Loading build/moz.configure/basebrowser-resources.configure 0 → 100644 +88 −0 Original line number Diff line number Diff line # Helpers # ------------------------------------------------- @depends(build_project) def is_desktop_build(build_project): return build_project == "browser" # Bootstrap resources # ------------------------------------------------- option( "--with-noscript", env="NOSCRIPT", nargs=1, default=None, help="Path to noscript .xpi extension archive.", ) @depends( "--with-noscript", mozbuild_state_path, bootstrap_path( "noscript", no_unpack=True, when=depends("--with-noscript")(lambda x: not x) ), ) @checking("for noscript") @imports(_from="pathlib", _import="Path") def noscript(value, mozbuild_state_path, _bootstrapped): if value: path = Path(value[0]) if path.is_file() and path.suffix == ".xpi": return value[0] else: die("--with-noscript must be an existing .xpi file") bootstrapped_location = Path(mozbuild_state_path) / "browser" for file in bootstrapped_location.glob(f"*.xpi"): if "noscript" in file.name: return str(bootstrapped_location / file) # noscript is not required for building. return None set_config("NOSCRIPT", noscript) option( "--with-tor-browser-fonts", env="TOR_BROWSER_FONTS", nargs=1, default=None, help="Path to location of fonts directory.", ) @depends( "--with-tor-browser-fonts", mozbuild_state_path, bootstrap_path( "fonts", when=depends("--with-tor-browser-fonts")(lambda x: not x) & is_desktop_build, ), ) @checking("for tor-browser fonts directory") @imports(_from="pathlib", _import="Path") def tor_browser_fonts(value, mozbuild_state_path, _bootstrapped): if value: path = Path(value[0]) # TODO: Do a more thorough check on the directory. if path.is_dir(): return value[0] else: die("--with-tor-browser-fonts must point to a real directory.") bootstrapped_location = Path(mozbuild_state_path) / "fonts" if bootstrapped_location.is_dir(): return str(bootstrapped_location) # tor browser fonts directory is not required for building. return None set_config("TOR_BROWSER_FONTS", tor_browser_fonts) build/moz.configure/bootstrap.configure +111 −4 Original line number Diff line number Diff line Loading @@ -4,6 +4,29 @@ # 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/. option( "--with-tor-browser-build-out", env="TOR_BROWSER_BUILD_OUT", nargs=1, default="https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out", help="URL pointing to a Tor Browser Build out folder, served over HTTP[S].", ) @depends("--with-tor-browser-build-out") def tor_browser_build_out(value): if value: return value[0] option( "--enable-tor-browser-build-only-bootstrap", env="TBB_ONLY_BOOTSTRAP", default=False, help="Flag that disables bootstrapping any artifact from Mozilla's Taskcluster. Will only bootstrap artifacts from tor-browser-build.", ) option( env="MOZ_FETCHES_DIR", nargs=1, Loading Loading @@ -115,9 +138,10 @@ def bootstrap_toolchain_tasks(host): def bootstrap_path(path, **kwargs): when = kwargs.pop("when", None) allow_failure = kwargs.pop("allow_failure", None) no_unpack = kwargs.pop("no_unpack", False) if kwargs: configure_error( "bootstrap_path only takes `when` and `allow_failure` as a keyword argument" "bootstrap_path only takes `when`, `allow_failure` and `no_unpack` as keyword arguments" ) @depends( Loading @@ -129,11 +153,16 @@ def bootstrap_path(path, **kwargs): build_environment, dependable(path), dependable(allow_failure), dependable(no_unpack), tor_browser_build_out, "--enable-tor-browser-build-only-bootstrap", target, when=when, ) @imports("os") @imports("subprocess") @imports("sys") @imports("mozbuild.tbbutils") @imports(_from="mozbuild.dirutils", _import="ensureParentDir") @imports(_from="importlib", _import="import_module") @imports(_from="shutil", _import="rmtree") Loading @@ -148,6 +177,10 @@ def bootstrap_path(path, **kwargs): build_env, path, allow_failure, no_unpack, tor_browser_build_out, tbb_only_bootstrap, target, ): if not path: return Loading @@ -158,6 +191,79 @@ def bootstrap_path(path, **kwargs): if path_parts[0] == "clang-tools": path_prefix = path_parts.pop(0) # Small hack because noscript is inside the browser folder. if path_parts[0] == "noscript": path_prefix = "browser" def try_tbb_bootstrap(exists): if not tor_browser_build_out: return False # Tor browser build doesn't have artifacts for all targets supported # by the Firefox build system. When this is empty it means we are # building for a platform which tbb doesn't support. if not target.tor_browser_build_alias: return False artifact = mozbuild.tbbutils.get_artifact_name(path_parts[0], tasks.prefix) if not artifact: log.info("%s is not mapped to a tbb artifact", path_parts[0]) return False artifact_path = mozbuild.tbbutils.get_artifact_path( tor_browser_build_out, artifact, target, prefix=path_prefix, log=log.warning, ) if not artifact_path: log.info("no path found in tbb/out for %s", artifact) return False artifact_index = mozbuild.tbbutils.get_artifact_index(artifact_path) index_file = os.path.join(toolchains_base_dir, "indices", artifact) try: with open(index_file) as fh: index = fh.read().strip() except Exception: index = None if index == artifact_index and exists: log.debug("%s is up-to-date", artifact) return True command = ["artifact", "toolchain", "--from-url", artifact_path] if no_unpack: command.append("--no-unpack") # Note to rebasers: # From here on, it's a slightly modified copy/paste # from the end of the try_bootstrap function log.info( "%s bootstrapped toolchain from TBB in %s", "Updating" if exists else "Installing", os.path.join(toolchains_base_dir, path_prefix, artifact), ) os.makedirs(os.path.join(toolchains_base_dir, path_prefix), exist_ok=True) proc = subprocess.run( [ sys.executable, os.path.join(build_env.topsrcdir, "mach"), "--log-no-times", ] + command, cwd=os.path.join(toolchains_base_dir, path_prefix), check=not allow_failure, ) if proc.returncode != 0 and allow_failure: return False ensureParentDir(index_file) with open(index_file, "w") as fh: fh.write(artifact_index) return True def try_bootstrap(exists): if not tasks: return False Loading Loading @@ -280,9 +386,10 @@ def bootstrap_path(path, **kwargs): try: # With --enable-bootstrap=no-update, we don't `try_bootstrap`, except # when the toolchain can't be found. if ( "no-update" not in enable_bootstrap or not exists ) and not try_bootstrap(exists): if ("no-update" not in enable_bootstrap or not exists) and not ( try_tbb_bootstrap(exists) or (not tbb_only_bootstrap and try_bootstrap(exists)) ): # If there aren't toolchain artifacts to use for this build, # don't return a path. return None Loading build/moz.configure/init.configure +16 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,21 @@ def split_triplet(triplet, allow_wasi=False): else: toolchain = "%s-%s" % (cpu, os) # In tor-browser-build we use slightly different terminology for # the supported platforms. Let's prepare that OS string here. # # Not all possible platforms listed here are supported in tbb, # so this value will be empty sometimes. tor_browser_build_alias = None if canonical_os == "Android" and canonical_kernel == "Linux": tor_browser_build_alias = f"android" elif canonical_os == "GNU" and canonical_kernel == "Linux": tor_browser_build_alias = f"linux" elif canonical_os == "OSX" and canonical_kernel == "Darwin": tor_browser_build_alias = f"macos" elif canonical_os == "WINNT" and canonical_kernel == "WINNT": tor_browser_build_alias = f"windows" return namespace( alias=triplet, cpu=CPU(canonical_cpu), Loading @@ -600,6 +615,7 @@ def split_triplet(triplet, allow_wasi=False): toolchain=toolchain, vendor=vendor, sub_configure_alias=sub_configure_alias, tor_browser_build_alias=tor_browser_build_alias, ) Loading moz.configure +1 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ check_prog("WGET", ("wget",), allow_missing=True) include("build/moz.configure/toolchain.configure", when="--enable-compile-environment") include("build/moz.configure/basebrowser-resources.configure") include("build/moz.configure/pkg.configure") include("build/moz.configure/memory.configure", when="--enable-compile-environment") Loading python/mozboot/mozboot/bootstrap.py +17 −9 Original line number Diff line number Diff line Loading @@ -52,21 +52,28 @@ Note on Artifact Mode: Artifact builds download prebuilt C++ components rather than building them locally. Artifact builds are faster! Artifact builds are recommended for people working on Firefox or Firefox for Android frontends, or the GeckoView Java API. They are unsuitable Artifact builds are recommended for people working on Tor Browser or Base Browser for Android frontends, or the GeckoView Java API. They are unsuitable for those working on C++ code. For more information see: https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html. Please choose the version of Firefox you want to build (see note above): # Note to Base Browser developers This is still highly experimental. Expect bugs! Please choose the version of Base Browser you want to build (see note above): %s Your choice: """ APPLICATIONS = OrderedDict( [ ("Firefox for Desktop Artifact Mode", "browser_artifact_mode"), ("Firefox for Desktop", "browser"), ("GeckoView/Firefox for Android Artifact Mode", "mobile_android_artifact_mode"), ("GeckoView/Firefox for Android", "mobile_android"), ("Base Browser for Desktop Artifact Mode", "browser_artifact_mode"), ("Base Browser for Desktop", "browser"), ( "GeckoView/Base Browser for Android Artifact Mode", "mobile_android_artifact_mode", ), ("GeckoView/Base Browser for Android", "mobile_android"), ("SpiderMonkey JavaScript engine", "js"), ] ) Loading Loading @@ -360,6 +367,8 @@ class Bootstrapper: getattr(self.instance, "ensure_%s_packages" % application)() def check_code_submission(self, checkout_root: Path): return if self.instance.no_interactive or which("moz-phab"): return Loading Loading @@ -474,8 +483,7 @@ class Bootstrapper: configure_mercurial(hg, state_dir) # Offer to configure Git, if the current checkout or repo type is Git. elif git and checkout_type == "git": should_configure_git = False elif False and git and checkout_type == "git": if not self.instance.no_interactive: should_configure_git = self.instance.prompt_yesno(prompt=CONFIGURE_GIT) else: Loading Loading
build/moz.configure/basebrowser-resources.configure 0 → 100644 +88 −0 Original line number Diff line number Diff line # Helpers # ------------------------------------------------- @depends(build_project) def is_desktop_build(build_project): return build_project == "browser" # Bootstrap resources # ------------------------------------------------- option( "--with-noscript", env="NOSCRIPT", nargs=1, default=None, help="Path to noscript .xpi extension archive.", ) @depends( "--with-noscript", mozbuild_state_path, bootstrap_path( "noscript", no_unpack=True, when=depends("--with-noscript")(lambda x: not x) ), ) @checking("for noscript") @imports(_from="pathlib", _import="Path") def noscript(value, mozbuild_state_path, _bootstrapped): if value: path = Path(value[0]) if path.is_file() and path.suffix == ".xpi": return value[0] else: die("--with-noscript must be an existing .xpi file") bootstrapped_location = Path(mozbuild_state_path) / "browser" for file in bootstrapped_location.glob(f"*.xpi"): if "noscript" in file.name: return str(bootstrapped_location / file) # noscript is not required for building. return None set_config("NOSCRIPT", noscript) option( "--with-tor-browser-fonts", env="TOR_BROWSER_FONTS", nargs=1, default=None, help="Path to location of fonts directory.", ) @depends( "--with-tor-browser-fonts", mozbuild_state_path, bootstrap_path( "fonts", when=depends("--with-tor-browser-fonts")(lambda x: not x) & is_desktop_build, ), ) @checking("for tor-browser fonts directory") @imports(_from="pathlib", _import="Path") def tor_browser_fonts(value, mozbuild_state_path, _bootstrapped): if value: path = Path(value[0]) # TODO: Do a more thorough check on the directory. if path.is_dir(): return value[0] else: die("--with-tor-browser-fonts must point to a real directory.") bootstrapped_location = Path(mozbuild_state_path) / "fonts" if bootstrapped_location.is_dir(): return str(bootstrapped_location) # tor browser fonts directory is not required for building. return None set_config("TOR_BROWSER_FONTS", tor_browser_fonts)
build/moz.configure/bootstrap.configure +111 −4 Original line number Diff line number Diff line Loading @@ -4,6 +4,29 @@ # 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/. option( "--with-tor-browser-build-out", env="TOR_BROWSER_BUILD_OUT", nargs=1, default="https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out", help="URL pointing to a Tor Browser Build out folder, served over HTTP[S].", ) @depends("--with-tor-browser-build-out") def tor_browser_build_out(value): if value: return value[0] option( "--enable-tor-browser-build-only-bootstrap", env="TBB_ONLY_BOOTSTRAP", default=False, help="Flag that disables bootstrapping any artifact from Mozilla's Taskcluster. Will only bootstrap artifacts from tor-browser-build.", ) option( env="MOZ_FETCHES_DIR", nargs=1, Loading Loading @@ -115,9 +138,10 @@ def bootstrap_toolchain_tasks(host): def bootstrap_path(path, **kwargs): when = kwargs.pop("when", None) allow_failure = kwargs.pop("allow_failure", None) no_unpack = kwargs.pop("no_unpack", False) if kwargs: configure_error( "bootstrap_path only takes `when` and `allow_failure` as a keyword argument" "bootstrap_path only takes `when`, `allow_failure` and `no_unpack` as keyword arguments" ) @depends( Loading @@ -129,11 +153,16 @@ def bootstrap_path(path, **kwargs): build_environment, dependable(path), dependable(allow_failure), dependable(no_unpack), tor_browser_build_out, "--enable-tor-browser-build-only-bootstrap", target, when=when, ) @imports("os") @imports("subprocess") @imports("sys") @imports("mozbuild.tbbutils") @imports(_from="mozbuild.dirutils", _import="ensureParentDir") @imports(_from="importlib", _import="import_module") @imports(_from="shutil", _import="rmtree") Loading @@ -148,6 +177,10 @@ def bootstrap_path(path, **kwargs): build_env, path, allow_failure, no_unpack, tor_browser_build_out, tbb_only_bootstrap, target, ): if not path: return Loading @@ -158,6 +191,79 @@ def bootstrap_path(path, **kwargs): if path_parts[0] == "clang-tools": path_prefix = path_parts.pop(0) # Small hack because noscript is inside the browser folder. if path_parts[0] == "noscript": path_prefix = "browser" def try_tbb_bootstrap(exists): if not tor_browser_build_out: return False # Tor browser build doesn't have artifacts for all targets supported # by the Firefox build system. When this is empty it means we are # building for a platform which tbb doesn't support. if not target.tor_browser_build_alias: return False artifact = mozbuild.tbbutils.get_artifact_name(path_parts[0], tasks.prefix) if not artifact: log.info("%s is not mapped to a tbb artifact", path_parts[0]) return False artifact_path = mozbuild.tbbutils.get_artifact_path( tor_browser_build_out, artifact, target, prefix=path_prefix, log=log.warning, ) if not artifact_path: log.info("no path found in tbb/out for %s", artifact) return False artifact_index = mozbuild.tbbutils.get_artifact_index(artifact_path) index_file = os.path.join(toolchains_base_dir, "indices", artifact) try: with open(index_file) as fh: index = fh.read().strip() except Exception: index = None if index == artifact_index and exists: log.debug("%s is up-to-date", artifact) return True command = ["artifact", "toolchain", "--from-url", artifact_path] if no_unpack: command.append("--no-unpack") # Note to rebasers: # From here on, it's a slightly modified copy/paste # from the end of the try_bootstrap function log.info( "%s bootstrapped toolchain from TBB in %s", "Updating" if exists else "Installing", os.path.join(toolchains_base_dir, path_prefix, artifact), ) os.makedirs(os.path.join(toolchains_base_dir, path_prefix), exist_ok=True) proc = subprocess.run( [ sys.executable, os.path.join(build_env.topsrcdir, "mach"), "--log-no-times", ] + command, cwd=os.path.join(toolchains_base_dir, path_prefix), check=not allow_failure, ) if proc.returncode != 0 and allow_failure: return False ensureParentDir(index_file) with open(index_file, "w") as fh: fh.write(artifact_index) return True def try_bootstrap(exists): if not tasks: return False Loading Loading @@ -280,9 +386,10 @@ def bootstrap_path(path, **kwargs): try: # With --enable-bootstrap=no-update, we don't `try_bootstrap`, except # when the toolchain can't be found. if ( "no-update" not in enable_bootstrap or not exists ) and not try_bootstrap(exists): if ("no-update" not in enable_bootstrap or not exists) and not ( try_tbb_bootstrap(exists) or (not tbb_only_bootstrap and try_bootstrap(exists)) ): # If there aren't toolchain artifacts to use for this build, # don't return a path. return None Loading
build/moz.configure/init.configure +16 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,21 @@ def split_triplet(triplet, allow_wasi=False): else: toolchain = "%s-%s" % (cpu, os) # In tor-browser-build we use slightly different terminology for # the supported platforms. Let's prepare that OS string here. # # Not all possible platforms listed here are supported in tbb, # so this value will be empty sometimes. tor_browser_build_alias = None if canonical_os == "Android" and canonical_kernel == "Linux": tor_browser_build_alias = f"android" elif canonical_os == "GNU" and canonical_kernel == "Linux": tor_browser_build_alias = f"linux" elif canonical_os == "OSX" and canonical_kernel == "Darwin": tor_browser_build_alias = f"macos" elif canonical_os == "WINNT" and canonical_kernel == "WINNT": tor_browser_build_alias = f"windows" return namespace( alias=triplet, cpu=CPU(canonical_cpu), Loading @@ -600,6 +615,7 @@ def split_triplet(triplet, allow_wasi=False): toolchain=toolchain, vendor=vendor, sub_configure_alias=sub_configure_alias, tor_browser_build_alias=tor_browser_build_alias, ) Loading
moz.configure +1 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ check_prog("WGET", ("wget",), allow_missing=True) include("build/moz.configure/toolchain.configure", when="--enable-compile-environment") include("build/moz.configure/basebrowser-resources.configure") include("build/moz.configure/pkg.configure") include("build/moz.configure/memory.configure", when="--enable-compile-environment") Loading
python/mozboot/mozboot/bootstrap.py +17 −9 Original line number Diff line number Diff line Loading @@ -52,21 +52,28 @@ Note on Artifact Mode: Artifact builds download prebuilt C++ components rather than building them locally. Artifact builds are faster! Artifact builds are recommended for people working on Firefox or Firefox for Android frontends, or the GeckoView Java API. They are unsuitable Artifact builds are recommended for people working on Tor Browser or Base Browser for Android frontends, or the GeckoView Java API. They are unsuitable for those working on C++ code. For more information see: https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html. Please choose the version of Firefox you want to build (see note above): # Note to Base Browser developers This is still highly experimental. Expect bugs! Please choose the version of Base Browser you want to build (see note above): %s Your choice: """ APPLICATIONS = OrderedDict( [ ("Firefox for Desktop Artifact Mode", "browser_artifact_mode"), ("Firefox for Desktop", "browser"), ("GeckoView/Firefox for Android Artifact Mode", "mobile_android_artifact_mode"), ("GeckoView/Firefox for Android", "mobile_android"), ("Base Browser for Desktop Artifact Mode", "browser_artifact_mode"), ("Base Browser for Desktop", "browser"), ( "GeckoView/Base Browser for Android Artifact Mode", "mobile_android_artifact_mode", ), ("GeckoView/Base Browser for Android", "mobile_android"), ("SpiderMonkey JavaScript engine", "js"), ] ) Loading Loading @@ -360,6 +367,8 @@ class Bootstrapper: getattr(self.instance, "ensure_%s_packages" % application)() def check_code_submission(self, checkout_root: Path): return if self.instance.no_interactive or which("moz-phab"): return Loading Loading @@ -474,8 +483,7 @@ class Bootstrapper: configure_mercurial(hg, state_dir) # Offer to configure Git, if the current checkout or repo type is Git. elif git and checkout_type == "git": should_configure_git = False elif False and git and checkout_type == "git": if not self.instance.no_interactive: should_configure_git = self.instance.prompt_yesno(prompt=CONFIGURE_GIT) else: Loading