[PATCH] D35377: [CMAKE] Speedup developer builds when passing LLVM_APPEND_VC_REV = OFF

don hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 15:55:23 PDT 2017


hintonda updated this revision to Diff 107196.
hintonda added a comment.

Only add custom commands if LLVM_APPEND_VC_REV = ON -- minimize diff.


https://reviews.llvm.org/D35377

Files:
  include/llvm/Support/CMakeLists.txt


Index: include/llvm/Support/CMakeLists.txt
===================================================================
--- include/llvm/Support/CMakeLists.txt
+++ include/llvm/Support/CMakeLists.txt
@@ -9,7 +9,6 @@
 endfunction()
 
 macro(find_first_existing_vc_file out_var path)
-  if ( LLVM_APPEND_VC_REV )
     find_program(git_executable NAMES git git.exe git.cmd)
     # Run from a subdirectory to force git to print an absolute path.
     execute_process(COMMAND ${git_executable} rev-parse --git-dir
@@ -30,7 +29,6 @@
         "${path}/.svn/entries" # SVN 1.6
       )
     endif()
-  endif()
 endmacro()
 
 find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
@@ -40,22 +38,29 @@
 
 set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake")
 
-if(DEFINED llvm_vc)
+if((DEFINED llvm_vc) AND LLVM_APPEND_VC_REV)
+  add_custom_command(OUTPUT force_version_inc_check COMMAND ${CMAKE_COMMAND} -E echo_append)
+
   # Create custom target to generate the VC revision include.
   add_custom_command(OUTPUT "${version_inc}"
-    DEPENDS "${llvm_vc}" "${get_svn_script}"
+    DEPENDS force_version_inc_check "${llvm_vc}" "${get_svn_script}"
     COMMAND
     ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
                      "-DNAME=LLVM_REVISION"
                      "-DHEADER_FILE=${version_inc}"
                      -P "${get_svn_script}")
-
-  # Mark the generated header as being generated.
-  set_source_files_properties("${version_inc}"
-    PROPERTIES GENERATED TRUE
-               HEADER_FILE_ONLY TRUE)
 else()
-  file(WRITE "${version_inc}" "")
+  # Ensure ${version_inc} is an empty file.
+  file(WRITE "${version_inc}.txt" "")
+  # Copy the file only if it has changed.
+  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    "${version_inc}.txt" "${version_inc}")
+  file(REMOVE "${version_inc}.txt")
 endif()
 
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+  PROPERTIES GENERATED TRUE
+             HEADER_FILE_ONLY TRUE)
+
 add_custom_target(llvm_vcsrevision_h DEPENDS "${version_inc}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35377.107196.patch
Type: text/x-patch
Size: 2091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170718/5f986289/attachment.bin>


More information about the llvm-commits mailing list