llvm.org GIT mirror llvm / 1f6df78
Use response file when generating LLVM-C.dll As discovered in D56774 the command line gets to long, so use a response file to give the script the libs. This change has been tested and is confirmed working for me. Commited on behalf of Jakob Bornecrantz. Differential Revision: https://reviews.llvm.org/D56781 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356443 91177308-0d34-0410-b5e6-96231b3b80d8 Serge Guelton 1 year, 7 months ago
4 changed file(s) with 48 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
569569 endif()
570570 option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF)
571571 if(MSVC)
572 option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" OFF)
572 option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON)
573573 else()
574574 option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF)
575575 endif()
131131 set(GEN_UNDERSCORE "")
132132 endif()
133133
134 # Set this name here, not used in multi conf loop,
135 # but add script will pick the right one.
136 set(LIBSFILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.args)
137
134138 # Get the full name to the libs so the python script understands them.
135139 foreach(lib ${LIB_NAMES})
136140 list(APPEND FULL_LIB_NAMES ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib)
137141 endforeach()
142
143 # Need to seperate lib names with newlines.
144 string(REPLACE ";" "\n" FILE_CONTENT "${FULL_LIB_NAMES}")
145
146 if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
147 foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
148 # Replace the special string with a per config directory.
149 string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} PER_CONF_CONTENT "${FILE_CONTENT}")
150
151 # Write out the full lib names into file to be read by the python script.
152 # One libsfile per build, the add_custom_command should expand
153 # ${CMAKE_CFG_INTDIR} correctly and select the right one.
154 file(WRITE ${CMAKE_BINARY_DIR}/${BUILD_MODE}/libllvm-c.args "${PER_CONF_CONTENT}")
155 endforeach()
156 else()
157 # Write out the full lib names into file to be read by the python script.
158 file(WRITE ${LIBSFILE} "${FILE_CONTENT}")
159 endif()
138160
139161 # Generate the exports file dynamically.
140162 set(GEN_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/gen-msvc-exports.py)
142164 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports)
143165
144166 add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}
145 COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} ${FULL_LIB_NAMES} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE}
167 COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE}
146168 DEPENDS ${LIB_NAMES} llvm-nm
147169 COMMENT "Generating export list for LLVM-C"
148170 VERBATIM )
8282 parser = argparse.ArgumentParser('gen-msvc-exports')
8383
8484 parser.add_argument(
85 '-i', '--libsfile', help='file with list of libs, new line separated',
86 action='store', default=None
87 )
88 parser.add_argument(
8589 '-o', '--output', help='output filename', default='LLVM-C.exports'
8690 )
8791 parser.add_argument('-u', '--underscore',
9296 '--nm', help='path to the llvm-nm executable', default='llvm-nm'
9397 )
9498 parser.add_argument(
95 'libs', metavar='LIBS', nargs='+', help='list of libraries to generate export from'
99 'libs', metavar='LIBS', nargs='*', help='list of libraries to generate export from'
96100 )
97101
98102 ns = parser.parse_args()
99103
100 gen_llvm_c_export(ns.output, ns.underscore, ns.libs, ns.nm)
104 libs = ns.libs
105
106 # Add if we where given a libsfile add it to the libs.
107 if ns.libsfile:
108 with open(ns.libsfile) as f:
109 libs.extend(f.read().splitlines())
110
111 gen_llvm_c_export(ns.output, ns.underscore, libs, ns.nm)
101112
102113
103114 if __name__ == '__main__':
5151
5252
5353 REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226.
54 set cmake_flags=-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DCMAKE_INSTALL_UCRT_LIBRARIES=ON -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% -DPACKAGE_VERSION=%package_version% -DLLDB_RELOCATABLE_PYTHON=1 -DLLDB_TEST_COMPILER=%cd%\build32_stage0\bin\clang.exe -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: "
54 set cmake_flags=^
55 -DCMAKE_BUILD_TYPE=Release ^
56 -DLLVM_ENABLE_ASSERTIONS=ON ^
57 -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON ^
58 -DLLVM_BUILD_LLVM_C_DYLIB=ON ^
59 -DCMAKE_INSTALL_UCRT_LIBRARIES=ON ^
60 -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% ^
61 -DPACKAGE_VERSION=%package_version% ^
62 -DLLDB_RELOCATABLE_PYTHON=1 ^
63 -DLLDB_TEST_COMPILER=%cd%\build32_stage0\bin\clang.exe ^
64 -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: "
5565
5666 REM TODO: Run the "check-all" tests.
5767