-
Notifications
You must be signed in to change notification settings - Fork 2
feat(asyncplusplus): add Amanieu/asyncplusplus LLAR formula #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fennoai
wants to merge
2
commits into
main
Choose a base branch
from
fennoai/issue-52-1785407817
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <async++.h> and | ||
| // exercise the public spawn/then/when_all/parallel_reduce API, then run it. | ||
| consumerSource := `#include <async++.h> | ||
| #include <iostream> | ||
|
|
||
| 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 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "Amanieu/asyncplusplus", | ||
| "deps": {} | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional performance improvement:
c.buildcompiles single-threaded here.CMake.Build(inx/cmake/cmake.go) runscmake --build <dir> --config Releasewith no--parallel/-j, so only one core is used for the whole compile.Consider
c.build "--parallel"(portable; CMake picks the core count) to speed up the build. Non-blocking.