From 9caa65ba95d0d2e69895854dfca9fcdbba798671 Mon Sep 17 00:00:00 2001 From: "fennoai[bot]" <231223108+fennoai[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:28:12 +0000 Subject: [PATCH] feat(google/crc32c): add LLAR formula for crc32c 1.1.1+ Translate the Conan Center crc32c recipe into an idiomatic LLAR Formula. - fromVer "1.1.1": both 1.1.1 and 1.1.2 share the same upstream build contract (CMake option set, single installed header crc32c/crc32c.h, target crc32c, cmake_minimum_required 3.1), so one Formula serves both. - onBuild: CMake with CRC32C_BUILD_TESTS/BENCHMARKS/USE_GLOG=OFF and CRC32C_INSTALL=ON, matching the recipe. CMAKE_POLICY_VERSION_MINIMUM=3.5 keeps the CMake 3.1 project buildable under CMake 4. Metadata: -lcrc32c. - No dependencies: glog/googletest/benchmark are vendored subprojects used only by the disabled tests/benchmarks; there are no find_package deps. - onTest: compiles and runs a consumer mirroring the Conan test_package via the exported Crc32c::crc32c package target, in a build tree independent of onBuild so it also passes on a cache hit. Verified with `llar test` for 1.1.2 and 1.1.1 on linux/amd64, including a cache-hit re-run to exercise onTest without onBuild. Closes #47 Co-authored-by: fennoai[bot] <231223108+fennoai[bot]@users.noreply.github.com> Co-authored-by: MeteorsLiu <17515813+MeteorsLiu@users.noreply.github.com> --- google/crc32c/1.1.1/Crc32c_llar.gox | 84 +++++++++++++++++++++++++++++ google/crc32c/versions.json | 4 ++ 2 files changed, 88 insertions(+) create mode 100644 google/crc32c/1.1.1/Crc32c_llar.gox create mode 100644 google/crc32c/versions.json diff --git a/google/crc32c/1.1.1/Crc32c_llar.gox b/google/crc32c/1.1.1/Crc32c_llar.gox new file mode 100644 index 0000000..dd1e0e3 --- /dev/null +++ b/google/crc32c/1.1.1/Crc32c_llar.gox @@ -0,0 +1,84 @@ +import "os" + +id "google/crc32c" + +fromVer "1.1.1" + +onBuild ctx => { + installDir := ctx.outputDir + + c := cmake.new(ctx.SourceDir, ctx.SourceDir+"/_build", installDir) + c.buildType "Release" + // crc32c declares cmake_minimum_required(VERSION 3.1); allow CMake 4. + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + // Build only the library and its public header; skip the tooling that + // pulls in vendored glog/googletest/benchmark subprojects. + c.defineBool "CRC32C_BUILD_TESTS", false + c.defineBool "CRC32C_BUILD_BENCHMARKS", false + c.defineBool "CRC32C_USE_GLOG", false + c.defineBool "CRC32C_INSTALL", true + + c.configure + c.build + c.install + + // crc32c installs a single library named crc32c and no pkg-config file. + ctx.setMetadata "-lcrc32c" +} + +onTest ctx => { + installDir := ctx.outputDir + + // Keep the consumer's build tree separate from onBuild's _build so the + // test also runs on a cache hit, where onBuild is skipped and _build + // never exists. Everything lives under a fresh scratch directory. + testDir := ctx.SourceDir + "/_consumer" + testBuild := testDir + "/_build" + os.mkdirAll(testDir, 0o755)! + + // Minimal consumer mirroring the Conan test_package: include the public + // header and exercise both the raw-buffer and std::string overloads. + consumer := `#include +#include +#include "crc32c/crc32c.h" + +int main() { + const uint8_t buffer[4] = {0, 0, 0, 0}; + std::uint32_t a = crc32c::Crc32c(buffer, sizeof(buffer)); + + std::string s; + s.resize(4); + std::uint32_t b = crc32c::Crc32c(s); + + return (a == b) ? 0 : 1; +} +` + os.writeFile(testDir+"/consumer.cpp", []byte(consumer), 0o644)! + + cmakeLists := `cmake_minimum_required(VERSION 3.5) +project(crc32c_consumer CXX) +set(CMAKE_CXX_STANDARD 11) +# Consume via the exported CMake package (installed under lib/cmake/Crc32c); +# cmake.use puts the install root on CMAKE_PREFIX_PATH. The Crc32c::crc32c +# target carries its own include directories and library. +find_package(Crc32c CONFIG REQUIRED) +add_executable(crc32c_consumer consumer.cpp) +target_link_libraries(crc32c_consumer PRIVATE Crc32c::crc32c) +` + os.writeFile(testDir+"/CMakeLists.txt", []byte(cmakeLists), 0o644)! + + tc := cmake.new(testDir, testBuild, "") + tc.buildType "Release" + tc.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + // Put the install root on CMAKE_PREFIX_PATH so find_package locates it. + tc.use installDir + + tc.configure + tc.build + + // Run the consumer; a non-zero exit surfaces through lastErr. + exec testBuild + "/crc32c_consumer" + if lastErr != nil { + panic lastErr + } +} diff --git a/google/crc32c/versions.json b/google/crc32c/versions.json new file mode 100644 index 0000000..2bfbf0d --- /dev/null +++ b/google/crc32c/versions.json @@ -0,0 +1,4 @@ +{ + "path": "google/crc32c", + "deps": {} +}