feat(json-c): add json-c/json-c formula - #121
Conversation
Translate the Conan Center json-c recipe (snapshot ffe30df101afd4dc95aac2f14b25bf345e64d7be, version 0.18) into an LLAR Formula serving upstream tag json-c-0.18-20240915. The build uses the CMake helper with the library-only configuration the Conan recipe selects for its defaults: static archive with -fPIC, BUILD_TESTING and BUILD_APPS off, and a normalized lib/ install layout. Consumer metadata is derived from the installed json-c.pc pkg-config file (static query, so the private -lm dependency is reported). onTest compiles and runs the Conan test_package consumer against the installed CMake package in a build tree independent of the onBuild scratch tree so it also passes on a cache hit. No dependencies: the upstream source and the Conan recipe declare none. Co-authored-by: fennoai[bot] <231223108+fennoai[bot]@users.noreply.github.com> Co-authored-by: MeteorsLiu <17515813+MeteorsLiu@users.noreply.github.com>
There was a problem hiding this comment.
FennoAI Review — json-c/json-c Formula
Overall this is a well-structured Formula that follows the LLAR conventions closely: id, versions.json.path, and the directory json-c/json-c all agree; the filename stem Jsonc is a valid Go identifier; fromVer is a non-empty string literal aligned with the directory; c.configure/c.build/c.install are called without result assignment or ! as required; os.mkdirAll/os.writeFile use the ! failure form; and the capout + lastErr + ctx.setMetadata metadata block matches the reference. The cmake defines and the -lm/pkg-config comments were verified accurate against the json-c-0.18-20240915 source (json-c.pc.in Libs.private: @LIBS@, upstream DISABLE_STATIC_FPIC branch). Performance and security passes found no issues.
Two low-severity findings on the onTest consumer block are left inline. Neither is a correctness bug; both are about the temp-checkout convention and comment accuracy.
Reviewers should still confirm BUILD_STATIC_LIBS, BUILD_APPS, and DISABLE_STATIC_FPIC exist in the CMake of this exact upstream tag, and that llar test passes after both a fresh build and a cache hit.
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
|
|
||
| // Build the consumer in a tree independent of the onBuild scratch tree so |
There was a problem hiding this comment.
onTest synthesizes consumer.c and CMakeLists.txt and writes them into ctx.SourceDir (testDir := ctx.SourceDir + "/_llar_consumer"), mutating the temporary upstream checkout. The reference's "Installed-Output Tests" section says test source files should come from the fresh ctx.SourceDir checkout or from files shipped in the Formula module (read via ctx.Proj.readFile); the example treats ctx.SourceDir + "/consumer" as a pre-existing subdir, not a place to generate files. Consider shipping consumer.c/CMakeLists.txt in the Formula module (read with ctx.Proj.readFile) or writing them to a scratch dir outside the source checkout.
Also, the comment's stated reason is inaccurate: the separate tree is not what makes the test "run on a cache hit." On a cache hit LLAR creates a fresh ctx.SourceDir and runs onTest against the persisted ctx.outputDir, so onBuild's _build never exists there regardless. A build tree separate from _build is the right convention, but its real purpose is avoiding collision with onBuild's tree during a cache-miss build-then-test run — not enabling cache-hit tests. Suggest rewording to attribute it to that (or to convention).
Closes #39.
Translates the Conan Center
json-crecipe (snapshotffe30df101afd4dc95aac2f14b25bf345e64d7be, version0.18) into an idiomatic LLAR Formula.Module
json-c/json-c/versions.json— pathjson-c/json-c, no dependency fallbacks (json-c has none).json-c/json-c/json-c-0.18-20240915/Jsonc_llar.gox—fromVer "json-c-0.18-20240915", the exact upstream tag Conan records for0.18.Translation notes
requirements/tool_requires/test_requires, and the upstream0.18source confirms json-c is self-contained, so there is noonRequireanddepsis empty.>= 0.17:BUILD_STATIC_LIBS=ON/BUILD_SHARED_LIBS=OFF(Conan defaultshared=False),DISABLE_STATIC_FPIC=OFF(Conan defaultfPIC=True),BUILD_TESTING=OFF,BUILD_APPS=OFF.CMAKE_INSTALL_LIBDIR=libnormalizes the layout so the installedjson-c.pcand the dependency search paths resolve withoutlib64handling.json-c.pcviapkg-config --cflags --libs --static json-c, so the consumer flags include the private-lmjson-c uses on UNIX — matching the Conanpackage_info(system_libs = ["m"]on Linux/FreeBSD for>= 0.17).onTestmirrors the Conantest_package: it writes a small consumer that includes<json-c/json.h>, links the installedjson-c::json-cCMake target, builds it in a tree separate from theonBuildscratch tree, and runs it. This keeps the test valid on a cache hit (whereonBuildis skipped).fromVerboundary. Only the exact0.18tag is claimed as verified per the issue's instruction; no unverified version range is asserted.Validation
Built and installed with the local
goplus/llarCLI (installed exactly as CI does). All passing (exit 0):llar test -v ./json-c/json-c@json-c-0.18-20240915— fresh build + consumer run.onTest(onBuild skipped) still passes.llar test ./json-c/json-c@json-c-0.18-20240915 --os linux --arch amd64— explicit host matrix.llar test --verbose ./json-c/json-c --os linux --arch amd64— the exact CI command; resolves to the latest tag (json-c-0.19-20260627), whichfromVeralso serves, and builds/tests cleanly.The installed tree contains
lib/libjson-c.a,include/json-c/*.h,lib/pkgconfig/json-c.pc, andlib/cmake/json-c/, and the consumer prints{ "Categories": [ "c", "c++" ] }.