shutil.move(tp, fp)
shutil.rmtree(os.path.join(dst, fname))
-def run(args, verbose=False, exception=False, cwd=None, env=None):
+def run(args, verbose=False, exception=False, **kwargs):
if verbose:
print("running: " + ' '.join(args))
sys.stdout.flush()
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
- ret = subprocess.Popen(args, cwd=cwd, env=env)
+ ret = subprocess.Popen(args, **kwargs)
code = ret.wait()
if code != 0:
err = "failed to run: " + ' '.join(args)
args.append("--frozen")
run(args, env=env, verbose=self.verbose)
- def output(self, args, env=None, cwd=None):
- default_encoding = sys.getdefaultencoding()
- proc = subprocess.Popen(args, stdout=subprocess.PIPE, env=env, cwd=cwd)
- (out, err) = proc.communicate()
- ret = proc.wait()
- if ret != 0:
- print(out)
- sys.exit(ret)
- return out.decode(default_encoding)
-
def build_triple(self):
default_encoding = sys.getdefaultencoding()
config = self.get_toml('build')
return
print('Updating submodules')
- output = self.output(["git", "submodule", "status"], cwd=self.rust_root)
- submodules = []
- for line in output.splitlines():
- # NOTE `git submodule status` output looks like this:
- #
- # -5066b7dcab7e700844b0e2ba71b8af9dc627a59b src/liblibc
- # +b37ef24aa82d2be3a3cc0fe89bf82292f4ca181c src/compiler-rt (remotes/origin/..)
- # e058ca661692a8d01f8cf9d35939dfe3105ce968 src/jemalloc (3.6.0-533-ge058ca6)
- #
- # The first character can be '-', '+' or ' ' and denotes the
- # `State` of the submodule Right next to this character is the
- # SHA-1 of the submodule HEAD And after that comes the path to the
- # submodule
- path = line[1:].split(' ')[1]
- submodules.append([path, line[0]])
-
- run(["git", "submodule", "sync"], cwd=self.rust_root)
-
- for submod in submodules:
- path, status = submod
- if path.endswith('llvm') and \
+ run(["git", "submodule", "-q", "sync"], cwd=self.rust_root)
+ # FIXME: nobody does, but this won't work well with whitespace in
+ # submodule path
+ submodules = [s.split()[1] for s in subprocess.check_output(
+ ["git", "config", "--file", os.path.join(
+ self.rust_root, ".gitmodules"), "--get-regexp", "path"]).splitlines()]
+ for module in submodules:
+ if module.endswith(b"llvm") and \
(self.get_toml('llvm-config') or self.get_mk('CFG_LLVM_ROOT')):
continue
- if path.endswith('jemalloc') and \
+ if module.endswith(b"jemalloc") and \
(self.get_toml('jemalloc') or self.get_mk('CFG_JEMALLOC_ROOT')):
continue
- submod_path = os.path.join(self.rust_root, path)
-
- if status == ' ':
- run(["git", "reset", "--hard"], cwd=submod_path)
- run(["git", "clean", "-fdx"], cwd=submod_path)
- elif status == '+':
- run(["git", "submodule", "update", path], cwd=self.rust_root)
- run(["git", "reset", "--hard"], cwd=submod_path)
- run(["git", "clean", "-fdx"], cwd=submod_path)
- elif status == '-':
- run(["git", "submodule", "init", path], cwd=self.rust_root)
- run(["git", "submodule", "update", path], cwd=self.rust_root)
- else:
- raise ValueError('unknown submodule status: ' + status)
+ run(["git", "submodule", "update",
+ "--init", module], cwd=self.rust_root)
+ run(["git", "submodule", "-q", "foreach", "git",
+ "reset", "-q", "--hard"], cwd=self.rust_root)
+ run(["git", "submodule", "-q", "foreach", "git",
+ "clean", "-qdfx"], cwd=self.rust_root)
+
def bootstrap():
parser = argparse.ArgumentParser(description='Build rust')