Browse Source

Only supply the CCACHE environment variable when user hasn't done it.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
b468eac53e
2 changed files with 9 additions and 7 deletions
  1. 2 2
      Docs/GettingStarted.dox
  2. 7 5
      Rakefile

+ 2 - 2
Docs/GettingStarted.dox

@@ -278,12 +278,12 @@ OpenGL does not depend on a separate shader compiler DLL.
 
 \section Using_ccache Using ccache
 
-ccache is a compiler cache software available on Linux and Mac OS X host systems. It speeds up the build by bypassing the actual compilation and reusing the result from previous compilation. In order for this to work correctly when building/using Urho3D library with GCC/Clang precompiled header enabled, the following environment variable must be set:
+ccache is a compiler cache software available on Linux and Mac OS X host systems. It speeds up the build by bypassing the actual compilation and reusing the result from previous compilation when the cache is hit. In order for this to work correctly when building/using Urho3D library with GCC/Clang precompiled header enabled, the following environment variable must be set:
 \verbatim
 CCACHE_SLOPPINESS=pch_defines,time_macros
 \endverbatim
 
-Failure to do so would cause the precompiled header cannot be used by ccache.
+Failure to do so would cause the precompiled header cannot be used by ccache. When ccache is setup correctly and with more hits than misses then even clean build can be done as fast as incremental build.
 
 \page Running Running Urho3D player application
 

+ 7 - 5
Rakefile

@@ -117,7 +117,7 @@ task :make do
     end
   }
   build_tree = ENV["#{platform}_build_tree"] || ENV['build_tree'] || "../#{platform}-Build"
-  use_ccache = ''
+  ccache_envvar = ''
   if !Dir.glob("#{build_tree}/*.xcodeproj").empty?
     # xcodebuild
     if !numjobs.empty?
@@ -131,7 +131,8 @@ task :make do
     filter = unfilter ? '' : '/nologo /verbosity:minimal'
   else
     # make
-    use_ccache = 'CCACHE_SLOPPINESS=pch_defines,time_macros CCACHE_COMPRESS=1' if ENV['USE_CCACHE']
+    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/
@@ -140,15 +141,16 @@ task :make do
         numjobs = `sysctl -n hw.logicalcpu`.chomp
       when /win32|mingw|mswin/
         require 'win32ole'
-        WIN32OLE.connect("winmgmts://").ExecQuery("select NumberOfLogicalProcessors from Win32_ComputerSystem").each { |out| numjobs = out.NumberOfLogicalProcessors }
+        WIN32OLE.connect('winmgmts://').ExecQuery('select NumberOfLogicalProcessors from Win32_ComputerSystem').each { |out| numjobs = out.NumberOfLogicalProcessors }
+        ccache_envvar = ''    # Extra env var is harmless even when ccache is not in use, well, except on Windows host system
       else
-        numjobs = '1'
+        numjobs = 1
       end
     end
     build_options = "-j#{numjobs}#{build_options}"
     filter = ''
   end
-  system "cd \"#{build_tree}\" && #{use_ccache} cmake --build . #{cmake_build_options} -- #{build_options} #{filter}" or abort
+  system "cd \"#{build_tree}\" && #{ccache_envvar} cmake --build . #{cmake_build_options} -- #{build_options} #{filter}" or abort
 end
 
 # Usage: rake android [parameter='--es pickedLibrary Urho3DPlayer'] [intent=.SampleLauncher] [package=com.github.urho3d] [success_indicator='Initialized engine'] [payload='sleep 30'] [api=19] [abi=armeabi-v7a] [avd=test_#{api}_#{abi}] [retries=10] [retry_interval=10]