def generate_targets(repo_path): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get tests from Makefile tests = get_tests(repo_path) if src_mk is None or cc_files is None or tests is None: return False TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path) # rocksdb_lib TARGETS.add_library( "rocksdb_lib", src_mk["LIB_SOURCES"] + src_mk["TOOL_LIB_SOURCES"]) # rocksdb_test_lib TARGETS.add_library( "rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []), [":rocksdb_lib"]) # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []) + ["util/testutil.cc"], [":rocksdb_lib"]) # test for every test we found in the Makefile for test in sorted(tests): match_src = [src for src in cc_files if ("/%s.c" % test) in src] if len(match_src) == 0: print(ColorString.warning("Cannot find .cc file for %s" % test)) continue elif len(match_src) > 1: print(ColorString.warning("Found more than one .cc for %s" % test)) print(match_src) continue assert(len(match_src) == 1) is_parallel = tests[test] TARGETS.register_test(test, match_src[0], is_parallel) if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test TARGETS.add_library(test_library, match_src, [":rocksdb_test_lib"]) TARGETS.flush_tests() print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True
def generate_targets(repo_path): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get tests from Makefile tests = get_tests(repo_path) if src_mk is None or cc_files is None or tests is None: return False TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path) # rocksdb_lib TARGETS.add_library( "rocksdb_lib", src_mk["LIB_SOURCES"] + src_mk["TOOL_LIB_SOURCES"]) # rocksdb_test_lib TARGETS.add_library( "rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []), [":rocksdb_lib"]) # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + ["util/testutil.cc"], [":rocksdb_lib"]) # test for every test we found in the Makefile for test in sorted(tests): match_src = [src for src in cc_files if ("/%s.c" % test) in src] if len(match_src) == 0: print(ColorString.warning("Cannot find .cc file for %s" % test)) continue elif len(match_src) > 1: print(ColorString.warning("Found more than one .cc for %s" % test)) print(match_src) continue assert(len(match_src) == 1) is_parallel = tests[test] TARGETS.register_test(test, match_src[0], is_parallel) if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test TARGETS.add_library(test_library, match_src, [":rocksdb_test_lib"]) TARGETS.flush_tests() print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True
def exit_with_error(msg): print(ColorString.error(msg)) sys.exit(1)
def generate_targets(repo_path, deps_map): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get tests from Makefile tests = get_tests(repo_path) if src_mk is None or cc_files is None or tests is None: return False TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path) # rocksdb_lib TARGETS.add_library("rocksdb_lib", src_mk["LIB_SOURCES"] + src_mk["TOOL_LIB_SOURCES"]) # rocksdb_test_lib TARGETS.add_library( "rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []), [":rocksdb_lib"]) # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []) + ["test_util/testutil.cc"], [":rocksdb_lib"]) # rocksdb_stress_lib TARGETS.add_library( "rocksdb_stress_lib", src_mk.get("ANALYZER_LIB_SOURCES", []) + src_mk.get('STRESS_LIB_SOURCES', []) + ["test_util/testutil.cc"], [":rocksdb_lib", ":rocksdb_test_lib"]) print("Extra dependencies:\n{0}".format(json.dumps(deps_map))) # test for every test we found in the Makefile for target_alias, deps in deps_map.items(): for test in sorted(tests): match_src = [src for src in cc_files if ("/%s.c" % test) in src] if len(match_src) == 0: print(ColorString.warning("Cannot find .cc file for %s" % test)) continue elif len(match_src) > 1: print( ColorString.warning("Found more than one .cc for %s" % test)) print(match_src) continue assert (len(match_src) == 1) is_parallel = tests[test] test_target_name = \ test if not target_alias else test + "_" + target_alias TARGETS.register_test(test_target_name, match_src[0], is_parallel, json.dumps(deps['extra_deps']), json.dumps(deps['extra_compiler_flags'])) if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test_target_name TARGETS.add_library(test_library, match_src, [":rocksdb_test_lib"]) TARGETS.flush_tests() print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True
def generate_targets(repo_path, deps_map): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get non_parallel tests from Makefile non_parallel_tests = get_non_parallel_tests(repo_path) if src_mk is None or cc_files is None or non_parallel_tests is None: return False extra_argv = "" if len(sys.argv) >= 2: # Heuristically quote and canonicalize whitespace for inclusion # in how the file was generated. extra_argv = " '{0}'".format(" ".join(sys.argv[1].split())) TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path, extra_argv) # rocksdb_lib TARGETS.add_library( "rocksdb_lib", src_mk["LIB_SOURCES"] + # always add range_tree, it's only excluded on ppc64, which we don't use internally src_mk["RANGE_TREE_SOURCES"] + src_mk["TOOL_LIB_SOURCES"], deps=["//folly/container:f14_hash"]) # rocksdb_whole_archive_lib TARGETS.add_library( "rocksdb_whole_archive_lib", src_mk["LIB_SOURCES"] + # always add range_tree, it's only excluded on ppc64, which we don't use internally src_mk["RANGE_TREE_SOURCES"] + src_mk["TOOL_LIB_SOURCES"], deps=["//folly/container:f14_hash"], headers=None, extra_external_deps="", link_whole=True) # rocksdb_test_lib TARGETS.add_library("rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []), [":rocksdb_lib"], extra_test_libs=True) # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []) + ["test_util/testutil.cc"], [":rocksdb_lib"]) # rocksdb_cache_bench_tools_lib TARGETS.add_library("rocksdb_cache_bench_tools_lib", src_mk.get("CACHE_BENCH_LIB_SOURCES", []), [":rocksdb_lib"]) # rocksdb_stress_lib TARGETS.add_rocksdb_library( "rocksdb_stress_lib", src_mk.get("ANALYZER_LIB_SOURCES", []) + src_mk.get('STRESS_LIB_SOURCES', []) + ["test_util/testutil.cc"]) # db_stress binary TARGETS.add_binary("db_stress", ["db_stress_tool/db_stress.cc"], [":rocksdb_stress_lib"]) # bench binaries for src in src_mk.get("MICROBENCH_SOURCES", []): name = src.rsplit( '/', 1)[1].split('.')[0] if '/' in src else src.split('.')[0] TARGETS.add_binary(name, [src], [], extra_bench_libs=True) print("Extra dependencies:\n{0}".format(json.dumps(deps_map))) # Dictionary test executable name -> relative source file path test_source_map = {} # c_test.c is added through TARGETS.add_c_test(). If there # are more than one .c test file, we need to extend # TARGETS.add_c_test() to include other C tests too. for test_src in src_mk.get("TEST_MAIN_SOURCES_C", []): if test_src != 'db/c_test.c': print("Don't know how to deal with " + test_src) return False TARGETS.add_c_test() try: with open(f"{repo_path}/buckifier/bench.json") as json_file: fast_fancy_bench_config_list = json.load(json_file) for config_dict in fast_fancy_bench_config_list: clean_benchmarks = {} benchmarks = config_dict['benchmarks'] for binary, benchmark_dict in benchmarks.items(): clean_benchmarks[binary] = {} for benchmark, overloaded_metric_list in benchmark_dict.items( ): clean_benchmarks[binary][benchmark] = [] for metric in overloaded_metric_list: if not isinstance(metric, dict): clean_benchmarks[binary][benchmark].append( metric) TARGETS.add_fancy_bench_config( config_dict['name'], clean_benchmarks, False, config_dict['expected_runtime_one_iter'], config_dict['sl_iterations'], config_dict['regression_threshold']) with open(f"{repo_path}/buckifier/bench-slow.json") as json_file: slow_fancy_bench_config_list = json.load(json_file) for config_dict in slow_fancy_bench_config_list: clean_benchmarks = {} benchmarks = config_dict['benchmarks'] for binary, benchmark_dict in benchmarks.items(): clean_benchmarks[binary] = {} for benchmark, overloaded_metric_list in benchmark_dict.items( ): clean_benchmarks[binary][benchmark] = [] for metric in overloaded_metric_list: if not isinstance(metric, dict): clean_benchmarks[binary][benchmark].append( metric) for config_dict in slow_fancy_bench_config_list: TARGETS.add_fancy_bench_config( config_dict['name'] + "_slow", clean_benchmarks, True, config_dict['expected_runtime_one_iter'], config_dict['sl_iterations'], config_dict['regression_threshold']) # it is better servicelab experiments break # than rocksdb github ci except Exception: pass TARGETS.add_test_header() for test_src in src_mk.get("TEST_MAIN_SOURCES", []): test = test_src.split('.c')[0].strip().split('/')[-1].strip() test_source_map[test] = test_src print("" + test + " " + test_src) for target_alias, deps in deps_map.items(): for test, test_src in sorted(test_source_map.items()): if len(test) == 0: print( ColorString.warning("Failed to get test name for %s" % test_src)) continue test_target_name = \ test if not target_alias else test + "_" + target_alias if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test_target_name TARGETS.add_library(test_library, [test_src], deps=[":rocksdb_test_lib"], extra_test_libs=True) TARGETS.register_test(test_target_name, test_src, deps=json.dumps(deps['extra_deps'] + [':' + test_library]), extra_compiler_flags=json.dumps( deps['extra_compiler_flags'])) else: TARGETS.register_test(test_target_name, test_src, deps=json.dumps(deps['extra_deps'] + [":rocksdb_test_lib"]), extra_compiler_flags=json.dumps( deps['extra_compiler_flags'])) print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True
def generate_targets(repo_path, deps_map): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get non_parallel tests from Makefile non_parallel_tests = get_non_parallel_tests(repo_path) if src_mk is None or cc_files is None or non_parallel_tests is None: return False extra_argv = "" if len(sys.argv) >= 2: # Heuristically quote and canonicalize whitespace for inclusion # in how the file was generated. extra_argv = " '{0}'".format(" ".join(sys.argv[1].split())) TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path, extra_argv) # rocksdb_lib TARGETS.add_library( "rocksdb_lib", src_mk["LIB_SOURCES"] + # always add range_tree, it's only excluded on ppc64, which we don't use internally src_mk["RANGE_TREE_SOURCES"] + src_mk["TOOL_LIB_SOURCES"]) # rocksdb_whole_archive_lib TARGETS.add_library( "rocksdb_whole_archive_lib", src_mk["LIB_SOURCES"] + # always add range_tree, it's only excluded on ppc64, which we don't use internally src_mk["RANGE_TREE_SOURCES"] + src_mk["TOOL_LIB_SOURCES"], deps=None, headers=None, extra_external_deps="", link_whole=True) # rocksdb_test_lib TARGETS.add_library("rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []), [":rocksdb_lib"], extra_external_deps=""" + [ ("googletest", None, "gtest"), ]""") # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []) + ["test_util/testutil.cc"], [":rocksdb_lib"]) # rocksdb_stress_lib TARGETS.add_rocksdb_library( "rocksdb_stress_lib", src_mk.get("ANALYZER_LIB_SOURCES", []) + src_mk.get('STRESS_LIB_SOURCES', []) + ["test_util/testutil.cc"]) print("Extra dependencies:\n{0}".format(json.dumps(deps_map))) # Dictionary test executable name -> relative source file path test_source_map = {} print(src_mk) # c_test.c is added through TARGETS.add_c_test(). If there # are more than one .c test file, we need to extend # TARGETS.add_c_test() to include other C tests too. for test_src in src_mk.get("TEST_MAIN_SOURCES_C", []): if test_src != 'db/c_test.c': print("Don't know how to deal with " + test_src) return False TARGETS.add_c_test() for test_src in src_mk.get("TEST_MAIN_SOURCES", []): test = test_src.split('.c')[0].strip().split('/')[-1].strip() test_source_map[test] = test_src print("" + test + " " + test_src) for target_alias, deps in deps_map.items(): for test, test_src in sorted(test_source_map.items()): if len(test) == 0: print( ColorString.warning("Failed to get test name for %s" % test_src)) continue test_target_name = \ test if not target_alias else test + "_" + target_alias TARGETS.register_test(test_target_name, test_src, test not in non_parallel_tests, json.dumps(deps['extra_deps']), json.dumps(deps['extra_compiler_flags'])) if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test_target_name TARGETS.add_library(test_library, [test_src], [":rocksdb_test_lib"]) TARGETS.flush_tests() print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True
def generate_targets(repo_path, deps_map): print(ColorString.info("Generating TARGETS")) # parsed src.mk file src_mk = parse_src_mk(repo_path) # get all .cc files cc_files = get_cc_files(repo_path) # get parallel tests from Makefile parallel_tests = get_parallel_tests(repo_path) if src_mk is None or cc_files is None or parallel_tests is None: return False TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path) # rocksdb_lib TARGETS.add_library( "rocksdb_lib", src_mk["LIB_SOURCES"] + src_mk["TOOL_LIB_SOURCES"]) # rocksdb_test_lib TARGETS.add_library( "rocksdb_test_lib", src_mk.get("MOCK_LIB_SOURCES", []) + src_mk.get("TEST_LIB_SOURCES", []) + src_mk.get("EXP_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []), [":rocksdb_lib"], extra_external_deps=""" + [ ("googletest", None, "gtest"), ]""") # rocksdb_tools_lib TARGETS.add_library( "rocksdb_tools_lib", src_mk.get("BENCH_LIB_SOURCES", []) + src_mk.get("ANALYZER_LIB_SOURCES", []) + ["test_util/testutil.cc"], [":rocksdb_lib"]) # rocksdb_stress_lib TARGETS.add_rocksdb_library( "rocksdb_stress_lib", src_mk.get("ANALYZER_LIB_SOURCES", []) + src_mk.get('STRESS_LIB_SOURCES', []) + ["test_util/testutil.cc"]) print("Extra dependencies:\n{0}".format(json.dumps(deps_map))) # Dictionary test executable name -> relative source file path test_source_map = {} print(src_mk) test_main_sources = src_mk.get("TEST_MAIN_SOURCES", []) + \ src_mk.get("TEST_MAIN_SOURCES_C", []) for test_src in test_main_sources: test = test_src.split('.c')[0].strip().split('/')[-1].strip() test_source_map[test] = test_src print("" + test + " " + test_src) for target_alias, deps in deps_map.items(): for test, test_src in sorted(test_source_map.items()): if len(test) == 0: print(ColorString.warning("Failed to get test name for %s" % test_src)) continue test_target_name = \ test if not target_alias else test + "_" + target_alias TARGETS.register_test( test_target_name, test_src, test in parallel_tests, json.dumps(deps['extra_deps']), json.dumps(deps['extra_compiler_flags'])) if test in _EXPORTED_TEST_LIBS: test_library = "%s_lib" % test_target_name TARGETS.add_library(test_library, [test_src], [":rocksdb_test_lib"]) TARGETS.flush_tests() print(ColorString.info("Generated TARGETS Summary:")) print(ColorString.info("- %d libs" % TARGETS.total_lib)) print(ColorString.info("- %d binarys" % TARGETS.total_bin)) print(ColorString.info("- %d tests" % TARGETS.total_test)) return True