servo: Merge #8366 - Add CCACHE infra and turn it on in travis (from larsbergstrom:ccache); r=frewsxcv
authorLars Bergstrom <lars@lars.com>
Sat, 07 Nov 2015 06:32:24 +0500
changeset 337523 3513d5f73a0306465b962437f37511cf01b00a1d
parent 337522 6e3c59a95658befbb90ef9217a33c54caa887173
child 337524 9dbf9f817ad33a3e2cb53c841480eb04853c75a1
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrewsxcv
servo: Merge #8366 - Add CCACHE infra and turn it on in travis (from larsbergstrom:ccache); r=frewsxcv r? @Manishearth This lets devs configure their use of CCACHE with their .servobuild file, as usual. For build environments, they can either have a .servobuild file or set the CCACHE env var to point at the ccache binary to use. It also adds support for ccache to our travis builds. Buildbot will come in a separate commit to the saltfs repo. It is expected that the various cargo makefiles will look at this variable and do the "right thing" to tell their native build to instead use ccache. e.g., https://github.com/servo/mozjs/pull/62 Source-Repo: https://github.com/servo/servo Source-Revision: d16ba51b4722a84f69976ca8679af672495248c8
servo/.travis.yml
servo/python/servo/build_commands.py
servo/python/servo/command_base.py
servo/servobuild.example
--- a/servo/.travis.yml
+++ b/servo/.travis.yml
@@ -10,21 +10,24 @@ matrix:
       dist: trusty
       script:
          - ./mach build -d --verbose
          - bash etc/ci/lockfile_changed.sh
       cache:
         directories:
           - .cargo
           - .servo
+          - $HOME/.ccache
+      env: CCACHE=/usr/bin/ccache
       addons:
         apt:
           packages:
             - cmake
             - freeglut3-dev
             - gperf
             - libosmesa6-dev
             - python-virtualenv
             - xorg-dev
+            - ccache
 
 branches:
   only:
     - master
--- a/servo/python/servo/build_commands.py
+++ b/servo/python/servo/build_commands.py
@@ -227,16 +227,19 @@ class MachCommands(CommandBase):
                     verbose=verbose)
                 if status:
                     return status
             openssl_dir = path.join(self.android_support_dir(), "openssl-1.0.1k")
             env['OPENSSL_LIB_DIR'] = openssl_dir
             env['OPENSSL_INCLUDE_DIR'] = path.join(openssl_dir, "include")
             env['OPENSSL_STATIC'] = 'TRUE'
 
+        if not (self.config["build"]["ccache"] == ""):
+            env['CCACHE'] = self.config["build"]["ccache"]
+
         status = call(
             ["cargo", "build"] + opts,
             env=env, cwd=self.servo_crate(), verbose=verbose)
         elapsed = time() - build_start
 
         # Generate Desktop Notification if elapsed-time > some threshold value
         notify_build_done(elapsed)
 
--- a/servo/python/servo/command_base.py
+++ b/servo/python/servo/command_base.py
@@ -102,16 +102,17 @@ class CommandBase(object):
             self.config["tools"]["cargo-root"] = path.join(
                 context.sharedir, "cargo", self.cargo_build_id())
         self.config["tools"].setdefault("rustc-with-gold", True)
 
         self.config.setdefault("build", {})
         self.config["build"].setdefault("android", False)
         self.config["build"].setdefault("mode", "")
         self.config["build"].setdefault("debug-mozjs", False)
+        self.config["build"].setdefault("ccache", "")
 
         self.config.setdefault("android", {})
         self.config["android"].setdefault("sdk", "")
         self.config["android"].setdefault("ndk", "")
         self.config["android"].setdefault("toolchain", "")
 
         self.config.setdefault("gonk", {})
         self.config["gonk"].setdefault("b2g", "")
--- a/servo/servobuild.example
+++ b/servo/servobuild.example
@@ -31,16 +31,18 @@ rustc-with-gold = true
 # Set "mode = dev" or use `mach build --dev` to build the project with warning.
 # or Set "mode = release" or use `mach build --release` for optimized build.
 # Defaults to prompting before building
 #mode = "dev"
 # Set "android = true" or use `mach build --android` to build the Android app.
 android = false
 # Set "debug-mozjs" or use `mach build --debug-mozjs` to build a debug spidermonkey.
 debug-mozjs = false
+# Set to the path to your ccache binary to enable caching of compiler outputs
+#ccache = "/usr/local/bin/ccache"
 
 # Android information
 [android]
 # Defaults to the value of $ANDROID_SDK, $ANDROID_NDK, $ANDROID_TOOLCHAIN respectively
 #sdk = "/opt/android-sdk"
 #ndk = "/opt/android-ndk"
 #toolchain = "/opt/android-toolchain"