Index: tools/llvm-shlib/CMakeLists.txt =================================================================== --- tools/llvm-shlib/CMakeLists.txt +++ tools/llvm-shlib/CMakeLists.txt @@ -133,17 +133,23 @@ endif() # Get the full name to the libs so the python script understands them. + # Also appends a newline to them for writing into a file. foreach(lib ${LIB_NAMES}) - list(APPEND FULL_LIB_NAMES ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib) + list(APPEND FULL_LIB_NAMES ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib\n) endforeach() + # Write out the full lib names into file to be read by the python script. + # The full lib names strings has a new line in them. + set(LIBSFILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.args) + file(WRITE ${FULL_LIB_NAMES}) + # Generate the exports file dynamically. set(GEN_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/gen-msvc-exports.py) set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE} - COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} ${FULL_LIB_NAMES} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE} + COMMAND ${PYTHON_EXECUTABLE} ${GEN_SCRIPT} --libsfile ${LIBSFILE} ${GEN_UNDERSCORE} --nm ${LLVM_TOOLS_BINARY_DIR}/llvm-nm -o ${LLVM_EXPORTED_SYMBOL_FILE} DEPENDS ${LIB_NAMES} llvm-nm COMMENT "Generating export list for LLVM-C" VERBATIM ) Index: tools/llvm-shlib/gen-msvc-exports.py =================================================================== --- tools/llvm-shlib/gen-msvc-exports.py +++ tools/llvm-shlib/gen-msvc-exports.py @@ -83,6 +83,10 @@ def main(): parser = argparse.ArgumentParser('gen-msvc-exports') + parser.add_argument( + '-i', '--libsfile', help='file with list of libs, new line separated', + action='store', default=None + ) parser.add_argument( '-o', '--output', help='output filename', default='LLVM-C.exports' ) @@ -99,7 +103,13 @@ ns = parser.parse_args() - gen_llvm_c_export(ns.output, ns.underscore, ns.libs, ns.nm) + libs = ns.libs + # Replace given libs if a libsfile was given + if (ns.libsfile): + with open(ns.libsfile) as f: + libs = f.read().splitLines() + + gen_llvm_c_export(ns.output, ns.underscore, libs, ns.nm) if __name__ == '__main__':