[gn build] add llvm_install_cctools_symlinks arg

It behaves (mostly) like the LLVM_INSTALL_CCTOOLS_SYMLINKS option
in cmake.

The minor difference is that the llvm-objcopy symlinks bitcode_strip
and install_name_tool symlink to llvm-objcopy directly in the GN build,
while it's a bitcode_strip -> llvm-bitcode-strip -> objcopy chain
in the CMake build (and analogous for install_name_tool).

The implementation is very similar to the implementation of the
existing llvm_install_binutils_symlinks arg.

Differential Revision: https://reviews.llvm.org/D122312
This commit is contained in:
Nico Weber 2022-03-23 09:32:49 -04:00
parent f9889dd28a
commit 69cde915e9
7 changed files with 57 additions and 3 deletions

View File

@ -78,6 +78,12 @@ group("llvm-cxxfilt") {
group("llvm-debuginfod-find") {
deps = [ "//llvm/tools/llvm-debuginfod-find:symlinks" ]
}
group("llvm-libtool-darwin") {
deps = [ "//llvm/tools/llvm-libtool-darwin:symlinks" ]
}
group("llvm-lipo") {
deps = [ "//llvm/tools/llvm-lipo:symlinks" ]
}
group("llvm-objcopy") {
deps = [ "//llvm/tools/llvm-objcopy:symlinks" ]
}

View File

@ -101,7 +101,7 @@ group("test") {
"//llvm/tools/llvm-cvtres",
"//llvm/tools/llvm-dis",
"//llvm/tools/llvm-dwarfdump",
"//llvm/tools/llvm-lipo",
"//llvm/tools/llvm-lipo:symlinks",
"//llvm/tools/llvm-mc",
"//llvm/tools/llvm-nm:symlinks",
"//llvm/tools/llvm-objcopy:symlinks",

View File

@ -265,9 +265,9 @@ group("test") {
"//llvm/tools/llvm-isel-fuzzer",
"//llvm/tools/llvm-jitlink",
"//llvm/tools/llvm-jitlink/llvm-jitlink-executor",
"//llvm/tools/llvm-libtool-darwin",
"//llvm/tools/llvm-libtool-darwin:symlinks",
"//llvm/tools/llvm-link",
"//llvm/tools/llvm-lipo",
"//llvm/tools/llvm-lipo:symlinks",
"//llvm/tools/llvm-lto",
"//llvm/tools/llvm-lto2",
"//llvm/tools/llvm-mc",

View File

@ -0,0 +1,5 @@
declare_args() {
# If set, creates symlinks for cctools like libtool or lipo in the build
# directory.
llvm_install_cctools_symlinks = false
}

View File

@ -1,3 +1,22 @@
import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
if (llvm_install_cctools_symlinks) {
symlink_or_copy("libtool") {
deps = [ ":llvm-libtool-darwin" ]
source = "llvm-libtool-darwin"
output = "$root_out_dir/bin/libtool"
}
}
# //:llvm-libtool-darwin depends on this symlink target, see comment in
# //BUILD.gn.
group("symlinks") {
if (llvm_install_cctools_symlinks) {
deps = [ ":libtool" ]
}
}
executable("llvm-libtool-darwin") {
deps = [
"//llvm/lib/Object",

View File

@ -1,10 +1,27 @@
import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
tablegen("LipoOpts") {
visibility = [ ":llvm-lipo" ]
args = [ "-gen-opt-parser-defs" ]
}
if (llvm_install_cctools_symlinks) {
symlink_or_copy("lipo") {
deps = [ ":llvm-lipo" ]
source = "llvm-lipo"
output = "$root_out_dir/bin/lipo"
}
}
# //:llvm-lipo depends on this symlink target, see comment in //BUILD.gn.
group("symlinks") {
if (llvm_install_cctools_symlinks) {
deps = [ ":lipo" ]
}
}
executable("llvm-lipo") {
deps = [
":LipoOpts",

View File

@ -1,4 +1,5 @@
import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")
@ -33,6 +34,12 @@ if (llvm_install_binutils_symlinks) {
"strip",
]
}
if (llvm_install_cctools_symlinks) {
symlinks += [
"bitcode_strip",
"install_name_tool",
]
}
foreach(target, symlinks) {
symlink_or_copy(target) {
deps = [ ":llvm-objcopy" ]