[llvm-driver][NFC] Simplify handling of tool symlinks

Differential Revision: https://reviews.llvm.org/D134979
This commit is contained in:
Alex Brachet 2022-10-01 20:18:49 +00:00
parent 34fa860048
commit aa1c58b9c6
3 changed files with 11 additions and 14 deletions

View File

@ -182,7 +182,7 @@ endmacro()
macro(add_clang_symlink name dest)
get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} ${name})
else()
llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE)
# Always generate install targets

View File

@ -916,6 +916,7 @@ macro(generate_llvm_objects name)
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}")
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOLS ${name})
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${name} ${name})
target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
endif()
@ -2032,7 +2033,6 @@ endfunction()
function(llvm_install_symlink project name dest)
get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
return()
endif()
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
@ -2079,11 +2079,7 @@ function(llvm_add_tool_symlink project link_name target)
get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
if (${target} IN_LIST LLVM_DRIVER_TOOLS)
string(REPLACE "-" "_" tool_entry ${target})
string(REPLACE "-" "_" key ${link_name})
string(REPLACE "llvm-" "" tool_name ${link_name})
set_property(GLOBAL APPEND_STRING PROPERTY
LLVM_EXTRA_DRIVER_ENTRIES "LLVM_DRIVER_TOOL(\"${tool_name}\", ${tool_entry})\n")
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${target} ${link_name})
endif()
set(dest_binary "$<TARGET_FILE:${target}>")

View File

@ -5,15 +5,17 @@ get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
foreach(tool ${LLVM_DRIVER_TOOLS})
string(REPLACE "-" "_" tool_entry ${tool})
string(REPLACE "llvm-" "" tool ${tool})
set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
get_property(tool_aliases GLOBAL PROPERTY LLVM_DRIVER_TOOL_ALIASES_${tool})
foreach(alias ${tool_aliases})
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${alias})
string(REPLACE "llvm-" "" alias ${alias})
set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
endforeach()
endforeach()
get_property(LLVM_EXTRA_DRIVER_ENTRIES GLOBAL PROPERTY LLVM_EXTRA_DRIVER_ENTRIES)
file(WRITE
"${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
"${def_decl}${LLVM_EXTRA_DRIVER_ENTRIES}#undef LLVM_DRIVER_TOOL\n")
"${def_decl}#undef LLVM_DRIVER_TOOL\n")
target_include_directories(llvm-driver PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_sources(llvm-driver PRIVATE llvm-driver.cpp)
@ -28,9 +30,8 @@ if(APPLE)
endif(APPLE)
macro(generate_driver_tool_targets)
get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY LLVM_DRIVER_TOOL_SYMLINKS)
foreach(name IN LISTS LLVM_DRIVER_TOOLS LLVM_DRIVER_TOOL_SYMLINKS)
foreach(name ${LLVM_DRIVER_TOOL_SYMLINKS})
add_llvm_tool_symlink(${name} llvm-driver ALWAYS_GENERATE)
# Always generate install targets
llvm_install_symlink(LLVM ${name} llvm-driver ALWAYS_GENERATE)