1#!/usr/bin/env python
2
3
4import confu
5parser = confu.standard_parser("pthreadpool configuration script")
6
7
8def main(args):
9    options = parser.parse_args(args)
10    build = confu.Build.from_options(options)
11
12    build.export_cpath("include", ["pthreadpool.h"])
13
14    with build.options(source_dir="src", extra_include_dirs="src", deps=build.deps.fxdiv):
15        sources = ["legacy-api.c", "portable-api.c"]
16        if build.target.is_emscripten:
17            sources.append("shim.c")
18        elif build.target.is_macos:
19            sources.append("gcd.c")
20        elif build.target.is_windows:
21            sources.append("windows.c")
22        else:
23            sources.append("pthreads.c")
24        build.static_library("pthreadpool", [build.cc(src) for src in sources])
25
26    with build.options(source_dir="test", deps=[build, build.deps.googletest]):
27        build.unittest("pthreadpool-test", build.cxx("pthreadpool.cc"))
28
29    with build.options(source_dir="bench", deps=[build, build.deps.googlebenchmark]):
30        build.benchmark("latency-bench", build.cxx("latency.cc"))
31        build.benchmark("throughput-bench", build.cxx("throughput.cc"))
32
33    return build
34
35
36if __name__ == "__main__":
37    import sys
38    main(sys.argv[1:]).generate()
39