[llvm] 7ed0891 - [gn build] port f06abbb39380 a bit (create main() functions for GENERATE_DRIVER targets)
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 6 03:29:08 PDT 2022
Author: Nico Weber
Date: 2022-06-06T06:28:52-04:00
New Revision: 7ed089153c943bee62fe59549e96d57e52ec980a
URL: https://github.com/llvm/llvm-project/commit/7ed089153c943bee62fe59549e96d57e52ec980a
DIFF: https://github.com/llvm/llvm-project/commit/7ed089153c943bee62fe59549e96d57e52ec980a.diff
LOG: [gn build] port f06abbb39380 a bit (create main() functions for GENERATE_DRIVER targets)
Added:
llvm/utils/gn/build/driver_executable.gni
Modified:
llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/dsymutil/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/llvm-cxxfilt/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/llvm-objcopy/BUILD.gn
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/driver_executable.gni b/llvm/utils/gn/build/driver_executable.gni
new file mode 100644
index 0000000000000..f838cb8e5ad22
--- /dev/null
+++ b/llvm/utils/gn/build/driver_executable.gni
@@ -0,0 +1,23 @@
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+
+# Corresponds to GENERATE_DRIVER in cmake (see add_llvm_executable in
+# llvm/cmake/modules/AddLLVM.cmake).
+template("driver_executable") {
+ tool_name = string_replace(target_name, "-", "_")
+
+ write_cmake_config("${tool_name}-driver") {
+ input = "//llvm/cmake/driver-template.cpp.in"
+ output = "$target_gen_dir/${tool_name}-driver.cpp"
+ values = [ "TOOL_NAME=$tool_name" ]
+ }
+
+ executable(target_name) {
+ forward_variables_from(invoker, "*")
+ deps += [ ":${tool_name}-driver" ]
+ sources += [ "$target_gen_dir/${tool_name}-driver.cpp" ]
+ }
+}
+
+set_defaults("driver_executable") {
+ configs = shared_binary_target_configs
+}
diff --git a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
index f09d87c056136..8f7432161b4bb 100644
--- a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -1,3 +1,4 @@
+import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")
@@ -46,7 +47,7 @@ if (host_os == "mac") {
}
}
-executable("clang") {
+driver_executable("clang") {
configs += [ "//llvm/utils/gn/build:clang_code" ]
deps = [
"//clang/include/clang/Config",
diff --git a/llvm/utils/gn/secondary/llvm/tools/dsymutil/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/dsymutil/BUILD.gn
index 8e8902d47cbb4..9a94179c7d032 100644
--- a/llvm/utils/gn/secondary/llvm/tools/dsymutil/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/dsymutil/BUILD.gn
@@ -1,11 +1,12 @@
import("//llvm/utils/TableGen/tablegen.gni")
+import("//llvm/utils/gn/build/driver_executable.gni")
tablegen("Options") {
visibility = [ ":dsymutil" ]
args = [ "-gen-opt-parser-defs" ]
}
-executable("dsymutil") {
+driver_executable("dsymutil") {
deps = [
":Options",
"//llvm/lib/CodeGen/AsmPrinter",
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
index 9d4ae2cbf8a1d..61e57f6858b4b 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
@@ -1,4 +1,5 @@
import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
symlinks = [
@@ -29,7 +30,7 @@ group("symlinks") {
}
}
-executable("llvm-ar") {
+driver_executable("llvm-ar") {
deps = [
"//llvm/lib/IR",
"//llvm/lib/Object",
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-cxxfilt/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-cxxfilt/BUILD.gn
index 081f77d29dfac..77cf73e0704e2 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-cxxfilt/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-cxxfilt/BUILD.gn
@@ -1,5 +1,6 @@
import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
+import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
tablegen("Opts") {
@@ -23,7 +24,7 @@ group("symlinks") {
}
}
-executable("llvm-cxxfilt") {
+driver_executable("llvm-cxxfilt") {
deps = [
":Opts",
"//llvm/lib/Demangle",
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-objcopy/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-objcopy/BUILD.gn
index 01df0df335ab9..8f6353bd8bb04 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-objcopy/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-objcopy/BUILD.gn
@@ -1,6 +1,7 @@
import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
+import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
tablegen("BitcodeStripOpts") {
@@ -56,7 +57,7 @@ group("symlinks") {
}
}
-executable("llvm-objcopy") {
+driver_executable("llvm-objcopy") {
deps = [
":BitcodeStripOpts",
":InstallNameToolOpts",
More information about the llvm-commits
mailing list