diff options
author | Robert Guo <robertguo@me.com> | 2018-01-27 11:37:24 -0500 |
---|---|---|
committer | Robert Guo <robertguo@me.com> | 2018-01-27 11:39:46 -0500 |
commit | 8d9b68094ca79bce5da7cf530a2e14383b466a72 (patch) | |
tree | 32ae219957779a2baf60d26a42e7086e015f473a /site_scons/site_tools | |
parent | 0aeb5ce7e8d4a190dac43fd110533eef149f7880 (diff) | |
download | mongo-8d9b68094ca79bce5da7cf530a2e14383b466a72.tar.gz |
SERVER-32785 integrate Google Benchmark with SCons
Diffstat (limited to 'site_scons/site_tools')
-rw-r--r-- | site_scons/site_tools/mongo_benchmark.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/site_scons/site_tools/mongo_benchmark.py b/site_scons/site_tools/mongo_benchmark.py new file mode 100644 index 00000000000..bd3c09f9f3c --- /dev/null +++ b/site_scons/site_tools/mongo_benchmark.py @@ -0,0 +1,45 @@ +"""Pseudo-builders for building and registering benchmarks. +""" +from SCons.Script import Action + +def exists(env): + return True + +_benchmarks = [] +def register_benchmark(env, test): + _benchmarks.append(test.path) + env.Alias('$BENCHMARK_ALIAS', test) + +def benchmark_list_builder_action(env, target, source): + ofile = open(str(target[0]), 'wb') + try: + for s in _benchmarks: + print '\t' + str(s) + ofile.write('%s\n' % s) + finally: + ofile.close() + +def build_benchmark(env, target, source, **kwargs): + + bmEnv = env.Clone() + bmEnv.InjectThirdPartyIncludePaths(libraries=['benchmark']) + + if bmEnv.TargetOSIs('windows'): + bmEnv.Append(LIBS=["ShLwApi.lib"]) + + libdeps = kwargs.get('LIBDEPS', []) + libdeps.append('$BUILD_DIR/third_party/shim_benchmark') + + kwargs['LIBDEPS'] = libdeps + + result = bmEnv.Program(target, source, **kwargs) + bmEnv.RegisterBenchmark(result[0]) + bmEnv.Install("#/build/benchmark/", result[0]) + return result + +def generate(env): + env.Command('$BENCHMARK_LIST', env.Value(_benchmarks), + Action(benchmark_list_builder_action, "Generating $TARGET")) + env.AddMethod(register_benchmark, 'RegisterBenchmark') + env.AddMethod(build_benchmark, 'Benchmark') + env.Alias('$BENCHMARK_ALIAS', '$BENCHMARK_LIST') |