servo: Merge #12752 - Run git commands only with mach build (from UK992:mach); r=metajack
authorUK992 <urbankrajnc92@gmail.com>
Fri, 05 Aug 2016 16:15:09 -0500
changeset 339446 16c5530fdf715a972d8ff8fb8268da2341c7a1c6
parent 339445 c4aefdcee7d19bd49f40ac50619a78747ac91568
child 339447 685103c088c040cf89c77a0892c7e10eff56b698
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)
reviewersmetajack
servo: Merge #12752 - Run git commands only with mach build (from UK992:mach); r=metajack This should solve problem with slow run on Windows mention in https://github.com/servo/servo/issues/12730, which is cause by slow git. Source-Repo: https://github.com/servo/servo Source-Revision: 686ca251392ffd7323693ccbe1defc89b3a36caa
servo/python/servo/build_commands.py
servo/python/servo/command_base.py
--- a/servo/python/servo/build_commands.py
+++ b/servo/python/servo/build_commands.py
@@ -204,17 +204,17 @@ class MachCommands(CommandBase):
 
         if debug_mozjs:
             features += ["script/debugmozjs"]
 
         if features:
             opts += ["--features", "%s" % ' '.join(features)]
 
         build_start = time()
-        env = self.build_env(target=target)
+        env = self.build_env(target=target, is_build=True)
 
         if android:
             # Build OpenSSL for android
             make_cmd = ["make"]
             if jobs is not None:
                 make_cmd += ["-j" + jobs]
             android_dir = self.android_build_dir(dev)
             openssl_dir = path.join(android_dir, "native", "openssl")
@@ -294,17 +294,17 @@ class MachCommands(CommandBase):
 
         servo_features = self.servo_features()
         if servo_features:
             opts += ["--features", "%s" % ' '.join("servo/" + x for x in servo_features)]
 
         build_start = time()
         with cd(path.join("ports", "cef")):
             ret = call(["cargo", "build"] + opts,
-                       env=self.build_env(), verbose=verbose)
+                       env=self.build_env(is_build=True), verbose=verbose)
         elapsed = time() - build_start
 
         # Generate Desktop Notification if elapsed-time > some threshold value
         notify_build_done(elapsed)
 
         print("CEF build completed in %s" % format_duration(elapsed))
 
         return ret
@@ -329,17 +329,17 @@ class MachCommands(CommandBase):
         opts = []
         if jobs is not None:
             opts += ["-j", jobs]
         if verbose:
             opts += ["-v"]
         if release:
             opts += ["--release"]
 
-        env = self.build_env()
+        env = self.build_env(is_build=True)
         env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8")
 
         build_start = time()
         with cd(path.join("ports", "geckolib")):
             ret = call(["cargo", "build"] + opts, env=env, verbose=verbose)
         elapsed = time() - build_start
 
         # Generate Desktop Notification if elapsed-time > some threshold value
--- a/servo/python/servo/command_base.py
+++ b/servo/python/servo/command_base.py
@@ -343,17 +343,17 @@ class CommandBase(object):
             else:
                 return dev_path
 
         print("The %s profile is not built. Please run './mach build%s' "
               "and try again." % ("release" if release else "dev",
                                   " --release" if release else ""))
         sys.exit()
 
-    def build_env(self, hosts_file_path=None, target=None):
+    def build_env(self, hosts_file_path=None, target=None, is_build=False):
         """Return an extended environment dictionary."""
         env = os.environ.copy()
         if sys.platform == "win32" and type(env['PATH']) == unicode:
             # On win32, the virtualenv's activate_this.py script sometimes ends up
             # turning os.environ['PATH'] into a unicode string.  This doesn't work
             # for passing env vars in to a process, so we force it back to ascii.
             # We don't use UTF8 since that won't be correct anyway; if you actually
             # have unicode stuff in your path, all this PATH munging would have broken
@@ -440,17 +440,17 @@ class CommandBase(object):
         # Ensure Rust uses hard floats and SIMD on ARM devices
         if target:
             if target.startswith('arm') or target.startswith('aarch64'):
                 env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C target-feature=+neon"
 
         env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -W unused-extern-crates"
 
         git_info = []
-        if os.path.isdir('.git'):
+        if os.path.isdir('.git') and is_build:
             git_sha = subprocess.check_output([
                 'git', 'rev-parse', '--short', 'HEAD'
             ]).strip()
             git_is_dirty = bool(subprocess.check_output([
                 'git', 'status', '--porcelain'
             ]).strip())
 
             git_info.append('')