From: Nico Weber Date: Mon, 11 May 2020 23:31:26 +0000 (-0400) Subject: [gn build] Make paths in generated llvm-lit relative. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18324bb3d9175d000c6b83e3383a8feecfafdfed;p=platform%2Fupstream%2Fllvm.git [gn build] Make paths in generated llvm-lit relative. This ports d4638cba and e613f0ee to the GN build. Since paths in the generated lit.site.cfg.py files still contain absolute paths in the GN build, this isn't very useful yet. No intended behavior change. --- diff --git a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn index d3da6fc..0dd17f3 100644 --- a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn @@ -7,6 +7,8 @@ import("//llvm/utils/gn/build/write_cmake_config.gni") write_cmake_config("llvm-lit") { input = "llvm-lit.in" + + # The rebase_path() calls below assume that this is in $root_out_dir/bin. output = "$root_out_dir/bin/llvm-lit" if (host_os == "win") { @@ -76,16 +78,18 @@ write_cmake_config("llvm-lit") { # 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" + config_map = + "def path(p):\n" + " if not p: return ''\n" + + " return os.path.abspath(os.path.join(__file__, '..', '..', p))\n" foreach(entry, entries) { - config_map += "map_config('" + rebase_path(entry[0]) + "', '" + - rebase_path(entry[1]) + "')\n" + config_map += + "\nmap_config(\n path(r'" + rebase_path(entry[0], root_out_dir) + + "'),\n path(r'" + rebase_path(entry[1], root_out_dir) + "'))" } values = [ - "LLVM_SOURCE_DIR=" + rebase_path("//llvm"), + "LLVM_SOURCE_DIR=" + rebase_path("//llvm", root_out_dir), "BUILD_MODE=.", "LLVM_LIT_CONFIG_MAP=" + config_map, ]