Commit d3c6d733 authored by brizental's avatar brizental
Browse files

MB 43564: Modify ./mach bootstrap for Mullvad Browser

parent e913cc4c
Loading
Loading
Loading
Loading
Loading
+78 −0
Original line number Diff line number Diff line
@@ -49,6 +49,84 @@ def noscript(value, mozbuild_state_path, _bootstrapped):
set_config("NOSCRIPT", noscript)


option(
    "--with-ublock",
    env="UBLOCK",
    nargs=1,
    default=None,
    help="Path to ublock .xpi extension archive.",
)


@depends(
    "--with-ublock",
    mozbuild_state_path,
    bootstrap_path(
        "ublock", no_unpack=True, when=depends("--with-ublock")(lambda x: not x)
    ),
)
@checking("for ublock extension")
@imports(_from="pathlib", _import="Path")
def ublock(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-ublock must be an existing .xpi file")

    bootstrapped_location = Path(mozbuild_state_path) / "browser"
    for file in bootstrapped_location.glob(f"*.xpi"):
        if "ublock" in file.name:
            return str(bootstrapped_location / file)

    # ublock is not required for building.
    return None


set_config("UBLOCK", ublock)


option(
    "--with-mullvad-extension",
    env="MULLVAD_EXTENSION",
    nargs=1,
    default=None,
    help="Path to mullvad extension .xpi extension archive.",
)


@depends(
    "--with-mullvad-extension",
    mozbuild_state_path,
    bootstrap_path(
        "mullvad-browser-extension",
        no_unpack=True,
        when=depends("--with-mullvad-extension")(lambda x: not x),
    ),
)
@checking("for mullvad extension")
@imports(_from="pathlib", _import="Path")
def mullvad_extension(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-mullvad-extension must be an existing .xpi file")

    bootstrapped_location = Path(mozbuild_state_path) / "browser"
    for file in bootstrapped_location.glob(f"*.xpi"):
        if "mullvad-browser-extension" in file.name:
            return str(bootstrapped_location / file)

    # mullvad extension is not required for building.
    return None


set_config("MULLVAD_EXTENSION", mullvad_extension)


option(
    "--with-tor-browser-fonts",
    env="TOR_BROWSER_FONTS",
+5 −1
Original line number Diff line number Diff line
@@ -198,7 +198,11 @@ def bootstrap_path(path, **kwargs):
            path_prefix = path_parts.pop(0)

        # Small hack because extensions are inside the browser folder.
        if path_parts[0] in ("noscript", ):
        if path_parts[0] in (
            "noscript",
            "ublock",
            "mullvad-browser-extension",
        ):
            path_prefix = "browser"

        def try_tbb_bootstrap(exists):
+7 −7
Original line number Diff line number Diff line
@@ -49,28 +49,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 Tor Browser or
Artifact builds are recommended for people working on Mullvad 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.

# Note to Base Browser developers
# Note to Mullvad 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 Mullvad 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"),
        ("Mullvad Browser for Desktop Artifact Mode", "browser_artifact_mode"),
        ("Mullvad Browser for Desktop", "browser"),
        (
            "GeckoView/Base Browser for Android Artifact Mode",
            "GeckoView/Mullvad Browser for Android Artifact Mode",
            "mobile_android_artifact_mode",
        ),
        ("GeckoView/Base Browser for Android", "mobile_android"),
        ("GeckoView/Mullvad Browser for Android", "mobile_android"),
        ("SpiderMonkey JavaScript engine", "js"),
    ]
)
+18 −0
Original line number Diff line number Diff line
@@ -279,6 +279,12 @@ class BuildBackend(LoggingMixin):
        noscript_target_filename = "{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
        noscript_location = config.substs.get("NOSCRIPT")

        ublock_target_filename = "uBlock0@raymondhill.net.xpi"
        ublock_location = config.substs.get("UBLOCK")

        mullvad_extension_target_filename = "{d19a89b9-76c1-4a61-bcd4-49e8de916403}.xpi"
        mullvad_extension_location = config.substs.get("MULLVAD_EXTENSION")

        if app == "browser":
            tbdir = Path(config.topobjdir) / "dist" / "bin"

@@ -318,6 +324,18 @@ class BuildBackend(LoggingMixin):
                paths["exts"],
            )

            self._setup_extension_symlink(
                ublock_location,
                ublock_target_filename,
                paths["exts"],
            )

            self._setup_extension_symlink(
                mullvad_extension_location,
                mullvad_extension_target_filename,
                paths["exts"],
            )

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

+5 −3
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ def list_files_http(url):
    return links


TOR_BROWSER_BUILD_ARTIFACTS = [
    # Tor Browser Build-only artifacts, these artifacts are not common with Firefox.
MULLVAD_BROWSER_BUILD_ARTIFACTS = [
    # Mullvad Browser Build-only artifacts, these artifacts are not common with Firefox.
    "mullvad-browser-extension",
    "noscript",
    "fonts",
    "ublock",
]

# Mapping of artifacts from taskcluster to tor-browser-build.
@@ -55,7 +57,7 @@ def get_artifact_index(artifact_path):
def get_artifact_name(original_artifact_name, host):
    # These are not build artifacts, they are pre-built artifacts to be added to the final build,
    # therefore this check can come before the host check.
    if original_artifact_name in TOR_BROWSER_BUILD_ARTIFACTS:
    if original_artifact_name in MULLVAD_BROWSER_BUILD_ARTIFACTS:
        return original_artifact_name

    if host != "linux64":