precompile common headers to reduce build time for win builds. With this build time...
authorRahul Kumar <rahku@microsoft.com>
Mon, 9 Feb 2015 06:04:06 +0000 (22:04 -0800)
committerRahul Kumar <rahku@microsoft.com>
Mon, 9 Feb 2015 06:04:06 +0000 (22:04 -0800)
[tfs-changeset: 1412352]

32 files changed:
CMakeLists.txt
src/debug/daccess/CMakeLists.txt
src/debug/di/CMakeLists.txt
src/debug/ee/dac/CMakeLists.txt
src/debug/ee/wks/CMakeLists.txt
src/dlls/mscordbi/CMakeLists.txt
src/ipcman/ipcman-staticcrt/CMakeLists.txt
src/jit/CMakeLists.txt
src/md/ceefilegen/CMakeLists.txt
src/md/compiler/dac/CMakeLists.txt
src/md/compiler/dbi/CMakeLists.txt
src/md/compiler/wks/CMakeLists.txt
src/md/datasource/dbi/CMakeLists.txt
src/md/enc/dac/CMakeLists.txt
src/md/enc/dbi/CMakeLists.txt
src/md/enc/wks/CMakeLists.txt
src/md/hotdata/dac/CMakeLists.txt
src/md/hotdata/full-staticcrt/CMakeLists.txt
src/md/hotdata/full/CMakeLists.txt
src/md/runtime/dac/CMakeLists.txt
src/md/runtime/dbi/CMakeLists.txt
src/md/runtime/wks/CMakeLists.txt
src/md/winmd/dac/CMakeLists.txt
src/md/winmd/dbi/CMakeLists.txt
src/md/winmd/wks/CMakeLists.txt
src/utilcode/cycletimer.cpp
src/utilcode/dac/CMakeLists.txt
src/utilcode/dyncrt/CMakeLists.txt
src/utilcode/lazycow.cpp
src/utilcode/staticnohost/CMakeLists.txt
src/vm/dac/CMakeLists.txt
src/vm/wks/CMakeLists.txt

index 096cee3b81bb8085e27d0fb999f4c9375e540805..8a4da122206ae277b91fb2d55aefa455d3e579f4 100644 (file)
@@ -69,6 +69,20 @@ function(preprocess_def_file inputFilename outputFilename)
                               PROPERTIES GENERATED TRUE)
 endfunction()
 
+function(add_precompiled_header header cppFile targetSources)
+  if(MSVC)
+    set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/stdafx.pch")
+
+    set_source_files_properties(${cppFile}
+                                PROPERTIES COMPILE_FLAGS "/Yc\"${header}\" /Fp\"${precompiledBinary}\""
+                                           OBJECT_OUTPUTS "${precompiledBinary}")
+    set_source_files_properties(${${targetSources}}
+                                PROPERTIES COMPILE_FLAGS "/Yu\"${header}\" /Fp\"${precompiledBinary}\""
+                                           OBJECT_DEPENDS "${precompiledBinary}")  
+    # Add cppFile to SourcesVar
+    set(${targetSources} ${${targetSources}} ${cppFile} PARENT_SCOPE)
+  endif(MSVC)    
+endfunction()
 
 # Includes
 
index cdea53390c2e12873d7d6d1ddc1d9e9bc3d106fe..9851dc808867d2b4bd5655e874b0049d5cb23c47 100644 (file)
@@ -47,4 +47,6 @@ endif(IS_64BIT_BUILD EQUAL 1)
 
 convert_to_absolute_path(DACCESS_SOURCES ${DACCESS_SOURCES})
 
+add_precompiled_header(stdafx.h stdafx.cpp DACCESS_SOURCES)
+
 add_library(daccess ${DACCESS_SOURCES})
index ab8c4da592af6ded836b6f260c4211566d78bbbf..6546b699201a0ea5c0052a059d8eef68bf1dad32 100644 (file)
@@ -51,6 +51,6 @@ elseif(CLR_CMAKE_PLATFORM_UNIX)
 
 endif(WIN32)
 
-
+add_precompiled_header(stdafx.h stdafx.cpp CORDBDI_SOURCES)
 
 add_library(cordbdi STATIC ${CORDBDI_SOURCES})
\ No newline at end of file
index 9a48058b83b61c296e9f1d58ea412c484197b191..c60a5f8a0855b62486a4ad69e4284042c8b26790 100644 (file)
@@ -1,4 +1,6 @@
 
 include(${CLR_DIR}/dac.cmake)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp CORDBEE_SOURCES_DAC)
+
 add_library(cordbee_dac ${CORDBEE_SOURCES_DAC})
index 13c575d5592cfa4b61adbcaa1f5d9fcaadb5ba96..9438b00b5391171577fd620d811f402fb80dc6bf 100644 (file)
@@ -1,6 +1,8 @@
 
 if (WIN32)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp CORDBEE_SOURCES_WKS)
+
 if (IS_64BIT_BUILD EQUAL 1)
   FIND_PROGRAM(ASM_COMPILER ml64.exe)
 else ()
index 627da375245935d3d2d5c0acb051e2bb572c2740..5d1cf42e507436011c3f005aadf4bfc992c41b5c 100644 (file)
@@ -3,6 +3,8 @@ set(MSCORDBI_SOURCES
 )  
 
 if(WIN32)
+    add_precompiled_header(stdafx.h stdafx.cpp MSCORDBI_SOURCES)
+    
     add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll)
 
     list(APPEND MSCORDBI_SOURCES
index 01c155c7ad2a0f7fe38bd31023f1f91f6489a189..91590bb0bb77d50d0f3cd82050537e1520dc0e85 100644 (file)
@@ -1,2 +1,3 @@
 add_definitions(-D_CRTIMP=) #static link of crt
+add_precompiled_header(stdafx.h ../stdafx.cpp IPCMAN_SOURCES)
 add_library(ipcmanager-staticcrt STATIC ${IPCMAN_SOURCES})
\ No newline at end of file
index 59d66bd216cfdeaa7cc791acca9ddad2e2d15bd2..35dcf861817b0a9a628aecc7d0e4cb8e9dcf5f7d 100644 (file)
@@ -65,6 +65,9 @@ set( SOURCES
 )
 
 if( WIN32 )
+
+  add_precompiled_header(jitpch.h jitpch.cpp SOURCES)
+
   # Create .def file containing a list of exports preceeded by
   # 'EXPORTS'.  The file "ClrJit.exports" already contains the list, so we
   # massage it into the correct format here to create "ClrJit.exports.def".
index 2df705540006905d0d4d55bca3df5787e7da02bf..146c6a02c3ffe4c22769c6408d7822e90663781a 100644 (file)
@@ -15,6 +15,8 @@ if(CLR_CMAKE_PLATFORM_UNIX)
     add_compile_options(-fPIC)
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
+add_precompiled_header(stdafx.h stdafx.cpp CEEFILEGEN_SOURCES)
+
 add_library(ceefgen
     STATIC
     ${CEEFILEGEN_SOURCES}
index efc424b572fc8c0f62eef5580c3433f5d0b3d39b..a73f7b0459a729387339752ab51e35433f1ba8c5 100644 (file)
@@ -2,4 +2,5 @@
 include(${CLR_DIR}/dac.cmake)
 include(../../md_dac.cmake)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
 add_library(mdcompiler_dac ${MDCOMPILER_SOURCES})
index 4244eec4e7c570fffc53b02e2f3d7f93b4b15a6a..e60d67767bbc3061fa28b4fbbc75b1429ac2db0b 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_dbi.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
 add_library(mdcompiler-dbi ${MDCOMPILER_SOURCES})
\ No newline at end of file
index a004ed9df919bd4b126538673b1d33b73c7a0201..7eb09e7524cde63f60b8a84ed61589ed03fc55cd 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_wks.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
 add_library(mdcompiler_wks ${MDCOMPILER_SOURCES})
\ No newline at end of file
index 248335b8e94fbd44e6556a48b615ce6ae7eda11d..c509c194100f6f5990d045f7808b670a49610f38 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_dbi.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDDATASOURCE_SOURCES)
 add_library(mddatasource_dbi STATIC ${MDDATASOURCE_SOURCES})
\ No newline at end of file
index b651fc28accb0da3fb64b76631a4980d8913e037..90f7e786b6e387f58cea0c48f75b762be4c4b3a8 100644 (file)
@@ -2,4 +2,5 @@
 include(${CLR_DIR}/dac.cmake)
 include(../../md_dac.cmake)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
 add_library(mdruntimerw_dac ${MDRUNTIMERW_SOURCES})
index 7898bfafdd1a2e13ab39fe62f6eb0f88cccbda24..6cd97dd5bde6014ae9b85fb213fe88fc411f51ca 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_dbi.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
 add_library(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES})
\ No newline at end of file
index e31d8ec05605c8eaa52aad780ed523afc37403a4..5b596ed7fa37a998345dba1bb99ad3773809deb9 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_wks.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
 add_library(mdruntimerw_wks ${MDRUNTIMERW_SOURCES})
index 9f37472641422623c643871c465b9ef4e32e845e..02519679d32a32abd06cc24997ae71e1847ee740 100644 (file)
@@ -1,4 +1,6 @@
 
 include(${CLR_DIR}/dac.cmake)
 
+add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
+
 add_library(mdhotdata_dac ${MDHOTDATA_SOURCES})
index dd7488f76882880b5d5c58b5cfb8d4358c8d1aad..3d796a23c0f041a70f62825b0ef534dcb12ff7d8 100644 (file)
@@ -1,2 +1,4 @@
 add_definitions(-D_CRTIMP=) # static link of crt
+
+add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
 add_library(mdhotdata-staticcrt ${MDHOTDATA_SOURCES})
index 688dfbee9a0426251680d9efce09f65d3883f4b6..15448b182accbb2227b2ee80d1e38f346a12efdd 100644 (file)
@@ -1 +1,3 @@
+add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
+
 add_library(mdhotdata_full ${MDHOTDATA_SOURCES})
index 620bc5bbc58d2af32b24e7f9b26b16bb2f29ae22..63ce26a1e91a2447259717f6d188d6d1a00c3029 100644 (file)
@@ -2,4 +2,6 @@
 include(${CLR_DIR}/dac.cmake)
 include(../../md_dac.cmake)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
+
 add_library(mdruntime_dac ${MDRUNTIME_SOURCES})
\ No newline at end of file
index 5276477f1cc8e12fec2948cccce53c87068ebec9..2cc8420c272ee25c07ade470517e6b5c2347a8a0 100644 (file)
@@ -1,2 +1,3 @@
 include(../../md_dbi.cmake)
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
 add_library(mdruntime-dbi ${MDRUNTIME_SOURCES})
\ No newline at end of file
index bbb718d98eee3d81adc880b90fc2c2429b218254..4822219c8c4f46bd1bba90008b0e64f405ed2d73 100644 (file)
@@ -1,3 +1,5 @@
 include(../../md_wks.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
 add_library(mdruntime_wks ${MDRUNTIME_SOURCES})
 
index 44806103c6442408477fe73e5476dcaf3fa79a9f..31e6bb0debde3222d071d537febcfd224b8ab901 100644 (file)
@@ -2,4 +2,5 @@
 include(${CLR_DIR}/dac.cmake)
 include(../../md_dbi.cmake)
 
+add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
 add_library(mdwinmd_dac ${MDWINMD_SOURCES})
index 12a06e29e1f4f9d48056015c5fb95a2307749838..707b6b4c748fd96c184623413e8c403079b02d83 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_dbi.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
 add_library(mdwinmd_dbi ${MDWINMD_SOURCES})
\ No newline at end of file
index 226dfb31cf7407718a25678f4510a981c2e86d8c..67b1f686f5ca40a45b631039036b844a6c6e3603 100644 (file)
@@ -1,2 +1,4 @@
 include(../../md_wks.cmake)
+
+add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
 add_library(mdwinmd_wks ${MDWINMD_SOURCES})
\ No newline at end of file
index 3410669738614be619b446a5a9e64df024aa280a..18b400d82caa40a04d33f8e02c5f864ce3588bf7 100644 (file)
@@ -3,6 +3,7 @@
 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
+#include "stdafx.h"
 
 #include "cycletimer.h"
 #include "winbase.h"
index ff6c48581a2389168ef9f0ae9f645f23b070014a..1a5d40b3c49ec672bde27f64bac2c3c9e7d5d076 100644 (file)
@@ -6,5 +6,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
     add_dependencies(utilcode_dac CoreClrPal)
 else()
     add_definitions(-DSELF_NO_HOST)
-    add_library(utilcode_dac STATIC ${UTILCODE_SOURCES} ../hostimpl.cpp)
+    list(APPEND UTILCODE_SOURCES ../hostimpl.cpp)
+    add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_SOURCES)
+    add_library(utilcode_dac STATIC ${UTILCODE_SOURCES})
 endif(CLR_CMAKE_PLATFORM_UNIX)
\ No newline at end of file
index 36f2ef487283afafe2e19cd167d42f5d1e1caeda..be2e2cca3895eb0f30f607223f0d8c5171ab3222 100644 (file)
@@ -3,5 +3,6 @@ if(CLR_CMAKE_PLATFORM_UNIX)
     add_library(utilcode STATIC ${UTILCODE_SOURCES})
     add_dependencies(utilcode CoreClrPal)
 else()
+    add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_SOURCES)
     add_library(utilcode STATIC ${UTILCODE_SOURCES})
 endif(CLR_CMAKE_PLATFORM_UNIX)
\ No newline at end of file
index 9a5fcfbf1c23485b31640e8c41eb96ed1542f7b8..6411ac41324bb2d79969f2a03c27b3184a456335 100644 (file)
@@ -6,6 +6,8 @@
 // LazyCOW.cpp
 //
 
+#include "stdafx.h"
+
 #include "pedecoder.h"
 #include "volatile.h"
 #include "lazycow.h"
index 254ada1ff92273909826b32659911771bdd8582e..ea662454f7789327f67d0b083f7f6aa7939b804f 100644 (file)
@@ -4,7 +4,7 @@ if(WIN32)
      add_definitions(-D_CRTIMP=) # use static version of crt
 
      list(APPEND UTILCODE_SOURCES ../hostimpl.cpp)
-
+     add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_SOURCES)
      add_library(utilcodestaticnohost STATIC ${UTILCODE_SOURCES})
 elseif(CLR_CMAKE_PLATFORM_UNIX)
      add_library(utilcodestaticnohost STATIC ${UTILCODE_SOURCES})
index 987b3f569581b20342353f4d9a282590b5a6625e..0b69d7efc04118473eb2a05529b75ff52f2f2e8b 100644 (file)
@@ -1,4 +1,5 @@
 
 include(${CLR_DIR}/dac.cmake)
 
+add_precompiled_header(common.h ../common.cpp VM_SOURCES_DAC)
 add_library(cee_dac ${VM_SOURCES_DAC})
\ No newline at end of file
index 49d45ccc2f9538a1d19607607322e63fc8aecc28..573ec6f0fb327551aaf6ba8dc81d2a4272389a65 100644 (file)
@@ -1,7 +1,14 @@
+if (WIN32)
+  add_precompiled_header(common.h ../common.cpp VM_SOURCES_WKS)
+  # mscorlib.cpp does not compile with precompiled header file
+  set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-") 
+  # .c file cannot use cpp precompiled header 
+  set_source_files_properties(../microsoft.comservices_i.c PROPERTIES COMPILE_FLAGS "/Y-") 
+endif (WIN32)
+
 add_library(cee_wks ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_AMD64_ASM})
 
 if (WIN32)
-
 # Get the current list of definitions
 get_compile_definitions(DEFINITIONS)