[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

Pushpinder Singh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 05:54:51 PDT 2020


pdhaliwal updated this revision to Diff 266172.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79400/new/

https://reviews.llvm.org/D79400

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1937,7 +1937,13 @@
         get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
         # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD
         if (NOT EXISTS "${git_dir}/logs/HEAD")
-          file(WRITE "${git_dir}/logs/HEAD" "")
+          execute_process(COMMAND ${CMAKE_COMMAND} -E touch HEAD
+            WORKING_DIRECTORY "${git_dir}/logs"
+            RESULT_VARIABLE touch_head_result
+            ERROR_QUIET)
+          if (NOT touch_head_result EQUAL 0)
+            return()
+          endif()
         endif()
         set(${out_var} "${git_dir}/logs/HEAD" PARENT_SCOPE)
       endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79400.266172.patch
Type: text/x-patch
Size: 830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200526/53faff30/attachment.bin>


More information about the llvm-commits mailing list