[PATCH] Only modify lto.exports.def when contents have changed

Greg Bedwell greg_bedwell at sn.scee.net
Thu Oct 3 23:51:41 PDT 2013


gbedwell added you to the CC list for the revision "Only modify lto.exports.def when contents have changed".

Previously, for Win32 builds we were regenerating the lto.exports.def file every time that CMake was run regardless or not of whether the file contents had changed.  This was forcing LTO.dll to be rebuilt each time that CMake was run even if there were no other differences.  This patch writes an intermediate file which is compared to the actual file (if it already exists).  If there is any difference, the intermediate file is copied in place of the actual file, otherwise the actual file is left unmodified.  This is the same technique used in GetSVN.cmake for the generated version header file.

If this looks okay, please could you commit for me?

Thanks,

Greg Bedwell
SN Systems - Sony Computer Entertainment Group

http://llvm-reviews.chandlerc.com/D1832

Files:
  tools/lto/CMakeLists.txt

Index: tools/lto/CMakeLists.txt
===================================================================
--- tools/lto/CMakeLists.txt
+++ tools/lto/CMakeLists.txt
@@ -15,10 +15,16 @@
     # 'EXPORTS'.  The file "lto.exports" already contains the list, so we
     # massage it into the correct format here to create "lto.exports.def".
     set(LTO_EXPORTS_DEF ${CMAKE_CURRENT_BINARY_DIR}/lto.exports.def)
+    set(LTO_EXPORTS_DEF_TEMP ${LTO_EXPORTS_DEF}.txt)
     file(READ "lto.exports" exports_list)
-    file(WRITE ${LTO_EXPORTS_DEF} "LIBRARY LTO\n")
-    file(APPEND ${LTO_EXPORTS_DEF} "EXPORTS\n")
-    file(APPEND ${LTO_EXPORTS_DEF} ${exports_list})
+    file(WRITE ${LTO_EXPORTS_DEF_TEMP} "LIBRARY LTO\n")
+    file(APPEND ${LTO_EXPORTS_DEF_TEMP} "EXPORTS\n")
+    file(APPEND ${LTO_EXPORTS_DEF_TEMP} ${exports_list})
+
+    # Copy the file only if it has changed.
+    execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+      ${LTO_EXPORTS_DEF_TEMP} ${LTO_EXPORTS_DEF})
+
     set(SHARED_LIB_SOURCES ${SOURCES} ${LTO_EXPORTS_DEF})
   else()
     set(SHARED_LIB_SOURCES ${SOURCES})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1832.1.patch
Type: text/x-patch
Size: 1095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131003/4f372785/attachment.bin>


More information about the llvm-commits mailing list