From f35557899b4a4c96e444c1256b7c3d9e5bdc1c89 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 11 May 2020 19:21:31 -0400 Subject: [PATCH] [gn build] Make config_map computation in llvm-lit more table-driven. No behavior change. --- .../gn/secondary/llvm/utils/llvm-lit/BUILD.gn | 87 ++++++++++++------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn b/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn index ca2ca2412cf..d3da6fc3e93 100644 --- a/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn +++ b/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn @@ -17,13 +17,6 @@ write_cmake_config("llvm-lit") { # lit's lit/llvm/config.py shells out to llvm-config. deps = [ "//llvm/tools/llvm-config" ] - # Generate LLVM_LIT_CONFIG_MAP parameter. - # llvm-lit contains a mapping from each lit.cfg.py file to the corresponding - # generated llvm.site.cfg.py file, so llvm-lit depends on all the targets to - # generate the site.cfg.py file. - # FIXME: Write relative paths for path()s. - config_map = "def path(p): return p if p else \"\"\n" - deps += [ "//clang-tools-extra/test:lit_site_cfg", "//clang-tools-extra/test:lit_unit_site_cfg", @@ -35,31 +28,61 @@ write_cmake_config("llvm-lit") { "//llvm/test:lit_unit_site_cfg", ] - # Note: \n is converted into a newline by write_cmake_config.py, not by gn. - config_map += - "map_config('" + rebase_path("//clang-tools-extra/test/lit.cfg.py") + - "', '" + rebase_path(clang_tools_extra_lit_site_cfg_file) + "')\n" - config_map += - "map_config('" + rebase_path("//clang-tools-extra/test/Unit/lit.cfg.py") + - "', '" + rebase_path(clang_tools_extra_lit_unit_site_cfg_file) + "')\n" - config_map += "map_config('" + - rebase_path("//clang-tools-extra/clangd/test/lit.cfg.py") + - "', '" + rebase_path(clangd_lit_site_cfg_file) + "')\n" - config_map += "map_config('" + - rebase_path("//clang-tools-extra/clang/unittests/lit.cfg.py") + - "', '" + rebase_path(clangd_lit_unit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//clang/test/lit.cfg.py") + - "', '" + rebase_path(clang_lit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//clang/test/Unit/lit.cfg.py") + - "', '" + rebase_path(clang_lit_unit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//lld/test/lit.cfg.py") + "', '" + - rebase_path(lld_lit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//lld/test/Unit/lit.cfg.py") + - "', '" + rebase_path(lld_lit_unit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//llvm/test/lit.cfg.py") + - "', '" + rebase_path(llvm_lit_site_cfg_file) + "')\n" - config_map += "map_config('" + rebase_path("//llvm/test/Unit/lit.cfg.py") + - "', '" + rebase_path(llvm_lit_unit_site_cfg_file) + "')\n" + entries = [ + [ + "//clang-tools-extra/test/lit.cfg.py", + clang_tools_extra_lit_site_cfg_file, + ], + [ + "//clang-tools-extra/test/Unit/lit.cfg.py", + clang_tools_extra_lit_unit_site_cfg_file, + ], + [ + "//clang-tools-extra/clangd/test/lit.cfg.py", + clangd_lit_site_cfg_file, + ], + [ + "//clang-tools-extra/clangd/unittests/lit.cfg.py", + clangd_lit_unit_site_cfg_file, + ], + [ + "//clang/test/lit.cfg.py", + clang_lit_site_cfg_file, + ], + [ + "//clang/test/Unit/lit.cfg.py", + clang_lit_unit_site_cfg_file, + ], + [ + "//lld/test/lit.cfg.py", + lld_lit_site_cfg_file, + ], + [ + "//lld/test/Unit/lit.cfg.py", + lld_lit_unit_site_cfg_file, + ], + [ + "//llvm/test/lit.cfg.py", + llvm_lit_site_cfg_file, + ], + [ + "//llvm/test/Unit/lit.cfg.py", + llvm_lit_unit_site_cfg_file, + ], + ] + + # Generate LLVM_LIT_CONFIG_MAP parameter. + # llvm-lit contains a mapping from each lit.cfg.py file to the corresponding + # generated llvm.site.cfg.py file, so llvm-lit depends on all the targets to + # generate the site.cfg.py file. + # Note: \n is converted to a newline by write_cmake_config.py, not by gn. + # FIXME: Write relative paths for path()s. + config_map = "def path(p): return p if p else \"\"\n" + + foreach(entry, entries) { + config_map += "map_config('" + rebase_path(entry[0]) + "', '" + + rebase_path(entry[1]) + "')\n" + } values = [ "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),