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 096cee3..8a4da12 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 cdea533..9851dc8 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 ab8c4da..6546b69 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 9a48058..c60a5f8 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 13c575d..9438b00 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 627da37..5d1cf42 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 01c155c..91590bb 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 59d66bd..35dcf86 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 2df7055..146c6a0 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 efc424b..a73f7b0 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 4244eec..e60d677 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 a004ed9..7eb09e7 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 248335b..c509c19 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 b651fc2..90f7e78 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 7898bfa..6cd97dd 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 e31d8ec..5b596ed 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 9f37472..0251967 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 dd7488f..3d796a2 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 688dfbe..15448b1 100644 (file)
@@ -1 +1,3 @@
+add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
+
 add_library(mdhotdata_full ${MDHOTDATA_SOURCES})
index 620bc5b..63ce26a 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 5276477..2cc8420 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 bbb718d..4822219 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 4480610..31e6bb0 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 12a06e2..707b6b4 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 226dfb3..67b1f68 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 3410669..18b400d 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 ff6c485..1a5d40b 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 36f2ef4..be2e2cc 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 9a5fcfb..6411ac4 100644 (file)
@@ -6,6 +6,8 @@
 // LazyCOW.cpp
 //
 
+#include "stdafx.h"
+
 #include "pedecoder.h"
 #include "volatile.h"
 #include "lazycow.h"
index 254ada1..ea66245 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 987b3f5..0b69d7e 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 49d45cc..573ec6f 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)