Browse Source

Enhance the rake make task to also support Ninja.

Yao Wei Tjong 姚伟忠 10 năm trước cách đây
mục cha
commit
b285bd2325
2 tập tin đã thay đổi với 10 bổ sung3 xóa
  1. 2 0
      CMake/Modules/Urho3D-CMake-common.cmake
  2. 8 3
      Rakefile

+ 2 - 0
CMake/Modules/Urho3D-CMake-common.cmake

@@ -676,6 +676,8 @@ macro (enable_pch HEADER_PATHNAME)
             if (CMAKE_GENERATOR STREQUAL Ninja)
                 # The precompiled header is always generated in the current binary dir,
                 # but Ninja project is not able to find it without adding the binary dir to the include search path
+                # FIXME: below quick fix may have negatively impacted ccache from perfoming correctly in Ninja
+                #        ccache increases the 'preprocessor error' stat count and fallbacks to perform the actual compilation which slows down the build unnecessarily
                 list (APPEND INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
             endif ()
         endif ()

+ 8 - 3
Rakefile

@@ -117,7 +117,8 @@ task :make do
     end
   }
   build_tree = ENV["#{platform}_build_tree"] || ENV['build_tree'] || "../#{platform}-Build"
-  ccache_envvar = ''
+  ccache_envvar = ENV['CCACHE_SLOPPINESS'] ? '' : 'CCACHE_SLOPPINESS=pch_defines,time_macros'   # Only attempt to do the right thing when user hasn't done it
+  ccache_envvar = "#{ccache_envvar} CCACHE_COMPRESS=1" unless ENV['CCACHE_COMPRESS']
   if !Dir.glob("#{build_tree}/*.xcodeproj").empty?
     # xcodebuild
     if !numjobs.empty?
@@ -127,12 +128,16 @@ task :make do
   elsif !Dir.glob("#{build_tree}/*.sln").empty?
     # msbuild
     numjobs = ":#{numjobs}" unless numjobs.empty?
+    ccache_envvar = ''    # Extra env var is harmless even when ccache is not in use, well, except on Windows host system
     build_options = "/maxcpucount#{numjobs}#{build_options}"
     filter = unfilter ? '' : '/nologo /verbosity:minimal'
+  elsif !Dir.glob("#{build_tree}/*.ninja").empty?
+    # ninja
+    if !numjobs.empty?
+      build_options = "-j#{numjobs}#{build_options}"
+    end
   else
     # make
-    ccache_envvar = 'CCACHE_SLOPPINESS=pch_defines,time_macros' unless ENV['CCACHE_SLOPPINESS']   # Only attempt to do the right thing when user hasn't done it
-    ccache_envvar = "#{ccache_envvar} CCACHE_COMPRESS=1" unless ENV['CACHE_COMPRESS']
     if numjobs.empty?
       case RUBY_PLATFORM
       when /linux/