Verified Commit 0af21763 authored by brizental's avatar brizental Committed by jwilde
Browse files

TB 43564: Modify ./mach bootstrap for Tor Browser

parent f12fe7d9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -228,7 +228,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:
+141 −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.",
    when=is_desktop_build,
)


@depends(
    "--with-tor-expert-bundle",
    mozbuild_state_path,
    bootstrap_path(
        "tor-expert-bundle",
        when=depends("--with-tor-expert-bundle", when=is_desktop_build)(
            lambda x: not x
        ),
    ),
    when=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, when=is_desktop_build)


# Android
# -------------------------------------------------


@depends(build_project)
def is_android_build(build_project):
    return build_project == "mobile/android"


option(
    "--with-tor-expert-bundle-aar",
    env="TOR_EXPERT_BUNDLE_AAR",
    nargs=1,
    default=None,
    help="Path to location of tor-expert-bundle.aar archive.",
    when=is_android_build,
)


@depends(
    "--with-tor-expert-bundle-aar",
    mozbuild_state_path,
    bootstrap_path(
        "tor-expert-bundle-aar",
        no_unpack=True,
        when=depends("--with-tor-expert-bundle-aar", when=is_android_build)(
            lambda x: not x
        ),
    ),
    when=is_android_build,
)
@checking("for tor-expert-bundle.aar")
@imports(_from="pathlib", _import="Path")
def tor_expert_bundle_aar(value, mozbuild_state_path, _bootstrapped):
    if value:
        path = Path(value[0])
        if path.suffix.lower() == ".aar":
            return value[0]
        else:
            die("--with-tor-expert-bundle-aar must point to a AAR archive.")

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

    die(
        "tor-expert-bundle-aar not found. Either enable bootstrap, or provide a path with --with-tor-expert-bundle-aar."
    )


set_config("TOR_EXPERT_BUNDLE_AAR", tor_expert_bundle_aar)


option(
    "--with-application-services",
    env="APPLICATION_SERVICES",
    nargs=1,
    default=None,
    help="Path to location of application-services gradle lib.",
    when=is_android_build,
)


@depends(
    "--with-application-services",
    mozbuild_state_path,
    bootstrap_path(
        "application-services",
        when=depends("--with-application-services", when=is_android_build)(
            lambda x: not x
        ),
    ),
    when=is_android_build,
)
@checking("for application-services")
@imports(_from="pathlib", _import="Path")
@imports("mozbuild.tbbutils")
def application_services(value, mozbuild_state_path, _bootstrapped):
    as_location = None

    if value:
        path = Path(value[0])
        if path.is_dir():
            as_location = path
        else:
            die("--with-application-services must point to a directory.")
    else:
        bootstrapped_location = Path(mozbuild_state_path) / "application-services/maven"
        if bootstrapped_location.is_dir():
            as_location = bootstrapped_location

    if not as_location:
        # application-services is required for building.
        die(
            "application-services not found. Either enable bootstrap, or provide a path with --with-application-services."
        )

    return as_location
+5 −2
Original line number Diff line number Diff line
@@ -742,13 +742,16 @@ set_config(
)


@depends("GRADLE_MAVEN_REPOSITORIES")
@depends(application_services, "GRADLE_MAVEN_REPOSITORIES")
@imports(_from="os.path", _import="isdir")
def gradle_maven_repositories(values):
def gradle_maven_repositories(app_services_location, values):
    if not values:
        die("GRADLE_MAVEN_REPOSITORIES must not be empty")
    if not all(values):
        die("GRADLE_MAVEN_REPOSITORIES entries must not be empty")

    # Prepend the location of the custom a-s location
    values = (f"file://{app_services_location}",) + values
    return values


+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,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,26 +50,26 @@ 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"),
])

Loading