From ca08ff876b3622a5e6b3aca6b60c934d245b7b0a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Apr 2017 21:50:44 +0200 Subject: [PATCH 1/2] Add cargo-geckolib and rustc-geckolib commands to mach. --- python/servo/build_commands.py | 3 +-- python/servo/command_base.py | 6 +++++- python/servo/devenv_commands.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index a8cb0f9e4a9..48de80811ee 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -416,9 +416,8 @@ class MachCommands(CommandBase): self.set_use_stable_rust() self.ensure_bootstrapped() - env = self.build_env(is_build=True) + env = self.build_env(is_build=True, geckolib=True) geckolib_build_path = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") - env["CARGO_TARGET_DIR"] = geckolib_build_path ret = None opts = [] diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 8db1209a6e4..2dbeff53bfb 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -382,7 +382,7 @@ class CommandBase(object): " --release" if release else "")) sys.exit() - def build_env(self, hosts_file_path=None, target=None, is_build=False): + def build_env(self, hosts_file_path=None, target=None, is_build=False, geckolib=False): """Return an extended environment dictionary.""" env = os.environ.copy() if sys.platform == "win32" and type(env['PATH']) == unicode: @@ -519,6 +519,10 @@ class CommandBase(object): env['GIT_INFO'] = '-'.join(git_info) + if geckolib: + geckolib_build_path = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") + env["CARGO_TARGET_DIR"] = geckolib_build_path + return env def servo_crate(self): diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index bb5ed6d2704..8fde8e3b361 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -38,6 +38,24 @@ class MachCommands(CommandBase): return call(["cargo"] + params, env=self.build_env()) return call(['cargo'] + params, env=self.build_env()) + @Command('cargo-geckolib', + description='Run Cargo with the same compiler version and root crate as build-geckolib', + category='devenv') + @CommandArgument( + 'params', default=None, nargs='...', + help="Command-line arguments to be passed through to Cargo") + def cargo_geckolib(self, params): + if not params: + params = [] + + self.set_use_stable_rust() + env = self.build_env(geckolib=True) + + if self.context.topdir == getcwd(): + with cd(path.join('ports', 'geckolib')): + return call(["cargo"] + params, env=env) + return call(['cargo'] + params, env=env) + @Command('cargo-update', description='Same as update-cargo', category='devenv') @@ -97,6 +115,21 @@ class MachCommands(CommandBase): params = [] return call(["rustc"] + params, env=self.build_env()) + @Command('rustc-geckolib', + description='Run the Rust compiler with the same compiler version and root crate as build-geckolib', + category='devenv') + @CommandArgument( + 'params', default=None, nargs='...', + help="Command-line arguments to be passed through to rustc") + def rustc_geckolib(self, params): + if params is None: + params = [] + + self.set_use_stable_rust() + env = self.build_env(geckolib=True) + + return call(["rustc"] + params, env=env) + @Command('rust-root', description='Print the path to the root of the Rust compiler', category='devenv') From 9f5ba0aee936e5be417c51f6e12c0d96a009c76b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Apr 2017 21:52:10 +0200 Subject: [PATCH 2/2] Make `./mach rustc` and `./mach cargo` bootstrap. --- python/servo/devenv_commands.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 8fde8e3b361..56f02b1cb55 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -33,6 +33,8 @@ class MachCommands(CommandBase): if not params: params = [] + self.ensure_bootstrapped() + if self.context.topdir == getcwd(): with cd(path.join('components', 'servo')): return call(["cargo"] + params, env=self.build_env()) @@ -49,6 +51,7 @@ class MachCommands(CommandBase): params = [] self.set_use_stable_rust() + self.ensure_bootstrapped() env = self.build_env(geckolib=True) if self.context.topdir == getcwd(): @@ -113,6 +116,9 @@ class MachCommands(CommandBase): def rustc(self, params): if params is None: params = [] + + self.ensure_bootstrapped() + return call(["rustc"] + params, env=self.build_env()) @Command('rustc-geckolib', @@ -126,6 +132,7 @@ class MachCommands(CommandBase): params = [] self.set_use_stable_rust() + self.ensure_bootstrapped() env = self.build_env(geckolib=True) return call(["rustc"] + params, env=env)