gn build: Add a template for calling write_cmake_config.py

No behavior change.

Differential Revision: https://reviews.llvm.org/D56487

llvm-svn: 350905
This commit is contained in:
Nico Weber 2019-01-10 23:10:04 +00:00
parent e50254c6ac
commit a82855a5d7
13 changed files with 207 additions and 276 deletions

View File

@ -17,8 +17,6 @@ Ideas for things to do:
- one-build-dir bootstrap builds using GN's toolchain feature - one-build-dir bootstrap builds using GN's toolchain feature
- move clang_tablegen into lib/ for private files - move clang_tablegen into lib/ for private files
- add write_cmake_config() template, use it throughout where
write_cmake_config.py is called
- add dead code stripping - add dead code stripping
- move run_tablegen.py from build to tablegen folder - move run_tablegen.py from build to tablegen folder
- figure out why -Iclang/Support gets added so often - figure out why -Iclang/Support gets added so often

View File

@ -0,0 +1,54 @@
# This file introduces a templates for calling write_cmake_config.py.
#
# write_cmake_config behaves like CMake's configure_file(), but runs at build
# time, not at generator time. See write_cmake_config.py for details.
#
# Parameters:
#
# input (required) [string]
#
# output (required) [string]
#
# values (required) [list of strings]
# Each entry is a '='-separated key-value pair used for substitution.
#
# Example use:
#
# write_cmake_config("attributes_compat_func_gen") {
# input = "Version.inc.in"
# output = "$root_gen_dir/clang/include/clang/Basic/Version.inc",
# values = [
# "CLANG_VERSION=$llvm_version",
# ]
# }
template("write_cmake_config") {
assert(defined(invoker.input), "must set 'input' in $target_name")
assert(defined(invoker.output), "must set 'output' in $target_name")
assert(defined(invoker.values), "must set 'values' in $target_name")
action(target_name) {
script = "//llvm/utils/gn/build/write_cmake_config.py"
sources = [
invoker.input,
]
outputs = [
invoker.output,
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
] + invoker.values
forward_variables_from(invoker,
[
"configs",
"deps",
"public_configs",
"public_deps",
"visibility",
])
}
}

View File

@ -1,22 +1,13 @@
import("//clang/utils/TableGen/clang_tablegen.gni") import("//clang/utils/TableGen/clang_tablegen.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
# Version header. # Version header.
action("version") { write_cmake_config("version") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "Version.inc.in"
output = "$target_gen_dir/Version.inc"
sources = [ values = [
"Version.inc.in",
]
outputs = [
"$root_gen_dir/clang/include/clang/Basic/Version.inc",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"CLANG_VERSION=$llvm_version", "CLANG_VERSION=$llvm_version",
"CLANG_VERSION_MAJOR=$llvm_version_major", "CLANG_VERSION_MAJOR=$llvm_version_major",
"CLANG_VERSION_MINOR=$llvm_version_minor", "CLANG_VERSION_MINOR=$llvm_version_minor",

View File

@ -1,6 +1,7 @@
import("//clang/lib/ARCMigrate/enable.gni") import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni") import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
config("Config_config") { config("Config_config") {
@ -8,20 +9,10 @@ config("Config_config") {
include_dirs = [ "$target_gen_dir/clang/include" ] include_dirs = [ "$target_gen_dir/clang/include" ]
} }
action("Config") { write_cmake_config("Config") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "config.h.cmake"
output = "$target_gen_dir/config.h"
sources = [ values = [
"config.h.cmake",
]
outputs = [
"$target_gen_dir/config.h",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"BUG_REPORT_URL=https://bugs.llvm.org/", "BUG_REPORT_URL=https://bugs.llvm.org/",
"CLANG_DEFAULT_LINKER=", "CLANG_DEFAULT_LINKER=",
"CLANG_DEFAULT_STD_C=", "CLANG_DEFAULT_STD_C=",
@ -47,36 +38,36 @@ action("Config") {
] ]
if (clang_enable_arcmt) { if (clang_enable_arcmt) {
args += [ "CLANG_ENABLE_ARCMT=1" ] values += [ "CLANG_ENABLE_ARCMT=1" ]
} else { } else {
args += [ "CLANG_ENABLE_ARCMT=" ] values += [ "CLANG_ENABLE_ARCMT=" ]
} }
if (clang_enable_static_analyzer) { if (clang_enable_static_analyzer) {
args += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ] values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
} else { } else {
args += [ "CLANG_ENABLE_STATIC_ANALYZER=" ] values += [ "CLANG_ENABLE_STATIC_ANALYZER=" ]
} }
if (host_os != "win") { if (host_os != "win") {
args += [ "CLANG_HAVE_RLIMITS=1" ] values += [ "CLANG_HAVE_RLIMITS=1" ]
} else { } else {
args += [ "CLANG_HAVE_RLIMITS=" ] values += [ "CLANG_HAVE_RLIMITS=" ]
} }
if (llvm_enable_libxml2) { if (llvm_enable_libxml2) {
args += [ "CLANG_HAVE_LIBXML=1" ] values += [ "CLANG_HAVE_LIBXML=1" ]
} else { } else {
args += [ "CLANG_HAVE_LIBXML=" ] values += [ "CLANG_HAVE_LIBXML=" ]
} }
if (host_os == "mac") { if (host_os == "mac") {
# FIXME: Hardcoding this isn't great, but assuming that the host ld version # FIXME: Hardcoding this isn't great, but assuming that the host ld version
# has anything to do with the ld version where the built clang will run # has anything to do with the ld version where the built clang will run
# isn't either. Probably want to make this a declare_args. # isn't either. Probably want to make this a declare_args.
args += [ "HOST_LINK_VERSION=305" ] values += [ "HOST_LINK_VERSION=305" ]
} else { } else {
args += [ "HOST_LINK_VERSION=" ] values += [ "HOST_LINK_VERSION=" ]
} }
# Let targets depending on this find the generated file. # Let targets depending on this find the generated file.

View File

@ -3,24 +3,15 @@ import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/lib/Target/targets.gni") import("//llvm/lib/Target/targets.gni")
import("//llvm/triples.gni") import("//llvm/triples.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni") import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("clang_lit_site_cfg_files.gni") import("clang_lit_site_cfg_files.gni")
template("write_lit_config") { template("write_lit_config") {
action(target_name) { write_cmake_config(target_name) {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = invoker.input
output = invoker.output
sources = [ values = [
invoker.input, "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
]
outputs = [
invoker.output,
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from ${sources[0]}, do not edit",
"CLANG_BINARY_DIR=" + "CLANG_BINARY_DIR=" +
rebase_path(get_label_info("//clang", "target_out_dir")), rebase_path(get_label_info("//clang", "target_out_dir")),
"CLANG_SOURCE_DIR=" + rebase_path("//clang"), "CLANG_SOURCE_DIR=" + rebase_path("//clang"),
@ -34,11 +25,11 @@ template("write_lit_config") {
] ]
if (host_os == "win") { if (host_os == "win") {
# See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
args += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ] values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
} else { } else {
args += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ] values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
} }
args += invoker.extra_args values += invoker.extra_values
} }
} }
@ -47,7 +38,7 @@ write_lit_config("lit_site_cfg") {
input = "//clang/test/lit.site.cfg.py.in" input = "//clang/test/lit.site.cfg.py.in"
output = clang_lit_site_cfg_file output = clang_lit_site_cfg_file
extra_args = [ extra_values = [
"CLANG_ANALYZER_WITH_Z3=", # Must be empty, not 0. "CLANG_ANALYZER_WITH_Z3=", # Must be empty, not 0.
"CLANG_BUILD_EXAMPLES=0", "CLANG_BUILD_EXAMPLES=0",
"CLANG_DEFAULT_CXX_STDLIB=", # Empty string means "default value" here. "CLANG_DEFAULT_CXX_STDLIB=", # Empty string means "default value" here.
@ -69,35 +60,35 @@ write_lit_config("lit_site_cfg") {
] ]
if (clang_enable_arcmt) { if (clang_enable_arcmt) {
extra_args += [ "CLANG_ENABLE_ARCMT=1" ] extra_values += [ "CLANG_ENABLE_ARCMT=1" ]
} else { } else {
extra_args += [ "CLANG_ENABLE_ARCMT=0" ] extra_values += [ "CLANG_ENABLE_ARCMT=0" ]
} }
if (clang_enable_static_analyzer) { if (clang_enable_static_analyzer) {
extra_args += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ] extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
} else { } else {
extra_args += [ "CLANG_ENABLE_STATIC_ANALYZER=0" ] extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=0" ]
} }
if (llvm_enable_zlib) { if (llvm_enable_zlib) {
extra_args += [ "HAVE_LIBZ=1" ] extra_values += [ "HAVE_LIBZ=1" ]
} else { } else {
extra_args += [ "HAVE_LIBZ=0" ] # Must be 0. extra_values += [ "HAVE_LIBZ=0" ] # Must be 0.
} }
if (host_cpu == "x64") { if (host_cpu == "x64") {
extra_args += [ "HOST_ARCH=x86_64" ] extra_values += [ "HOST_ARCH=x86_64" ]
} else { } else {
assert(false, "unimplemented host_cpu " + host_cpu) assert(false, "unimplemented host_cpu " + host_cpu)
} }
if (host_os == "mac") { if (host_os == "mac") {
extra_args += [ "LLVM_PLUGIN_EXT=.dylib" ] extra_values += [ "LLVM_PLUGIN_EXT=.dylib" ]
} else if (host_os == "win") { } else if (host_os == "win") {
extra_args += [ "LLVM_PLUGIN_EXT=.dll" ] extra_values += [ "LLVM_PLUGIN_EXT=.dll" ]
} else { } else {
extra_args += [ "LLVM_PLUGIN_EXT=.so" ] extra_values += [ "LLVM_PLUGIN_EXT=.so" ]
} }
} }
@ -105,7 +96,7 @@ write_lit_config("lit_unit_site_cfg") {
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
input = "//clang/test/Unit/lit.site.cfg.py.in" input = "//clang/test/Unit/lit.site.cfg.py.in"
output = clang_lit_unit_site_cfg_file output = clang_lit_unit_site_cfg_file
extra_args = [ "LLVM_BUILD_MODE=." ] extra_values = [ "LLVM_BUILD_MODE=." ]
} }
# This target should contain all dependencies of check-clang. # This target should contain all dependencies of check-clang.

View File

@ -1,4 +1,5 @@
import("//llvm/utils/gn/build/symlink_or_copy.gni") import("//llvm/utils/gn/build/symlink_or_copy.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
symlinks = [ symlinks = [
@ -35,20 +36,10 @@ group("symlinks") {
} }
if (host_os == "mac") { if (host_os == "mac") {
action("write_info_plist") { write_cmake_config("write_info_plist") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "Info.plist.in"
sources = [ output = "$target_gen_dir/Info.plist"
"Info.plist.in", values = [
]
outputs = [
"$target_gen_dir/Info.plist",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor", "TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
"TOOL_INFO_NAME=clang", "TOOL_INFO_NAME=clang",
"TOOL_INFO_UTI=org.llvm.clang", "TOOL_INFO_UTI=org.llvm.clang",

View File

@ -1,19 +1,10 @@
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
action("version") { write_cmake_config("version") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "Version.inc.in"
output = "$target_gen_dir/Version.inc"
sources = [ values = [
"Version.inc.in",
]
outputs = [
"$target_gen_dir/Version.inc",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LLD_VERSION=$llvm_version", "LLD_VERSION=$llvm_version",
"LLD_VERSION_MAJOR=$llvm_version_major", "LLD_VERSION_MAJOR=$llvm_version_major",
"LLD_VERSION_MINOR=$llvm_version_minor", "LLD_VERSION_MINOR=$llvm_version_minor",

View File

@ -2,26 +2,16 @@ import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
import("//llvm/triples.gni") import("//llvm/triples.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni") import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("lld_lit_site_cfg_files.gni") import("lld_lit_site_cfg_files.gni")
# The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in. # The bits common to writing lit.site.cfg.py.in and Unit/lit.site.cfg.py.in.
template("write_lit_cfg") { template("write_lit_cfg") {
action(target_name) { write_cmake_config(target_name) {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = invoker.input
output = invoker.output
sources = [ values = [
invoker.input, "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
]
outputs = [
invoker.output,
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from ${sources[0]}, do not edit",
"LLD_BINARY_DIR=" + "LLD_BINARY_DIR=" +
rebase_path(get_label_info("//lld", "target_out_dir")), rebase_path(get_label_info("//lld", "target_out_dir")),
"LLD_SOURCE_DIR=" + rebase_path("//lld"), "LLD_SOURCE_DIR=" + rebase_path("//lld"),
@ -36,7 +26,7 @@ template("write_lit_cfg") {
"PYTHON_EXECUTABLE=$python_path", "PYTHON_EXECUTABLE=$python_path",
"TARGET_TRIPLE=$llvm_target_triple", "TARGET_TRIPLE=$llvm_target_triple",
] ]
args += invoker.extra_args values += invoker.extra_values
} }
} }
@ -45,23 +35,23 @@ write_lit_cfg("lit_site_cfg") {
input = "//lld/test/lit.site.cfg.py.in" input = "//lld/test/lit.site.cfg.py.in"
output = lld_lit_site_cfg_file output = lld_lit_site_cfg_file
extra_args = [] extra_values = []
if (llvm_enable_dia_sdk) { if (llvm_enable_dia_sdk) {
extra_args += [ "LLVM_ENABLE_DIA_SDK=1" ] extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
} else { } else {
extra_args += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0. extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
} }
if (llvm_enable_libxml2) { if (llvm_enable_libxml2) {
extra_args += [ "LLVM_LIBXML2_ENABLED=1" ] extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
} else { } else {
extra_args += [ "LLVM_LIBXML2_ENABLED=" ] # Must be empty. extra_values += [ "LLVM_LIBXML2_ENABLED=" ] # Must be empty.
} }
if (llvm_enable_zlib) { if (llvm_enable_zlib) {
extra_args += [ "HAVE_LIBZ=1" ] extra_values += [ "HAVE_LIBZ=1" ]
} else { } else {
extra_args += [ "HAVE_LIBZ=0" ] # Must be 0. extra_values += [ "HAVE_LIBZ=0" ] # Must be 0.
} }
} }
@ -69,7 +59,7 @@ write_lit_cfg("lit_unit_site_cfg") {
# Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER. # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
input = "//lld/test/Unit/lit.site.cfg.py.in" input = "//lld/test/Unit/lit.site.cfg.py.in"
output = lld_lit_unit_site_cfg_file output = lld_lit_unit_site_cfg_file
extra_args = [ "LLVM_BUILD_MODE=." ] extra_values = [ "LLVM_BUILD_MODE=." ]
} }
# This target should contain all dependencies of check-lld. # This target should contain all dependencies of check-lld.

View File

@ -7,6 +7,7 @@ import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
import("//llvm/utils/gn/build/libs/xar/enable.gni") import("//llvm/utils/gn/build/libs/xar/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni") import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
# Contains actions to create config.h, llvm-config.h, abi-breaking.h, # Contains actions to create config.h, llvm-config.h, abi-breaking.h,
@ -43,53 +44,32 @@ declare_args() {
llvm_enable_reverse_iteration = false llvm_enable_reverse_iteration = false
} }
action("abi-breaking") { write_cmake_config("abi-breaking") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "abi-breaking.h.cmake"
output = "$target_gen_dir/abi-breaking.h"
sources = [ values = []
"abi-breaking.h.cmake",
]
outputs = [
"$target_gen_dir/abi-breaking.h",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
]
if (llvm_enable_abi_breaking_checks) { if (llvm_enable_abi_breaking_checks) {
args += [ "LLVM_ENABLE_ABI_BREAKING_CHECKS=1" ] values += [ "LLVM_ENABLE_ABI_BREAKING_CHECKS=1" ]
} else { } else {
args += [ "LLVM_ENABLE_ABI_BREAKING_CHECKS=" ] values += [ "LLVM_ENABLE_ABI_BREAKING_CHECKS=" ]
} }
if (llvm_enable_reverse_iteration) { if (llvm_enable_reverse_iteration) {
args += [ "LLVM_ENABLE_REVERSE_ITERATION=1" ] values += [ "LLVM_ENABLE_REVERSE_ITERATION=1" ]
} else { } else {
args += [ "LLVM_ENABLE_REVERSE_ITERATION=" ] values += [ "LLVM_ENABLE_REVERSE_ITERATION=" ]
} }
} }
action("config") { write_cmake_config("config") {
script = "//llvm/utils/gn/build/write_cmake_config.py"
public_deps = [ public_deps = [
":llvm-config", ":llvm-config",
] ]
sources = [ input = "config.h.cmake"
"config.h.cmake", output = "$target_gen_dir/config.h"
] values = [
outputs = [
"$target_gen_dir/config.h",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"BUG_REPORT_URL=https://bugs.llvm.org/", "BUG_REPORT_URL=https://bugs.llvm.org/",
"ENABLE_BACKTRACES=1", "ENABLE_BACKTRACES=1",
"ENABLE_CRASH_OVERRIDES=1", "ENABLE_CRASH_OVERRIDES=1",
@ -149,7 +129,7 @@ action("config") {
] ]
if (host_os == "linux") { if (host_os == "linux") {
args += [ values += [
"HAVE_FUTIMENS=1", "HAVE_FUTIMENS=1",
"HAVE_LINK_H=1", "HAVE_LINK_H=1",
"HAVE_LSEEK64=1", "HAVE_LSEEK64=1",
@ -161,7 +141,7 @@ action("config") {
"HAVE_VALGRIND_VALGRIND_H=1", "HAVE_VALGRIND_VALGRIND_H=1",
] ]
} else { } else {
args += [ values += [
"HAVE_FUTIMENS=", "HAVE_FUTIMENS=",
"HAVE_LINK_H=", "HAVE_LINK_H=",
"HAVE_LSEEK64=", "HAVE_LSEEK64=",
@ -175,7 +155,7 @@ action("config") {
} }
if (host_os == "mac") { if (host_os == "mac") {
args += [ values += [
"HAVE_CRASHREPORTER_INFO=1", "HAVE_CRASHREPORTER_INFO=1",
"HAVE_DECL_ARC4RANDOM=1", "HAVE_DECL_ARC4RANDOM=1",
"HAVE_DLADDR=1", "HAVE_DLADDR=1",
@ -186,7 +166,7 @@ action("config") {
"HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=1", "HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=1",
] ]
} else { } else {
args += [ values += [
"HAVE_CRASHREPORTER_INFO=", "HAVE_CRASHREPORTER_INFO=",
"HAVE_DECL_ARC4RANDOM=", "HAVE_DECL_ARC4RANDOM=",
"HAVE_DLADDR=", "HAVE_DLADDR=",
@ -199,7 +179,7 @@ action("config") {
} }
if (host_os == "win") { if (host_os == "win") {
args += [ values += [
"HAVE_BACKTRACE=", "HAVE_BACKTRACE=",
"HAVE_DECL_STRERROR_S=1", "HAVE_DECL_STRERROR_S=1",
"HAVE_DLFCN_H=", "HAVE_DLFCN_H=",
@ -241,7 +221,7 @@ action("config") {
] ]
} else { } else {
# POSIX-y system defaults. # POSIX-y system defaults.
args += [ values += [
"HAVE_BACKTRACE=1", "HAVE_BACKTRACE=1",
"HAVE_DECL_STRERROR_S=", "HAVE_DECL_STRERROR_S=",
"HAVE_DLFCN_H=1", "HAVE_DLFCN_H=1",
@ -284,58 +264,48 @@ action("config") {
} }
if (host_os == "linux") { if (host_os == "linux") {
args += [ "LTDL_SHLIB_EXT=.so" ] values += [ "LTDL_SHLIB_EXT=.so" ]
} else if (host_os == "mac") { } else if (host_os == "mac") {
args += [ "LTDL_SHLIB_EXT=.dylib" ] values += [ "LTDL_SHLIB_EXT=.dylib" ]
} else if (host_os == "win") { } else if (host_os == "win") {
args += [ "LTDL_SHLIB_EXT=.dll" ] values += [ "LTDL_SHLIB_EXT=.dll" ]
} }
if (llvm_enable_libedit) { if (llvm_enable_libedit) {
args += [ "HAVE_LIBEDIT=1" ] values += [ "HAVE_LIBEDIT=1" ]
} else { } else {
args += [ "HAVE_LIBEDIT=" ] values += [ "HAVE_LIBEDIT=" ]
} }
if (llvm_enable_libxar) { if (llvm_enable_libxar) {
args += [ "HAVE_LIBXAR=1" ] values += [ "HAVE_LIBXAR=1" ]
} else { } else {
args += [ "HAVE_LIBXAR=" ] values += [ "HAVE_LIBXAR=" ]
} }
if (llvm_enable_terminfo) { if (llvm_enable_terminfo) {
args += [ "HAVE_TERMINFO=1" ] values += [ "HAVE_TERMINFO=1" ]
} else { } else {
args += [ "HAVE_TERMINFO=" ] values += [ "HAVE_TERMINFO=" ]
} }
if (llvm_enable_zlib) { if (llvm_enable_zlib) {
args += [ "LLVM_ENABLE_ZLIB=1" ] values += [ "LLVM_ENABLE_ZLIB=1" ]
} else { } else {
args += [ "LLVM_ENABLE_ZLIB=" ] values += [ "LLVM_ENABLE_ZLIB=" ]
} }
if (llvm_enable_libxml2) { if (llvm_enable_libxml2) {
args += [ "LLVM_LIBXML2_ENABLED=1" ] values += [ "LLVM_LIBXML2_ENABLED=1" ]
} else { } else {
args += [ "LLVM_LIBXML2_ENABLED=" ] values += [ "LLVM_LIBXML2_ENABLED=" ]
} }
} }
action("llvm-config") { write_cmake_config("llvm-config") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "llvm-config.h.cmake"
output = "$target_gen_dir/llvm-config.h"
sources = [ values = [
"llvm-config.h.cmake",
]
outputs = [
"$target_gen_dir/llvm-config.h",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LLVM_ENABLE_DUMP=", "LLVM_ENABLE_DUMP=",
"LINK_POLLY_INTO_TOOLS=", "LINK_POLLY_INTO_TOOLS=",
"LLVM_DEFAULT_TARGET_TRIPLE=$llvm_target_triple", "LLVM_DEFAULT_TARGET_TRIPLE=$llvm_target_triple",
@ -359,15 +329,15 @@ action("llvm-config") {
] ]
if (host_os == "win") { if (host_os == "win") {
args += [ "LLVM_ON_UNIX=" ] values += [ "LLVM_ON_UNIX=" ]
} else { } else {
args += [ "LLVM_ON_UNIX=1" ] values += [ "LLVM_ON_UNIX=1" ]
} }
if (llvm_enable_threads) { if (llvm_enable_threads) {
args += [ "LLVM_ENABLE_THREADS=1" ] values += [ "LLVM_ENABLE_THREADS=1" ]
} else { } else {
args += [ "LLVM_ENABLE_THREADS=" ] values += [ "LLVM_ENABLE_THREADS=" ]
} }
} }
@ -378,16 +348,10 @@ template("write_target_def_file") {
assert(defined(invoker.key), "must set 'key' in $target_name") assert(defined(invoker.key), "must set 'key' in $target_name")
assert(defined(invoker.value), "must set 'value' in $target_name") assert(defined(invoker.value), "must set 'value' in $target_name")
action(target_name) { write_cmake_config(target_name) {
visibility = [ ":write_target_def_files" ] visibility = [ ":write_target_def_files" ]
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "$target_name.in"
output = "$target_gen_dir/$target_name"
sources = [
"$target_name.in",
]
outputs = [
"$target_gen_dir/$target_name",
]
# Build something like # Build something like
# `LLVM_ENUM_ASM_PARSERS=LLVM_ASM_PARSER(ARM)\nLLVM_ASM_PARSER(X86)\n`. Note # `LLVM_ENUM_ASM_PARSERS=LLVM_ASM_PARSER(ARM)\nLLVM_ASM_PARSER(X86)\n`. Note
@ -397,10 +361,7 @@ template("write_target_def_file") {
foreach(target, llvm_targets_to_build) { foreach(target, llvm_targets_to_build) {
value = "$value${invoker.value}($target)\n" value = "$value${invoker.value}($target)\n"
} }
args = [ values = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"${invoker.key}=$value", "${invoker.key}=$value",
] ]
} }

View File

@ -81,8 +81,8 @@ static_library("LLVMWebAssemblyCodeGen") {
"WebAssemblyLowerEmscriptenEHSjLj.cpp", "WebAssemblyLowerEmscriptenEHSjLj.cpp",
"WebAssemblyLowerGlobalDtors.cpp", "WebAssemblyLowerGlobalDtors.cpp",
"WebAssemblyMCInstLower.cpp", "WebAssemblyMCInstLower.cpp",
"WebAssemblyMemIntrinsicResults.cpp",
"WebAssemblyMachineFunctionInfo.cpp", "WebAssemblyMachineFunctionInfo.cpp",
"WebAssemblyMemIntrinsicResults.cpp",
"WebAssemblyOptimizeLiveIntervals.cpp", "WebAssemblyOptimizeLiveIntervals.cpp",
"WebAssemblyOptimizeReturned.cpp", "WebAssemblyOptimizeReturned.cpp",
"WebAssemblyPeephole.cpp", "WebAssemblyPeephole.cpp",

View File

@ -6,24 +6,15 @@ import("//llvm/utils/gn/build/libs/pthread/enable.gni")
import("//llvm/utils/gn/build/libs/xar/enable.gni") import("//llvm/utils/gn/build/libs/xar/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni") import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("llvm_lit_site_cfg_files.gni") import("llvm_lit_site_cfg_files.gni")
template("write_lit_config") { template("write_lit_config") {
action(target_name) { write_cmake_config(target_name) {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = invoker.input
output = invoker.output
sources = [ values = [
invoker.input, "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
]
outputs = [
invoker.output,
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LIT_SITE_CFG_IN_HEADER=## Autogenerated from ${sources[0]}, do not edit",
"ENABLE_SHARED=0", "ENABLE_SHARED=0",
"LLVM_BINARY_DIR=" + "LLVM_BINARY_DIR=" +
rebase_path(get_label_info("//llvm", "target_out_dir")), rebase_path(get_label_info("//llvm", "target_out_dir")),
@ -32,18 +23,18 @@ template("write_lit_config") {
] ]
if (host_os == "win") { if (host_os == "win") {
# See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
args += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ] values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin") ]
} else { } else {
args += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ] values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib") ]
} }
args += invoker.extra_args values += invoker.extra_values
} }
} }
write_lit_config("lit_site_cfg") { write_lit_config("lit_site_cfg") {
input = "//llvm/test/lit.site.cfg.py.in" input = "//llvm/test/lit.site.cfg.py.in"
output = llvm_lit_site_cfg_file output = llvm_lit_site_cfg_file
extra_args = [ extra_values = [
"BUILD_SHARED_LIBS=0", "BUILD_SHARED_LIBS=0",
# Only used by the Go bindings tests, or if LLVM_USE_SANITIZER includes # Only used by the Go bindings tests, or if LLVM_USE_SANITIZER includes
@ -88,25 +79,25 @@ write_lit_config("lit_site_cfg") {
] ]
if (host_cpu == "x64") { if (host_cpu == "x64") {
extra_args += [ "HOST_ARCH=x86_64" ] extra_values += [ "HOST_ARCH=x86_64" ]
} else { } else {
assert(false, "unimplemented host_cpu " + host_cpu) assert(false, "unimplemented host_cpu " + host_cpu)
} }
if (host_os == "mac") { if (host_os == "mac") {
extra_args += [ extra_values += [
"EXEEXT=", "EXEEXT=",
"HOST_OS=Darwin", "HOST_OS=Darwin",
"SHLIBEXT=.dylib", "SHLIBEXT=.dylib",
] ]
} else if (host_os == "linux") { } else if (host_os == "linux") {
extra_args += [ extra_values += [
"EXEEXT=", "EXEEXT=",
"HOST_OS=Linux", "HOST_OS=Linux",
"SHLIBEXT=.so", "SHLIBEXT=.so",
] ]
} else if (host_os == "win") { } else if (host_os == "win") {
extra_args += [ extra_values += [
"EXEEXT=.exe", "EXEEXT=.exe",
"HOST_OS=Windows", "HOST_OS=Windows",
"SHLIBEXT=.dll", "SHLIBEXT=.dll",
@ -119,57 +110,57 @@ write_lit_config("lit_site_cfg") {
# so just claim that ld is gold on Linux. The function also checks if # so just claim that ld is gold on Linux. The function also checks if
# LLVMgold.so exists, but since that target isn't hooked up yet in the GN # LLVMgold.so exists, but since that target isn't hooked up yet in the GN
# build the LLVMgold.so tests currently don't run anywhere in the GN build. # build the LLVMgold.so tests currently don't run anywhere in the GN build.
extra_args += [ "GOLD_EXECUTABLE=ld" ] extra_values += [ "GOLD_EXECUTABLE=ld" ]
} else { } else {
extra_args += [ "GOLD_EXECUTABLE=" ] extra_values += [ "GOLD_EXECUTABLE=" ]
} }
if (host_os == "mac") { if (host_os == "mac") {
extra_args += [ "LD64_EXECUTABLE=ld" ] extra_values += [ "LD64_EXECUTABLE=ld" ]
} else { } else {
extra_args += [ "LD64_EXECUTABLE=" ] extra_values += [ "LD64_EXECUTABLE=" ]
} }
if (llvm_enable_assertions) { if (llvm_enable_assertions) {
extra_args += [ "ENABLE_ASSERTIONS=1" ] extra_values += [ "ENABLE_ASSERTIONS=1" ]
} else { } else {
extra_args += [ "ENABLE_ASSERTIONS=0" ] # Must be 0. extra_values += [ "ENABLE_ASSERTIONS=0" ] # Must be 0.
} }
if (llvm_enable_libxar) { if (llvm_enable_libxar) {
extra_args += [ "HAVE_LIBXAR=1" ] extra_values += [ "HAVE_LIBXAR=1" ]
} else { } else {
extra_args += [ "HAVE_LIBXAR=0" ] # Must be 0. extra_values += [ "HAVE_LIBXAR=0" ] # Must be 0.
} }
if (llvm_enable_dia_sdk) { if (llvm_enable_dia_sdk) {
extra_args += [ "LLVM_ENABLE_DIA_SDK=1" ] extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ]
} else { } else {
extra_args += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0. extra_values += [ "LLVM_ENABLE_DIA_SDK=0" ] # Must be 0.
} }
if (llvm_enable_libxml2) { if (llvm_enable_libxml2) {
extra_args += [ "LLVM_LIBXML2_ENABLED=1" ] extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
} else { } else {
extra_args += [ "LLVM_LIBXML2_ENABLED=" ] # Must be empty. extra_values += [ "LLVM_LIBXML2_ENABLED=" ] # Must be empty.
} }
if (llvm_enable_threads) { if (llvm_enable_threads) {
extra_args += [ "LLVM_ENABLE_THREADS=1" ] extra_values += [ "LLVM_ENABLE_THREADS=1" ]
} else { } else {
extra_args += [ "LLVM_ENABLE_THREADS=0" ] # Must be 0. extra_values += [ "LLVM_ENABLE_THREADS=0" ] # Must be 0.
} }
if (llvm_enable_zlib) { if (llvm_enable_zlib) {
extra_args += [ "HAVE_LIBZ=1" ] extra_values += [ "HAVE_LIBZ=1" ]
} else { } else {
extra_args += [ "HAVE_LIBZ=0" ] # Must be 0. extra_values += [ "HAVE_LIBZ=0" ] # Must be 0.
} }
} }
write_lit_config("lit_unit_site_cfg") { write_lit_config("lit_unit_site_cfg") {
input = "//llvm/test/Unit/lit.site.cfg.py.in" input = "//llvm/test/Unit/lit.site.cfg.py.in"
output = llvm_lit_unit_site_cfg_file output = llvm_lit_unit_site_cfg_file
extra_args = [ "LLVM_BUILD_MODE=." ] extra_values = [ "LLVM_BUILD_MODE=." ]
} }
# This target should contain all dependencies of check-llvm. # This target should contain all dependencies of check-llvm.

View File

@ -4,17 +4,12 @@ import("//llvm/utils/gn/build/libs/pthread/enable.gni")
import("//llvm/utils/gn/build/libs/terminfo/enable.gni") import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni") import("//llvm/utils/gn/build/libs/zlib/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
action("BuildVariables.inc") { write_cmake_config("BuildVariables.inc") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "BuildVariables.inc.in"
output = "$target_gen_dir/BuildVariables.inc"
sources = [
"BuildVariables.inc.in",
]
outputs = [
"$target_gen_dir/BuildVariables.inc",
]
if (is_debug) { if (is_debug) {
build_mode = "debug" build_mode = "debug"
@ -68,11 +63,7 @@ action("BuildVariables.inc") {
system_libs += " ${l}z${lib}" system_libs += " ${l}z${lib}"
} }
args = [ values = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LLVM_SRC_ROOT=" + rebase_path("//llvm"), "LLVM_SRC_ROOT=" + rebase_path("//llvm"),
"LLVM_OBJ_ROOT=" + rebase_path(root_out_dir), "LLVM_OBJ_ROOT=" + rebase_path(root_out_dir),

View File

@ -1,20 +1,15 @@
import("//clang/test/clang_lit_site_cfg_files.gni") import("//clang/test/clang_lit_site_cfg_files.gni")
import("//lld/test/lld_lit_site_cfg_files.gni") import("//lld/test/lld_lit_site_cfg_files.gni")
import("//llvm/test/llvm_lit_site_cfg_files.gni") import("//llvm/test/llvm_lit_site_cfg_files.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
action("llvm-lit") { write_cmake_config("llvm-lit") {
script = "//llvm/utils/gn/build/write_cmake_config.py" input = "llvm-lit.in"
output = "$root_out_dir/bin/llvm-lit"
sources = [
"llvm-lit.in",
]
outputs = [
"$root_out_dir/bin/llvm-lit",
]
if (host_os == "win") { if (host_os == "win") {
# llvm-lit needs suffix.py for multiprocess to find a main module. # llvm-lit needs suffix.py for multiprocess to find a main module.
outputs[0] = "${outputs[0]}.py" output = "${output}.py"
} }
# lit's lit/llvm/config.py shells out to llvm-config. # lit's lit/llvm/config.py shells out to llvm-config.
@ -51,11 +46,7 @@ action("llvm-lit") {
config_map += "map_config('" + rebase_path("//llvm/test/Unit/lit.cfg.py") + config_map += "map_config('" + rebase_path("//llvm/test/Unit/lit.cfg.py") +
"', '" + rebase_path(llvm_lit_unit_site_cfg_file) + "')\n" "', '" + rebase_path(llvm_lit_unit_site_cfg_file) + "')\n"
args = [ values = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"LLVM_SOURCE_DIR=" + rebase_path("//llvm"), "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
"LLVM_BINARY_DIR=" + "LLVM_BINARY_DIR=" +
rebase_path(get_label_info("//llvm", "target_out_dir")), rebase_path(get_label_info("//llvm", "target_out_dir")),