From f5f45de4e5fb9cb4411afd87034e807d63142dce Mon Sep 17 00:00:00 2001 From: "fennoai[bot]" <231223108+fennoai[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:31:31 +0000 Subject: [PATCH] feat(asyncplusplus): add Amanieu/asyncplusplus LLAR formula Translate the Conan Center asyncplusplus recipe (version 1.2) into an idiomatic LLAR formula. - fromVer v1.1: the Conan "all" folder serves 1.1 and 1.2, and both upstream tags share an identical CMake build/install contract. - No onRequire: upstream declares no external packages; it only needs the system threads library (find_package(Threads)). - onBuild builds the static library via the CMake helper (BUILD_SHARED_LIBS OFF, matching the Conan shared=False default) and installs the full public interface into ctx.outputDir. - Metadata is derived from the installed interface (no pkg-config file upstream): -DLIBASYNC_STATIC -lasync++ -lpthread. - onTest compiles and runs a small consumer (derived from the Conan test_package) against the installed artifacts in an independent build tree so it also passes on a cache hit. Verified with `llar test -v` for v1.2 and v1.1 (host --os/--arch linux with amd64 and arm64), plus a cache-hit re-run exercising onTest against cached artifacts. Closes #52 Co-authored-by: fennoai[bot] <231223108+fennoai[bot]@users.noreply.github.com> Co-authored-by: MeteorsLiu <17515813+MeteorsLiu@users.noreply.github.com> --- .../asyncplusplus/v1.1/Asyncplusplus_llar.gox | 79 +++++++++++++++++++ Amanieu/asyncplusplus/versions.json | 4 + 2 files changed, 83 insertions(+) create mode 100644 Amanieu/asyncplusplus/v1.1/Asyncplusplus_llar.gox create mode 100644 Amanieu/asyncplusplus/versions.json diff --git a/Amanieu/asyncplusplus/v1.1/Asyncplusplus_llar.gox b/Amanieu/asyncplusplus/v1.1/Asyncplusplus_llar.gox new file mode 100644 index 0000000..ae10f7f --- /dev/null +++ b/Amanieu/asyncplusplus/v1.1/Asyncplusplus_llar.gox @@ -0,0 +1,79 @@ +import "os" + +id "Amanieu/asyncplusplus" + +// Conan Center serves versions 1.1 and 1.2 from the same "all" recipe folder. +// Both upstream tags (v1.1, v1.2) share an identical CMake build and install +// contract, so a single formula covers the range from v1.1 upward. +fromVer "v1.1" + +// Async++ is a self-contained C++11 concurrency framework. Upstream only needs +// the system threads library (find_package(Threads)); it declares no external +// packages, matching the Conan recipe which has no requirements. Hence there is +// no onRequire. It also builds for any os/arch with a C++11 toolchain, and +// pthread is a system library resolved by the toolchain rather than an LLAR +// dependency, so no matrix constraints are needed. + +onBuild ctx => { + installDir := ctx.outputDir + + c := cmake.new(ctx.SourceDir, ctx.SourceDir+"/_build", installDir) + c.buildType "Release" + // Upstream declares cmake_minimum_required(VERSION 3.1); modern CMake needs + // this shim to accept the old policy baseline. + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + // Build the static library, matching the Conan default (shared=False). With + // BUILD_SHARED_LIBS=OFF, upstream defines LIBASYNC_STATIC on the target. + c.defineBool "BUILD_SHARED_LIBS", false + + c.configure + c.build + c.install + + // No pkg-config file is installed upstream, so derive the consumer flags + // from the installed interface: define LIBASYNC_STATIC for the static + // library (as both upstream CMake and the Conan package_info do), link + // libasync++, and link pthread (Async++ links Threads::Threads PUBLIC). + ctx.setMetadata "-DLIBASYNC_STATIC -lasync++ -lpthread" +} + +onTest ctx => { + installDir := ctx.outputDir + + // Keep the test build tree independent of the onBuild scratch tree so the + // test also works on a cache hit, when onBuild (and its _build dir) does + // not run. ctx.SourceDir is a fresh checkout that always exists. + testDir := ctx.SourceDir + "/_test" + os.mkdirAll(testDir, 0o755)! + + // Consumer derived from the Conan test_package: include and + // exercise the public spawn/then/when_all/parallel_reduce API, then run it. + consumerSource := `#include +#include + +int main() { + auto t1 = async::spawn([] { std::cout << "task1\n"; }); + auto t2 = async::spawn([]() -> int { return 42; }); + auto t3 = t2.then([](int v) -> int { return v * 3; }); + auto t4 = async::when_all(t1, t3); + t4.get(); + + int r = async::parallel_reduce({1, 2, 3, 4}, 0, [](int x, int y) { + return x + y; + }); + if (r != 10) { + std::cerr << "unexpected reduce result: " << r << "\n"; + return 1; + } + std::cout << "async++ ok: " << r << "\n"; + return 0; +} +` + src := testDir + "/consumer.cpp" + os.writeFile(src, []byte(consumerSource), 0o644)! + + bin := testDir + "/consumer" + exec "g++", "-std=c++11", "-DLIBASYNC_STATIC", "-I", installDir+"/include", "-o", bin, src, "-L", installDir+"/lib", "-lasync++", "-lpthread" + + exec bin +} diff --git a/Amanieu/asyncplusplus/versions.json b/Amanieu/asyncplusplus/versions.json new file mode 100644 index 0000000..2ab69c6 --- /dev/null +++ b/Amanieu/asyncplusplus/versions.json @@ -0,0 +1,4 @@ +{ + "path": "Amanieu/asyncplusplus", + "deps": {} +}