some Python nits and fixes
This commit is contained in:
parent
a264f5b7e8
commit
a422b7e4ed
2 changed files with 15 additions and 19 deletions
|
@ -81,9 +81,10 @@ def run(args, verbose=False):
|
||||||
|
|
||||||
def stage0_data(rust_root):
|
def stage0_data(rust_root):
|
||||||
nightlies = os.path.join(rust_root, "src/stage0.txt")
|
nightlies = os.path.join(rust_root, "src/stage0.txt")
|
||||||
with open(nightlies, 'r') as nightlies:
|
|
||||||
data = {}
|
data = {}
|
||||||
for line in nightlies.read().split("\n"):
|
with open(nightlies, 'r') as nightlies:
|
||||||
|
for line in nightlies:
|
||||||
|
line = line.rstrip() # Strip newline character, '\n'
|
||||||
if line.startswith("#") or line == '':
|
if line.startswith("#") or line == '':
|
||||||
continue
|
continue
|
||||||
a, b = line.split(": ", 1)
|
a, b = line.split(": ", 1)
|
||||||
|
@ -219,7 +220,7 @@ class RustBuild:
|
||||||
env)
|
env)
|
||||||
|
|
||||||
def run(self, args, env):
|
def run(self, args, env):
|
||||||
proc = subprocess.Popen(args, env = env)
|
proc = subprocess.Popen(args, env=env)
|
||||||
ret = proc.wait()
|
ret = proc.wait()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
@ -234,10 +235,9 @@ class RustBuild:
|
||||||
try:
|
try:
|
||||||
ostype = subprocess.check_output(['uname', '-s']).strip()
|
ostype = subprocess.check_output(['uname', '-s']).strip()
|
||||||
cputype = subprocess.check_output(['uname', '-m']).strip()
|
cputype = subprocess.check_output(['uname', '-m']).strip()
|
||||||
except FileNotFoundError:
|
except subprocess.CalledProcessError:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return 'x86_64-pc-windows-msvc'
|
return 'x86_64-pc-windows-msvc'
|
||||||
else:
|
|
||||||
err = "uname not found"
|
err = "uname not found"
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
raise Exception(err)
|
raise Exception(err)
|
||||||
|
@ -247,7 +247,7 @@ class RustBuild:
|
||||||
# sysctl instead.
|
# sysctl instead.
|
||||||
if ostype == 'Darwin' and cputype == 'i686':
|
if ostype == 'Darwin' and cputype == 'i686':
|
||||||
sysctl = subprocess.check_output(['sysctl', 'hw.optional.x86_64'])
|
sysctl = subprocess.check_output(['sysctl', 'hw.optional.x86_64'])
|
||||||
if sysctl.contains(': 1'):
|
if ': 1' in sysctl:
|
||||||
cputype = 'x86_64'
|
cputype = 'x86_64'
|
||||||
|
|
||||||
# The goal here is to come up with the same triple as LLVM would,
|
# The goal here is to come up with the same triple as LLVM would,
|
||||||
|
|
|
@ -11,18 +11,15 @@
|
||||||
# except according to those terms.
|
# except according to those terms.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
|
||||||
|
|
||||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../bootstrap"))
|
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../bootstrap"))
|
||||||
sys.path.append(path)
|
sys.path.append(path)
|
||||||
|
|
||||||
import bootstrap
|
import bootstrap
|
||||||
|
|
||||||
def main(argv):
|
def main(triple):
|
||||||
src_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
src_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||||
triple = argv[1]
|
|
||||||
data = bootstrap.stage0_data(src_root)
|
data = bootstrap.stage0_data(src_root)
|
||||||
|
|
||||||
channel, date = data['rustc'].split('-', 1)
|
channel, date = data['rustc'].split('-', 1)
|
||||||
|
@ -31,9 +28,8 @@ def main(argv):
|
||||||
if not os.path.exists(dl_dir):
|
if not os.path.exists(dl_dir):
|
||||||
os.makedirs(dl_dir)
|
os.makedirs(dl_dir)
|
||||||
|
|
||||||
filename_base = 'rustc-' + channel + '-' + triple
|
filename = 'rustc-{}-{}.tar.gz'.format(channel, triple)
|
||||||
filename = filename_base + '.tar.gz'
|
url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename)
|
||||||
url = 'https://static.rust-lang.org/dist/' + date + '/' + filename
|
|
||||||
dst = dl_dir + '/' + filename
|
dst = dl_dir + '/' + filename
|
||||||
if not os.path.exists(dst):
|
if not os.path.exists(dst):
|
||||||
bootstrap.get(url, dst)
|
bootstrap.get(url, dst)
|
||||||
|
@ -48,4 +44,4 @@ def main(argv):
|
||||||
bootstrap.unpack(dst, stage0_dst, match='rustc', verbose=True)
|
bootstrap.unpack(dst, stage0_dst, match='rustc', verbose=True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv[1])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue