Auto merge of #12752 - UK992:mach, r=metajack

Run git commands only with mach build

This should solve problem with slow run on Windows mention in https://github.com/servo/servo/issues/12730, which is cause by slow git.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12752)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-05 16:15:09 -05:00 committed by GitHub
commit 686ca25139
2 changed files with 5 additions and 5 deletions

View file

@ -209,7 +209,7 @@ class MachCommands(CommandBase):
opts += ["--features", "%s" % ' '.join(features)] opts += ["--features", "%s" % ' '.join(features)]
build_start = time() build_start = time()
env = self.build_env(target=target) env = self.build_env(target=target, is_build=True)
if android: if android:
# Build OpenSSL for android # Build OpenSSL for android
@ -299,7 +299,7 @@ class MachCommands(CommandBase):
build_start = time() build_start = time()
with cd(path.join("ports", "cef")): with cd(path.join("ports", "cef")):
ret = call(["cargo", "build"] + opts, ret = call(["cargo", "build"] + opts,
env=self.build_env(), verbose=verbose) env=self.build_env(is_build=True), verbose=verbose)
elapsed = time() - build_start elapsed = time() - build_start
# Generate Desktop Notification if elapsed-time > some threshold value # Generate Desktop Notification if elapsed-time > some threshold value
@ -334,7 +334,7 @@ class MachCommands(CommandBase):
if release: if release:
opts += ["--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") env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8")
build_start = time() build_start = time()

View file

@ -348,7 +348,7 @@ class CommandBase(object):
" --release" if release else "")) " --release" if release else ""))
sys.exit() 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.""" """Return an extended environment dictionary."""
env = os.environ.copy() env = os.environ.copy()
if sys.platform == "win32" and type(env['PATH']) == unicode: if sys.platform == "win32" and type(env['PATH']) == unicode:
@ -445,7 +445,7 @@ class CommandBase(object):
env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -W unused-extern-crates" env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -W unused-extern-crates"
git_info = [] git_info = []
if os.path.isdir('.git'): if os.path.isdir('.git') and is_build:
git_sha = subprocess.check_output([ git_sha = subprocess.check_output([
'git', 'rev-parse', '--short', 'HEAD' 'git', 'rev-parse', '--short', 'HEAD'
]).strip() ]).strip()