Teach llvm-build to avoid touching LibraryDependencies.inc unless the contents
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 19 Nov 2014 03:34:20 +0000 (03:34 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 19 Nov 2014 03:34:20 +0000 (03:34 +0000)
change. This saves us from rebuilding llvm-config each time we reconfigure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222308 91177308-0d34-0410-b5e6-96231b3b80d8

utils/llvm-build/llvmbuild/main.py

index 36c7d53..353741f 100644 (file)
@@ -1,4 +1,5 @@
 from __future__ import absolute_import
 from __future__ import absolute_import
+import filecmp
 import os
 import sys
 
 import os
 import sys
 
@@ -382,7 +383,7 @@ subdirectories = %s
 
         # Write out the library table.
         make_install_dir(os.path.dirname(output_path))
 
         # Write out the library table.
         make_install_dir(os.path.dirname(output_path))
-        f = open(output_path, 'w')
+        f = open(output_path+'.new', 'w')
         f.write("""\
 //===- llvm-build generated file --------------------------------*- C++ -*-===//
 //
         f.write("""\
 //===- llvm-build generated file --------------------------------*- C++ -*-===//
 //
@@ -420,6 +421,14 @@ subdirectories = %s
         f.write('};\n')
         f.close()
 
         f.write('};\n')
         f.close()
 
+        if not os.path.isfile(output_path):
+            os.rename(output_path+'.new', output_path)
+        elif filecmp.cmp(output_path, output_path+'.new'):
+            os.remove(output_path+'.new')
+        else:
+            os.remove(output_path)
+            os.rename(output_path+'.new', output_path)
+
     def get_required_libraries_for_component(self, ci, traverse_groups = False):
         """
         get_required_libraries_for_component(component_info) -> iter
     def get_required_libraries_for_component(self, ci, traverse_groups = False):
         """
         get_required_libraries_for_component(component_info) -> iter