Commit 2cc73baa authored by brizental's avatar brizental
Browse files

TB 43564: Modify ./mach bootstrap for Tor Browser

parent fa88381a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -226,7 +226,9 @@ def bootstrap_path(path, **kwargs):
                log.info("no path found in tbb/out for %s", artifact)
                return False

            artifact_index = mozbuild.tbbutils.get_artifact_index(artifact_path)
            artifact_index = mozbuild.tbbutils.get_artifact_index(
                artifact_path, artifact
            )
            index_file = os.path.join(toolchains_base_dir, "indices", artifact)
            try:
                with open(index_file) as fh:
+37 −0
Original line number Diff line number Diff line
option(
    "--with-tor-expert-bundle",
    env="TOR_EXPERT_BUNDLE",
    nargs=1,
    default=None,
    help="Path to location of tor-expert-bundle directory.",
)


@depends(
    "--with-tor-expert-bundle",
    mozbuild_state_path,
    bootstrap_path(
        "tor-expert-bundle",
        when=depends("--with-tor-expert-bundle")(lambda x: not x) & is_desktop_build,
    ),
)
@checking("for tor-expert-bundle")
@imports(_from="pathlib", _import="Path")
def tor_expert_bundle(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-expert-bundle must point to a real directory.")

    bootstrapped_location = Path(mozbuild_state_path) / "tor-expert-bundle"
    if bootstrapped_location.is_dir():
        return str(bootstrapped_location)

    # tor-expert-bundle is not required for building.
    return None


set_config("TOR_EXPERT_BUNDLE", tor_expert_bundle)
+1 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ def check_prog(*args, **kwargs):

include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
include("build/moz.configure/basebrowser-resources.configure")
include("build/moz.configure/torbrowser-resources.configure")

include("build/moz.configure/pkg.configure")
include("build/moz.configure/memory.configure", when="--enable-compile-environment")
+7 −7
Original line number Diff line number Diff line
@@ -50,27 +50,27 @@ Artifact builds download prebuilt C++ components rather than building
them locally. Artifact builds are faster!

Artifact builds are recommended for people working on Tor Browser or
Base Browser for Android frontends, or the GeckoView Java API. They are unsuitable
Tor 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.

# Note to Base Browser developers
# Note to Tor Browser developers

This is still highly experimental. Expect bugs!

Please choose the version of Base Browser you want to build (see note above):
Please choose the version of Tor Browser you want to build (see note above):
%s
Your choice: """

APPLICATIONS = OrderedDict(
    [
        ("Base Browser for Desktop Artifact Mode", "browser_artifact_mode"),
        ("Base Browser for Desktop", "browser"),
        ("Tor Browser for Desktop Artifact Mode", "browser_artifact_mode"),
        ("Tor Browser for Desktop", "browser"),
        (
            "GeckoView/Base Browser for Android Artifact Mode",
            "GeckoView/Tor Browser for Android Artifact Mode",
            "mobile_android_artifact_mode",
        ),
        ("GeckoView/Base Browser for Android", "mobile_android"),
        ("GeckoView/Tor Browser for Android", "mobile_android"),
        ("SpiderMonkey JavaScript engine", "js"),
    ]
)
+62 −0
Original line number Diff line number Diff line
@@ -268,12 +268,16 @@ class BuildBackend(LoggingMixin):
                paths = {
                    "docs": tbdir / "Contents/Resources/TorBrowser/Docs",
                    "exts": tbdir / "Contents/Resources/distribution/extensions",
                    "tor_bin": tbdir / "Contents/MacOS/tor",
                    "tor_config": tbdir / "Contents/Resources/TorBrowser/Tor",
                    "fonts": tbdir / "Resources/fonts",
                }
            else:
                paths = {
                    "docs": tbdir / "TorBrowser/Docs",
                    "exts": tbdir / "distribution/extensions",
                    "tor_bin": tbdir / "TorBrowser/Tor",
                    "tor_config": tbdir / "TorBrowser/Data/Tor",
                    "fonts": tbdir / "fonts",
                }

@@ -309,6 +313,64 @@ class BuildBackend(LoggingMixin):
                paths["exts"].mkdir(parents=True, exist_ok=True)
                _infallible_symlink(noscript_location, noscript_target)

            expert_bundle_location = config.substs.get("TOR_EXPERT_BUNDLE")
            if expert_bundle_location:
                expert_bundle_location = Path(expert_bundle_location)
                if not expert_bundle_location.is_dir():
                    return

                self.log(
                    logging.INFO,
                    "_setup_tor_browser_environment",
                    {
                        "expert_bundle_location": str(expert_bundle_location),
                    },
                    "Setting up tor-expert-bundle resources from {expert_bundle_location}",
                )

                # Set up Tor configuration files
                paths["tor_config"].mkdir(parents=True, exist_ok=True)
                for file in ["geoip", "geoip6", "torrc-defaults"]:
                    target = paths["tor_config"] / file
                    _infallible_symlink(expert_bundle_location / "data" / file, target)

                # Set up Conjure documentation
                conjust_docs_location = paths["docs"] / "conjure"
                conjust_docs_location.mkdir(parents=True, exist_ok=True)
                conjure_readme = conjust_docs_location / "README.CONJURE.md"
                _infallible_symlink(
                    expert_bundle_location
                    / "tor/pluggable_transports/README.CONJURE.md",
                    conjure_readme,
                )

                # Set up pluggable transports
                paths["tor_bin"].mkdir(parents=True, exist_ok=True)
                pluggable_transports_location = (
                    expert_bundle_location / "tor/pluggable_transports"
                )
                pluggable_transports_target = paths["tor_bin"] / "PluggableTransports"
                pluggable_transports_target.mkdir(parents=True, exist_ok=True)
                for file in pluggable_transports_location.iterdir():
                    # We only want the PT executables.
                    if os.access(file, os.X_OK) or file.suffix.lower() == ".exe":
                        target = pluggable_transports_target / file.name
                        _infallible_symlink(file, target)

                # Setup Tor binary
                for item in Path(expert_bundle_location / "tor").iterdir():
                    target = paths["tor_bin"] / item.name

                    if item.is_file():
                        _infallible_symlink(item, target)

                # Set up licenses
                licenses_location = paths["docs"] / "Licenses"
                licenses_location.mkdir(parents=True, exist_ok=True)
                for item in (expert_bundle_location / "docs").iterdir():
                    target = licenses_location / item.name
                    _infallible_symlink(item, target)

    def post_build(self, config, output, jobs, verbose, status):
        """Called late during 'mach build' execution, after `build(...)` has finished.

Loading