mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add mach build-stable to build with stable rustc
Github issue: #11806 Building with current stable rust (1.9.0) still fails because of feature pragmas in some dependencies (e.g. serde_item).
This commit is contained in:
parent
e30b288ed6
commit
a1a1dec4d5
7 changed files with 125 additions and 28 deletions
1
ports/stable-rust/.gitignore
vendored
Normal file
1
ports/stable-rust/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
6
ports/stable-rust/Cargo.toml
Normal file
6
ports/stable-rust/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "stable-rust"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["The Servo Project Developers"]
|
||||||
|
|
||||||
|
[dependencies]
|
10
ports/stable-rust/src/lib.rs
Normal file
10
ports/stable-rust/src/lib.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -131,11 +131,20 @@ class MachCommands(CommandBase):
|
||||||
action='append',
|
action='append',
|
||||||
default=[],
|
default=[],
|
||||||
help='Download rust stdlib for specified target')
|
help='Download rust stdlib for specified target')
|
||||||
def bootstrap_rustc(self, force=False, target=[]):
|
@CommandArgument('--stable',
|
||||||
|
action='store_true',
|
||||||
|
help='Use stable rustc version')
|
||||||
|
def bootstrap_rustc(self, force=False, target=[], stable=False):
|
||||||
|
self.set_use_stable_rust(stable)
|
||||||
|
version = self.rust_version()
|
||||||
|
rust_path = self.rust_path()
|
||||||
|
if stable:
|
||||||
rust_dir = path.join(
|
rust_dir = path.join(
|
||||||
self.context.sharedir, "rust", self.rust_path())
|
self.context.sharedir, "rust", version, rust_path)
|
||||||
date = self.rust_path().split("/")[0]
|
else:
|
||||||
install_dir = path.join(self.context.sharedir, "rust", date)
|
rust_dir = path.join(
|
||||||
|
self.context.sharedir, "rust", rust_path)
|
||||||
|
install_dir = path.join(self.context.sharedir, "rust", version)
|
||||||
|
|
||||||
if not force and path.exists(path.join(rust_dir, "rustc", "bin", "rustc" + BIN_SUFFIX)):
|
if not force and path.exists(path.join(rust_dir, "rustc", "bin", "rustc" + BIN_SUFFIX)):
|
||||||
print("Rust compiler already downloaded.", end=" ")
|
print("Rust compiler already downloaded.", end=" ")
|
||||||
|
@ -145,12 +154,15 @@ class MachCommands(CommandBase):
|
||||||
shutil.rmtree(rust_dir)
|
shutil.rmtree(rust_dir)
|
||||||
os.makedirs(rust_dir)
|
os.makedirs(rust_dir)
|
||||||
|
|
||||||
# The Rust compiler is hosted on the nightly server under the date with a name
|
# The nightly Rust compiler is hosted on the nightly server under the date with a name
|
||||||
# rustc-nightly-HOST-TRIPLE.tar.gz. We just need to pull down and extract it,
|
# rustc-nightly-HOST-TRIPLE.tar.gz, whereas the stable compiler is named
|
||||||
|
# rustc-VERSION-HOST-TRIPLE.tar.gz. We just need to pull down and extract it,
|
||||||
# giving a directory name that will be the same as the tarball name (rustc is
|
# giving a directory name that will be the same as the tarball name (rustc is
|
||||||
# in that directory).
|
# in that directory).
|
||||||
rustc_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s.tar.gz"
|
if stable:
|
||||||
% self.rust_path())
|
rustc_url = "https://static.rust-lang.org/dist/%s.tar.gz" % rust_path
|
||||||
|
else:
|
||||||
|
rustc_url = "https://static-rust-lang-org.s3.amazonaws.com/dist/%s.tar.gz" % rust_path
|
||||||
tgz_file = rust_dir + '-rustc.tar.gz'
|
tgz_file = rust_dir + '-rustc.tar.gz'
|
||||||
|
|
||||||
download_file("Rust compiler", rustc_url, tgz_file)
|
download_file("Rust compiler", rustc_url, tgz_file)
|
||||||
|
@ -159,11 +171,15 @@ class MachCommands(CommandBase):
|
||||||
extract(tgz_file, install_dir)
|
extract(tgz_file, install_dir)
|
||||||
print("Rust compiler ready.")
|
print("Rust compiler ready.")
|
||||||
|
|
||||||
# Each Rust stdlib has a name of the form `rust-std-nightly-TRIPLE.tar.gz`, with
|
# Each Rust stdlib has a name of the form `rust-std-nightly-TRIPLE.tar.gz` for the nightly
|
||||||
|
# releases, or rust-std-VERSION-TRIPLE.tar.gz for stable releases, with
|
||||||
# a directory of the name `rust-std-TRIPLE` inside and then a `lib` directory.
|
# a directory of the name `rust-std-TRIPLE` inside and then a `lib` directory.
|
||||||
# This `lib` directory needs to be extracted and merged with the `rustc/lib`
|
# This `lib` directory needs to be extracted and merged with the `rustc/lib`
|
||||||
# directory from the host compiler above.
|
# directory from the host compiler above.
|
||||||
lib_dir = path.join(install_dir, "rustc-nightly-{}".format(host_triple()),
|
nightly_suffix = "" if stable else "-nightly"
|
||||||
|
stable_version = "-{}".format(version) if stable else ""
|
||||||
|
lib_dir = path.join(install_dir,
|
||||||
|
"rustc{}{}-{}".format(nightly_suffix, stable_version, host_triple()),
|
||||||
"rustc", "lib", "rustlib")
|
"rustc", "lib", "rustlib")
|
||||||
|
|
||||||
# ensure that the libs for the host's target is downloaded
|
# ensure that the libs for the host's target is downloaded
|
||||||
|
@ -179,18 +195,26 @@ class MachCommands(CommandBase):
|
||||||
print("Use |bootstrap-rust --force| to download again.")
|
print("Use |bootstrap-rust --force| to download again.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if self.use_stable_rust():
|
||||||
|
std_url = ("https://static.rust-lang.org/dist/rust-std-%s-%s.tar.gz"
|
||||||
|
% (version, target_triple))
|
||||||
|
tgz_file = install_dir + ('rust-std-%s-%s.tar.gz' % (version, target_triple))
|
||||||
|
else:
|
||||||
std_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s/rust-std-nightly-%s.tar.gz"
|
std_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s/rust-std-nightly-%s.tar.gz"
|
||||||
% (date, target_triple))
|
% (version, target_triple))
|
||||||
tgz_file = install_dir + ('rust-std-nightly-%s.tar.gz' % target_triple)
|
tgz_file = install_dir + ('rust-std-nightly-%s.tar.gz' % target_triple)
|
||||||
|
|
||||||
download_file("Host rust library for target %s" % target_triple, std_url, tgz_file)
|
download_file("Host rust library for target %s" % target_triple, std_url, tgz_file)
|
||||||
print("Extracting Rust stdlib for target %s..." % target_triple)
|
print("Extracting Rust stdlib for target %s..." % target_triple)
|
||||||
extract(tgz_file, install_dir)
|
extract(tgz_file, install_dir)
|
||||||
shutil.copytree(path.join(install_dir, "rust-std-nightly-%s" % target_triple,
|
shutil.copytree(path.join(install_dir,
|
||||||
|
"rust-std%s%s-%s" % (nightly_suffix, stable_version, target_triple),
|
||||||
"rust-std-%s" % target_triple, "lib", "rustlib", target_triple),
|
"rust-std-%s" % target_triple, "lib", "rustlib", target_triple),
|
||||||
path.join(install_dir, "rustc-nightly-%s" % host_triple(),
|
path.join(install_dir,
|
||||||
|
"rustc%s%s-%s" % (nightly_suffix, stable_version, host_triple),
|
||||||
"rustc", "lib", "rustlib", target_triple))
|
"rustc", "lib", "rustlib", target_triple))
|
||||||
shutil.rmtree(path.join(install_dir, "rust-std-nightly-%s" % target_triple))
|
shutil.rmtree(path.join(install_dir,
|
||||||
|
"rust-std%s%s-%s" % (nightly_suffix, stable_version, target_triple)))
|
||||||
|
|
||||||
print("Rust {} libs ready.".format(target_triple))
|
print("Rust {} libs ready.".format(target_triple))
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,43 @@ class MachCommands(CommandBase):
|
||||||
print("Build completed in %s" % format_duration(elapsed))
|
print("Build completed in %s" % format_duration(elapsed))
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
@Command('build-stable',
|
||||||
|
description='Build Servo using stable rustc',
|
||||||
|
category='build')
|
||||||
|
@CommandArgument('--target', '-t',
|
||||||
|
default=None,
|
||||||
|
help='Cross compile for given target platform')
|
||||||
|
@CommandArgument('--release', '-r',
|
||||||
|
action='store_true',
|
||||||
|
help='Build in release mode')
|
||||||
|
@CommandArgument('--dev', '-d',
|
||||||
|
action='store_true',
|
||||||
|
help='Build in development mode')
|
||||||
|
@CommandArgument('--jobs', '-j',
|
||||||
|
default=None,
|
||||||
|
help='Number of jobs to run in parallel')
|
||||||
|
@CommandArgument('--features',
|
||||||
|
default=None,
|
||||||
|
help='Space-separated list of features to also build',
|
||||||
|
nargs='+')
|
||||||
|
@CommandArgument('--android',
|
||||||
|
default=None,
|
||||||
|
action='store_true',
|
||||||
|
help='Build for Android')
|
||||||
|
@CommandArgument('--debug-mozjs',
|
||||||
|
default=None,
|
||||||
|
action='store_true',
|
||||||
|
help='Enable debug assertions in mozjs')
|
||||||
|
@CommandArgument('--verbose', '-v',
|
||||||
|
action='store_true',
|
||||||
|
help='Print verbose output')
|
||||||
|
@CommandArgument('params', nargs='...',
|
||||||
|
help="Command-line arguments to be passed through to Cargo")
|
||||||
|
def build_stable(self, target=None, release=False, dev=False, jobs=None,
|
||||||
|
features=None, android=None, verbose=False, debug_mozjs=False, params=None):
|
||||||
|
self.set_use_stable_rust()
|
||||||
|
self.build(target, release, dev, jobs, features, android, verbose, debug_mozjs, params)
|
||||||
|
|
||||||
@Command('build-cef',
|
@Command('build-cef',
|
||||||
description='Build the Chromium Embedding Framework library',
|
description='Build the Chromium Embedding Framework library',
|
||||||
category='build')
|
category='build')
|
||||||
|
|
|
@ -184,9 +184,7 @@ class CommandBase(object):
|
||||||
self.config["tools"].setdefault("system-cargo", False)
|
self.config["tools"].setdefault("system-cargo", False)
|
||||||
self.config["tools"].setdefault("rust-root", "")
|
self.config["tools"].setdefault("rust-root", "")
|
||||||
self.config["tools"].setdefault("cargo-root", "")
|
self.config["tools"].setdefault("cargo-root", "")
|
||||||
if not self.config["tools"]["system-rust"]:
|
self.set_use_stable_rust(False)
|
||||||
self.config["tools"]["rust-root"] = path.join(
|
|
||||||
context.sharedir, "rust", self.rust_path())
|
|
||||||
if not self.config["tools"]["system-cargo"]:
|
if not self.config["tools"]["system-cargo"]:
|
||||||
self.config["tools"]["cargo-root"] = path.join(
|
self.config["tools"]["cargo-root"] = path.join(
|
||||||
context.sharedir, "cargo", self.cargo_build_id())
|
context.sharedir, "cargo", self.cargo_build_id())
|
||||||
|
@ -205,16 +203,33 @@ class CommandBase(object):
|
||||||
self.config["android"].setdefault("platform", "android-18")
|
self.config["android"].setdefault("platform", "android-18")
|
||||||
self.config["android"].setdefault("target", "arm-linux-androideabi")
|
self.config["android"].setdefault("target", "arm-linux-androideabi")
|
||||||
|
|
||||||
_rust_path = None
|
_use_stable_rust = False
|
||||||
|
_rust_version = None
|
||||||
|
_rust_version_is_stable = False
|
||||||
_cargo_build_id = None
|
_cargo_build_id = None
|
||||||
|
|
||||||
|
def set_use_stable_rust(self, use_stable_rust=True):
|
||||||
|
self._use_stable_rust = use_stable_rust
|
||||||
|
if not self.config["tools"]["system-rust"]:
|
||||||
|
self.config["tools"]["rust-root"] = path.join(
|
||||||
|
self.context.sharedir, "rust", self.rust_path())
|
||||||
|
|
||||||
|
def use_stable_rust(self):
|
||||||
|
return self._use_stable_rust
|
||||||
|
|
||||||
def rust_path(self):
|
def rust_path(self):
|
||||||
if self._rust_path is None:
|
if self._use_stable_rust:
|
||||||
filename = path.join(self.context.topdir, "rust-nightly-date")
|
return "rustc-%s-%s" % (self.rust_version(), host_triple())
|
||||||
|
else:
|
||||||
|
return "%s/rustc-nightly-%s" % (self.rust_version(), host_triple())
|
||||||
|
|
||||||
|
def rust_version(self):
|
||||||
|
if self._rust_version is None or self._use_stable_rust != self._rust_version_is_stable:
|
||||||
|
filename = path.join(self.context.topdir,
|
||||||
|
"rust-stable-version" if self._use_stable_rust else "rust-nightly-date")
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
date = f.read().strip()
|
self._rust_version = f.read().strip()
|
||||||
self._rust_path = ("%s/rustc-nightly-%s" % (date, host_triple()))
|
return self._rust_version
|
||||||
return self._rust_path
|
|
||||||
|
|
||||||
def cargo_build_id(self):
|
def cargo_build_id(self):
|
||||||
if self._cargo_build_id is None:
|
if self._cargo_build_id is None:
|
||||||
|
@ -317,7 +332,9 @@ class CommandBase(object):
|
||||||
|
|
||||||
env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"]
|
env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"]
|
||||||
|
|
||||||
if "CARGO_TARGET_DIR" not in env:
|
if self.use_stable_rust():
|
||||||
|
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "ports/stable-rust/target")
|
||||||
|
elif "CARGO_TARGET_DIR" not in env:
|
||||||
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target")
|
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target")
|
||||||
|
|
||||||
if extra_lib:
|
if extra_lib:
|
||||||
|
@ -426,7 +443,8 @@ class CommandBase(object):
|
||||||
|
|
||||||
if not (self.config['tools']['system-rust'] or (rustc_binary_exists and target_exists)):
|
if not (self.config['tools']['system-rust'] or (rustc_binary_exists and target_exists)):
|
||||||
print("looking for rustc at %s" % (rustc_path))
|
print("looking for rustc at %s" % (rustc_path))
|
||||||
Registrar.dispatch("bootstrap-rust", context=self.context, target=filter(None, [target]))
|
Registrar.dispatch("bootstrap-rust", context=self.context, target=filter(None, [target]),
|
||||||
|
stable=self._use_stable_rust)
|
||||||
|
|
||||||
cargo_path = path.join(self.config["tools"]["cargo-root"], "cargo", "bin",
|
cargo_path = path.join(self.config["tools"]["cargo-root"], "cargo", "bin",
|
||||||
"cargo" + BIN_SUFFIX)
|
"cargo" + BIN_SUFFIX)
|
||||||
|
|
1
rust-stable-version
Normal file
1
rust-stable-version
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1.9.0
|
Loading…
Add table
Add a link
Reference in a new issue