def build(self, target=None, release=False, jobs=None, android=None, verbose=False, debug_mozjs=False, params=None): self.ensure_bootstrapped() if android is None: android = self.config["build"]["android"] opts = params or [] features = [] if release: opts += ["--release"] if target: opts += ["--target", target] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if android: # Ensure the APK builder submodule has been built first apk_builder_dir = "support/android-rs-glue" with cd(path.join(apk_builder_dir, "apk-builder")): subprocess.call(["cargo", "build"], env=self.build_env()) opts += ["--target", "arm-linux-androideabi"] if debug_mozjs or self.config["build"]["debug-mozjs"]: features += ["script/debugmozjs"] if is_headless_build(): opts += ["--no-default-features"] features += ["glutin_app", "headless"] if features: opts += ["--features", "%s" % ' '.join(features)] build_start = time() env = self.build_env() if android: # Build OpenSSL for android with cd(self.android_support_dir()): status = subprocess.call( ["make", "-j4", "-f", "openssl.makefile"], env=self.build_env()) env['OPENSSL_PATH'] = path.join(self.android_support_dir(), "openssl-1.0.1k") status = subprocess.call(["cargo", "build"] + opts, env=env, cwd=self.servo_crate()) elapsed = time() - build_start print("Build completed in %0.2fs" % elapsed) return status
def build(self, target=None, release=False, jobs=None, android=None, verbose=False, debug_mozjs=False, params=None): self.ensure_bootstrapped() if android is None: android = self.config["build"]["android"] opts = params or [] features = [] if release: opts += ["--release"] if target: opts += ["--target", target] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if android: # Ensure the APK builder submodule has been built first apk_builder_dir = "support/android-rs-glue" with cd(path.join(apk_builder_dir, "apk-builder")): subprocess.call(["cargo", "build"], env=self.build_env()) opts += ["--target", "arm-linux-androideabi"] if debug_mozjs or self.config["build"]["debug-mozjs"]: features += ["script/debugmozjs"] if is_headless_build(): opts += ["--no-default-features"] features += ["headless"] if android: features += ["android_glue"] if features: opts += ["--features", "%s" % ' '.join(features)] build_start = time() env = self.build_env() if android: # Build OpenSSL for android with cd(self.android_support_dir()): status = subprocess.call( ["make", "-j4", "-f", "openssl.makefile"], env=self.build_env()) env['OPENSSL_PATH'] = path.join(self.android_support_dir(), "openssl-1.0.1k") status = subprocess.call( ["cargo", "build"] + opts, env=env, cwd=self.servo_crate()) elapsed = time() - build_start print("Build completed in %0.2fs" % elapsed) return status
def update_cargo(self, params): cargo_paths = [path.join("."), path.join("ports", "cef"), path.join("ports", "android", "glut_app")] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def build_geckolib(self, jobs=None, verbose=False, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() self.ensure_clobbered() env = self.build_env(is_build=True, geckolib=True) ret = None opts = [] features = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] else: features += ["gecko_debug"] if features: opts += ["--features", ' '.join(features)] build_start = time() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(self.config, elapsed) print("GeckoLib build completed in %s" % format_duration(elapsed)) return ret
def build_geckolib(self, jobs=None, verbose=False, release=False): self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] build_start = time() env = self.build_env() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("GeckoLib build completed in %s" % format_duration(elapsed)) return ret
def upgrade_wpt_runner(self): env = self.build_env() with cd(path.join(self.context.topdir, 'tests', 'wpt', 'harness')): code = call(["git", "init"], env=env) if code: return code # No need to report an error if this fails, as it will for the first use call(["git", "remote", "rm", "upstream"], env=env) code = call([ "git", "remote", "add", "upstream", "https://github.com/w3c/wptrunner.git" ], env=env) if code: return code code = call(["git", "fetch", "upstream"], env=env) if code: return code code = call(["git", "reset", "--hard", "remotes/upstream/master"], env=env) if code: return code code = call(["rm", "-rf", ".git"], env=env) if code: return code return 0
def build_geckolib(self, jobs=None, verbose=False, release=False): self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] build_start = time() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=self.build_env(), verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("GeckoLib build completed in %0.2fs" % elapsed) return ret
def update_submodules(self): # Ensure that the installed git version is >= 1.8.1 gitversion_output = subprocess.check_output(["git", "--version"]) gitversion = LooseVersion(gitversion_output.split(" ")[-1]) if gitversion < LooseVersion("1.8.1"): print("Git version 1.8.1 or above required. Current version is {}". format(gitversion)) sys.exit(1) submodules = subprocess.check_output(["git", "submodule", "status"]) for line in submodules.split('\n'): components = line.strip().split(' ') if len(components) > 1: module_path = components[1] if path.exists(module_path): with cd(module_path): output = subprocess.check_output( ["git", "status", "--porcelain"]) if len(output) != 0: print("error: submodule %s is not clean" % module_path) print("\nClean the submodule and try again.") return 1 subprocess.check_call( ["git", "submodule", "--quiet", "sync", "--recursive"]) subprocess.check_call( ["git", "submodule", "update", "--init", "--recursive"])
def update_cargo(self, params=None, package=None, all_packages=None): if not params: params = [] if package: params += ["-p", package] elif all_packages: params = [] else: print("Please choose package to update with the --package (-p) ") print("flag or update all packages with --all-packages (-a) flag") sys.exit(1) cargo_paths = [ path.join('components', 'servo'), path.join('ports', 'cef'), path.join('ports', 'geckolib'), path.join('ports', 'gonk') ] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def fetch(self): # Fetch Rust and Cargo self.ensure_bootstrapped() # Fetch Cargo dependencies with cd(self.context.topdir): call(["cargo", "fetch"], env=self.build_env())
def build_gonk(self, jobs=None, verbose=False, release=False): self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] opts += ["--target", "arm-linux-androideabi"] env = self.build_env(gonk=True) build_start = time() with cd(path.join("ports", "gonk")): ret = subprocess.call(["cargo", "build"] + opts, env=env) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("Gonk build completed in %0.2fs" % elapsed) return ret
def build_cef(self, jobs=None, verbose=False, release=False, with_debug_assertions=False): self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] servo_features = self.servo_features() if servo_features: opts += ["--features", "%s" % ' '.join(servo_features)] build_start = time() env = self.build_env(is_build=True) if with_debug_assertions: env["RUSTFLAGS"] = "-C debug_assertions" with cd(path.join("ports", "cef")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("CEF build completed in %s" % format_duration(elapsed)) return ret
def test_stylo(self, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env() env["RUST_BACKTRACE"] = "1" env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") release = ["--release"] if release else [] ret = 0 with cd(path.join("ports", "geckolib")): ret = call(["cargo", "test", "-p", "stylo_tests"] + release, env=env) if ret != 0: return ret with cd(path.join("ports", "geckolib")): return call(["cargo", "test", "-p", "style"] + release, env=env)
def build_gonk(self, jobs=None, verbose=False, release=False): target = "arm-linux-androideabi" self.ensure_bootstrapped(target=target) opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] opts += ["--target", self.config["android"]["target"]] env = self.build_env(gonk=True) build_start = time() with cd(path.join("ports", "gonk")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("Gonk build completed in %s" % str(datetime.timedelta(seconds=elapsed))) return ret
def run_cargo(self, params, geckolib=False, check=False): if geckolib: self.set_use_stable_rust() crate_dir = path.join('ports', 'geckolib') else: crate_dir = path.join('components', 'servo') self.ensure_bootstrapped() self.ensure_clobbered() env = self.build_env(geckolib=geckolib) if not params: params = [] if check: params = ['check'] + params build_start = time() if self.context.topdir == getcwd(): with cd(crate_dir): status = call(['cargo'] + params, env=env) else: status = call(['cargo'] + params, env=env) elapsed = time() - build_start notify_build_done(self.config, elapsed, status == 0) if check and status == 0: print('Finished checking, binary NOT updated. Consider ./mach build before ./mach run') return status
def update_submodules(self): # Ensure that the installed git version is >= 1.8.1 gitversion_output = subprocess.check_output(["git", "--version"]) gitversion = LooseVersion(gitversion_output.split(" ")[-1]) if gitversion < LooseVersion("1.8.1"): print("Git version 1.8.1 or above required. Current version is {}" .format(gitversion)) sys.exit(1) submodules = subprocess.check_output(["git", "submodule", "status"]) for line in submodules.split('\n'): components = line.strip().split(' ') if len(components) > 1: module_path = components[1] if path.exists(module_path): with cd(module_path): output = subprocess.check_output( ["git", "status", "--porcelain"]) if len(output) != 0: print("error: submodule %s is not clean" % module_path) print("\nClean the submodule and try again.") return 1 subprocess.check_call( ["git", "submodule", "--quiet", "sync", "--recursive"]) subprocess.check_call( ["git", "submodule", "update", "--init", "--recursive"])
def run_cargo(self, params, geckolib=False, check=False): if geckolib: self.set_use_stable_rust() crate_dir = path.join('ports', 'geckolib') else: crate_dir = path.join('components', 'servo') self.ensure_bootstrapped() self.ensure_clobbered() env = self.build_env(geckolib=geckolib) if not params: params = [] if check: params = ['check'] + params build_start = time() if self.context.topdir == getcwd(): with cd(crate_dir): status = call(['cargo'] + params, env=env) else: status = call(['cargo'] + params, env=env) elapsed = time() - build_start notify_build_done(self.config, elapsed, status == 0) if check and status == 0: print( 'Finished checking, binary NOT updated. Consider ./mach build before ./mach run' ) return status
def rustfmt(self, directory=""): if directory == "": directory = self.context.topdir with cd(self.context.topdir): return self.call_rustup_run(["cargo", "fmt", "--", directory], env=self.build_env())
def build_geckolib(self, jobs=None, verbose=False, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] env = self.build_env(is_build=True) env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") build_start = time() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("GeckoLib build completed in %s" % format_duration(elapsed)) return ret
def package(self, params, release=False, dev=False, debug=False, debugger=None): env = self.build_env() binary_path = self.get_binary_path(release, dev, android=True) if dev: env["NDK_DEBUG"] = "1" env["ANT_FLAVOR"] = "debug" dev_flag = "-d" else: env["ANT_FLAVOR"] = "release" dev_flag = "" target_dir = os.path.dirname(binary_path) output_apk = "{}.apk".format(binary_path) try: with cd(path.join("support", "android", "build-apk")): subprocess.check_call([ "cargo", "run", "--", dev_flag, "-o", output_apk, "-t", target_dir, "-r", self.get_top_dir() ], env=env) except subprocess.CalledProcessError as e: print("Packaging Android exited with return value %d" % e.returncode) return e.returncode
def build_gonk(self, jobs=None, verbose=False, release=False): target = "arm-linux-androideabi" self.ensure_bootstrapped(target=target) opts = [] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] opts += ["--target", self.config["android"]["target"]] env = self.build_env(gonk=True) build_start = time() with cd(path.join("ports", "gonk")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("Gonk build completed in %s" % format_duration(elapsed)) return ret
def cargo(self, params): if not params: params = [] if self.context.topdir == getcwd(): with cd(path.join('components', 'servo')): return call(["cargo"] + params, env=self.build_env()) return call(['cargo'] + params, env=self.build_env())
def cargo(self, params): if not params: params = [] if self.context.topdir == getcwd(): with cd(path.join("components", "servo")): return subprocess.call(["cargo"] + params, env=self.build_env()) return subprocess.call(["cargo"] + params, env=self.build_env())
def fetch(self): # Fetch Rust and Cargo self.ensure_bootstrapped() # Fetch Cargo dependencies for cargo_path in CARGO_PATHS: with cd(cargo_path): print(cargo_path) call(["cargo", "fetch"], env=self.build_env())
def clippy(self, package=None, json=False): params = ["--features=script/plugins/clippy"] if package: params += ["-p", package] if json: params += ["--", "-Zunstable-options", "--error-format", "json"] with cd(path.join(self.context.topdir, "components", "servo")): return subprocess.call(["cargo", "rustc", "-v"] + params, env=self.build_env())
def package(self, release=False, dev=False, android=None, debug=False, debugger=None): env = self.build_env() if android is None: android = self.config["build"]["android"] binary_path = self.get_binary_path(release, dev, android=android) if android: if dev: env["NDK_DEBUG"] = "1" env["ANT_FLAVOR"] = "debug" dev_flag = "-d" else: env["ANT_FLAVOR"] = "release" dev_flag = "" target_dir = os.path.dirname(binary_path) output_apk = "{}.apk".format(binary_path) try: with cd(path.join("support", "android", "build-apk")): subprocess.check_call(["cargo", "run", "--", dev_flag, "-o", output_apk, "-t", target_dir, "-r", self.get_top_dir()], env=env) except subprocess.CalledProcessError as e: print("Packaging Android exited with return value %d" % e.returncode) return e.returncode else: dir_to_package = '/'.join(binary_path.split('/')[:-1]) browserhtml_path = find_dep_path_newest('browserhtml', binary_path) if browserhtml_path is None: print("Could not find browserhtml package; perhaps you haven't built Servo.") return 1 print("Deleting unused files") keep = ['servo', 'resources', 'build'] for f in os.listdir(dir_to_package + '/'): if f not in keep: delete(dir_to_package + '/' + f) for f in os.listdir(dir_to_package + '/build/'): if 'browserhtml' not in f: delete(dir_to_package + '/build/' + f) print("Writing runservo.sh") # TODO: deduplicate this arg list from post_build_commands servo_args = ['-w', '-b', '--pref', 'dom.mozbrowser.enabled', '--pref', 'dom.forcetouch.enabled', '--pref', 'shell.quit-on-escape.enabled=false', path.join(browserhtml_path, 'out', 'index.html')] runservo = os.open(dir_to_package + 'runservo.sh', os.O_WRONLY | os.O_CREAT, int("0755", 8)) os.write(runservo, "./servo " + ' '.join(servo_args)) os.close(runservo) print("Creating tarball") tar_path = '/'.join(dir_to_package.split('/')[:-1]) + '/' tar_path += datetime.utcnow().replace(microsecond=0).isoformat() tar_path += "-servo-tech-demo.tar.gz" with tarfile.open(tar_path, "w:gz") as tar: # arcname is to add by relative rather than absolute path tar.add(dir_to_package, arcname='servo/') print("Packaged Servo into " + tar_path)
def test_stylo(self): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env() env["RUST_BACKTRACE"] = "1" env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") with cd(path.join("ports", "geckolib")): return call(["cargo", "test", "-p", "stylo_tests"], env=env)
def find_dep_path_newest(package, bin_path): deps_path = path.join(path.split(bin_path)[0], "build") with cd(deps_path): print(os.getcwd()) candidates = glob(package + '-*') candidates = (path.join(deps_path, c) for c in candidates) candidate_times = sorted(((path.getmtime(c), c) for c in candidates), reverse=True) if len(candidate_times) > 0: return candidate_times[0][1] return None
def update_cargo(self, params): cargo_paths = [path.join('.'), path.join('ports', 'cef'), path.join('ports', 'android', 'glut_app')] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def clippy(self, package=None, json=False): params = ["--features=clippy"] if package: params += ["-p", package] if json: params += ["--", "-Zunstable-options", "--error-format", "json"] with cd(path.join(self.context.topdir, "components", "servo")): return subprocess.call(["cargo", "rustc", "-v"] + params, env=self.build_env())
def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env(is_build=True) geckolib_build_path = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") env["CARGO_TARGET_DIR"] = geckolib_build_path ret = None opts = [] if with_gecko is not None: opts += ["--features", "bindgen"] env["MOZ_DIST"] = path.abspath(with_gecko) if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] if with_gecko is not None: print("Generating atoms data...") run_file = path.join(self.context.topdir, "components", "style", "binding_tools", "regen_atoms.py") run_globals = {"__file__": run_file} execfile(run_file, run_globals) run_globals["generate_atoms"](env["MOZ_DIST"]) build_start = time() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) print("GeckoLib build completed in %s" % format_duration(elapsed)) if with_gecko is not None and ret == 0: print("Copying binding files to style/gecko_bindings...") build_path = path.join(geckolib_build_path, "release" if release else "debug", "") target_style_path = find_dep_path_newest("style", build_path) out_gecko_path = path.join(target_style_path, "out", "gecko") bindings_path = path.join(self.context.topdir, "components", "style", "gecko_bindings") for f in ["bindings.rs", "structs_debug.rs", "structs_release.rs"]: shutil.copy(path.join(out_gecko_path, f), bindings_path) return ret
def test_stylo(self, release=False, test_name=None): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env() env["RUST_BACKTRACE"] = "1" env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") args = (["cargo", "test", "-p", "stylo_tests", "--features", "testing"] + (["--release"] if release else []) + (test_name or [])) with cd(path.join("ports", "geckolib")): return call(args, env=env)
def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env(is_build=True, geckolib=True) geckolib_build_path = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") ret = None opts = [] features = [] if with_gecko is not None: features += ["bindgen"] env["MOZ_DIST"] = path.abspath(path.expanduser(with_gecko)) if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] if release: opts += ["--release"] else: features += ["gecko_debug"] if features: opts += ["--features", ' '.join(features)] if with_gecko is not None: print("Generating atoms data...") run_file = path.join(self.context.topdir, "components", "style", "binding_tools", "regen_atoms.py") run_globals = {"__file__": run_file} execfile(run_file, run_globals) run_globals["generate_atoms"](env["MOZ_DIST"]) build_start = time() with cd(path.join("ports", "geckolib")): ret = call(["cargo", "build"] + opts, env=env, verbose=verbose) elapsed = time() - build_start # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(self.config, elapsed) print("GeckoLib build completed in %s" % format_duration(elapsed)) if with_gecko is not None: print("Copying binding files to style/gecko_bindings...") build_path = path.join(geckolib_build_path, "release" if release else "debug", "") target_style_path = find_dep_path_newest("style", build_path) out_gecko_path = path.join(target_style_path, "out", "gecko") bindings_path = path.join(self.context.topdir, "components", "style", "gecko_bindings") for f in ["bindings.rs", "structs_debug.rs", "structs_release.rs"]: shutil.copy(path.join(out_gecko_path, f), bindings_path) return ret
def update_cargo(self, params): cargo_paths = [ path.join('.'), path.join('ports', 'cef'), path.join('ports', 'android', 'glut_app') ] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def cargo_geckolib(self, params): if not params: params = [] self.set_use_stable_rust() self.ensure_bootstrapped() 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)
def upgrade_wpt_runner(self): with cd(path.join(self.context.topdir, 'tests', 'wpt', 'harness')): code = call(["git", "init"], env=self.build_env()) if code: return code call( ["git", "remote", "add", "upstream", "https://github.com/w3c/wptrunner.git"], env=self.build_env()) code = call(["git", "fetch", "upstream"], env=self.build_env()) if code: return code code = call(["git", "reset", '--', "hard", "remotes/upstream/master"], env=self.build_env()) if code: return code
def update_cargo(self, params=None): if not params: params = [] cargo_paths = [path.join('components', 'servo'), path.join('ports', 'cef'), path.join('ports', 'gonk')] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def test_stylo(self, release=False, test_name=None): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env() env["RUST_BACKTRACE"] = "1" env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") args = ( ["cargo", "test", "-p", "stylo_tests", "--features", "testing"] + (["--release"] if release else []) + (test_name or [])) with cd(path.join("ports", "geckolib")): return call(args, env=env)
def test_stylo(self): self.set_use_stable_rust() self.ensure_bootstrapped() env = self.build_env() env["RUST_BACKTRACE"] = "1" env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") with cd(path.join("ports", "geckolib")): result = call(["cargo", "test", "-p", "stylo_tests"], env=env) if result != 0: return result
def upgrade_wpt_runner(self): with cd(path.join(self.context.topdir, "tests", "wpt", "harness")): code = subprocess.call(["git", "init"], env=self.build_env()) if code: return code subprocess.call( ["git", "remote", "add", "upstream", "https://github.com/w3c/wptrunner.git"], env=self.build_env() ) code = subprocess.call(["git", "fetch", "upstream"], env=self.build_env()) if code: return code code = subprocess.call(["git", "reset", "--", "hard", "remotes/upstream/master"], env=self.build_env()) if code: return code
def update_submodules(self): submodules = subprocess.check_output(["git", "submodule", "status"]) for line in submodules.split('\n'): components = line.strip().split(' ') if len(components) > 1: module_path = components[1] if path.exists(module_path): with cd(module_path): output = subprocess.check_output(["git", "status", "--porcelain"]) if len(output) != 0: print("error: submodule %s is not clean" % module_path) print("\nClean the submodule and try again.") return 1 subprocess.check_call(["git", "submodule", "--quiet", "sync", "--recursive"]) subprocess.check_call(["git", "submodule", "update", "--init", "--recursive"])
def update_cargo(self, params=None): if not params: params = [] cargo_paths = [ path.join('components', 'servo'), path.join('ports', 'cef'), path.join('ports', 'gonk') ] for cargo_path in cargo_paths: with cd(cargo_path): print(cargo_path) subprocess.call(["cargo", "update"] + params, env=self.build_env())
def build(self, target=None, release=False, jobs=None, android=None, verbose=False, debug_mozjs=False): self.ensure_bootstrapped() if android is None: android = self.config["build"]["android"] opts = [] if release: opts += ["--release"] if target: opts += ["--target", target] if jobs is not None: opts += ["-j", jobs] if verbose: opts += ["-v"] features = [] if debug_mozjs or self.config["build"]["debug-mozjs"]: features += ["script/debugmozjs"] if features: opts += ["--features", "%s" % ' '.join(features)] build_start = time() env = self.build_env() if android: # Build OpenSSL for android with cd(self.android_support_dir()): status = subprocess.call( ["make", "-j4", "-f", "openssl.makefile"], env=self.build_env()) env['OPENSSL_PATH'] = path.join(self.android_support_dir(), "openssl-1.0.1j") make_opts = [] if opts: make_opts += ["CARGO_OPTS=" + " ".join(opts)] status = subprocess.call( ["make", "-C", "ports/android"] + make_opts, env=env) else: status = subprocess.call( ["cargo", "build"] + opts, env=env, cwd=self.servo_crate()) elapsed = time() - build_start print("Build completed in %0.2fs" % elapsed) return status
def build_cef(self, jobs=None): self.ensure_bootstrapped() ret = None opts = [] if jobs is not None: opts += ["-j", jobs] build_start = time() with cd(path.join("ports", "cef")): ret = subprocess.call(["cargo", "build"], env=self.build_env()) elapsed = time() - build_start print("CEF build completed in %0.2fs" % elapsed) return ret
def update_cargo(self, params=None, package=None, all_packages=None): if not params: params = [] if package: params += ["-p", package] elif all_packages: params = [] else: print("Please choose package to update with the --package (-p) ") print("flag or update all packages with --all-packages (-a) flag") sys.exit(1) self.ensure_bootstrapped() with cd(self.context.topdir): call(["cargo", "update"] + params, env=self.build_env())
def update_cargo(self, params=None, package=None, all_packages=None): if not params: params = [] if package: params += ["-p", package] elif all_packages: params = [] else: print("Please choose package to update with the --package (-p) ") print("flag or update all packages with --all-packages (-a) flag") sys.exit(1) for cargo_path in CARGO_PATHS: with cd(cargo_path): print(cargo_path) call(["cargo", "update"] + params, env=self.build_env())