[llvm] dbb0d8e - Don't use relpaths in lit cfg if build/source dir are on different drives.

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 12:44:04 PDT 2020


Author: Andrew Ng
Date: 2020-04-03T15:43:50-04:00
New Revision: dbb0d8ecb3a024bd6817ebd8ad8c5c199a51d933

URL: https://github.com/llvm/llvm-project/commit/dbb0d8ecb3a024bd6817ebd8ad8c5c199a51d933
DIFF: https://github.com/llvm/llvm-project/commit/dbb0d8ecb3a024bd6817ebd8ad8c5c199a51d933.diff

LOG: Don't use relpaths in lit cfg if build/source dir are on different drives.

See discussion on https://reviews.llvm.org/D77184.

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 91bec7d80813..8be19b12ed4f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1494,8 +1494,14 @@ function(configure_lit_site_cfg site_in site_out)
     # outselves. cmake has no relpath function, so use Python for that.
     string(REPLACE ";" "\\;" ARG_PATH_VALUES_ESCAPED "${ARG_PATH_VALUES}")
     get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY)
-    execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
-      "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, sys.argv[1]).replace(os.sep, '/') if p else '' for p in sys.argv[2].split(';')))"
+    execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "\n
+import os, sys\n
+drive = os.path.splitdrive(sys.argv[1])[0]\n
+def relpath(p):\n
+    if not p: return ''\n
+    if os.path.splitdrive(p)[0] != drive: return p\n
+    return os.path.relpath(p, sys.argv[1]).replace(os.sep, '/')\n
+sys.stdout.write(';'.join(relpath(p) for p in sys.argv[2].split(';')))"
       ${OUTPUT_DIR}
       ${ARG_PATH_VALUES_ESCAPED}
       OUTPUT_VARIABLE ARG_PATH_VALUES_RELATIVE)


        


More information about the llvm-commits mailing list