[CMake] add_llvm_symbol_exports: Use Python oneliner instead of "cmd.exe /c type...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 5 Jul 2015 08:56:38 +0000 (08:56 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 5 Jul 2015 08:56:38 +0000 (08:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241402 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake

index 4f60d9e6e7d675c48daae9f5fb945fc2c70dfae1..752d496f74f6f0cf82d020fe9a58dc076d085f98 100644 (file)
@@ -93,20 +93,9 @@ function(add_llvm_symbol_exports target_name export_file)
   else()
     set(native_export_file "${target_name}.def")
 
   else()
     set(native_export_file "${target_name}.def")
 
-    set(CAT "cat")
-    set(export_file_nativeslashes ${export_file})
-    if(WIN32 AND NOT CYGWIN AND NOT MSYS)
-      set(CAT "type")
-      # Convert ${export_file} to native format (backslashes) for "type"
-      # Does not use file(TO_NATIVE_PATH) as it doesn't create a native
-      # path but a build-system specific format (see CMake bug
-      # http://public.kitware.com/Bug/print_bug_page.php?bug_id=5939 )
-      string(REPLACE / \\ export_file_nativeslashes ${export_file})
-    endif()
-
     add_custom_command(OUTPUT ${native_export_file}
     add_custom_command(OUTPUT ${native_export_file}
-      COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > ${native_export_file}
-      COMMAND ${CAT} ${export_file_nativeslashes} >> ${native_export_file}
+      COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
+        < ${export_file} > ${native_export_file}
       DEPENDS ${export_file}
       VERBATIM
       COMMENT "Creating export file for ${target_name}")
       DEPENDS ${export_file}
       VERBATIM
       COMMENT "Creating export file for ${target_name}")