Skip to content

Commit

Permalink
Bug 1522986 - Allow to auto-bootstrap the macos SDK. r=firefox-build-…
Browse files Browse the repository at this point in the history
…system-reviewers,ahochheiden

Differential Revision: https://phabricator.services.mozilla.com/D167772
  • Loading branch information
glandium committed Feb 1, 2023
1 parent afec521 commit 7d5e528
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 52 deletions.
28 changes: 16 additions & 12 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,23 @@ with only_when(host_is_osx | target_is_osx):
)
return Version(obj["Version"])

@depends("--with-macos-sdk", host)
def sdk_min_version():
return "11.3"

@depends(
"--with-macos-sdk",
host,
bootstrap_path(
"MacOSX{}.sdk".format(sdk_min_version()),
when=depends("--with-macos-sdk")(lambda x: not x),
),
)
@imports(_from="__builtin__", _import="Exception")
@imports(_from="os.path", _import="isdir")
@imports(_from="os", _import="listdir")
def macos_sdk(sdk, host):
# When we change the SDK we build with, please update the manual SDK
# installation docs:
# https://firefox-source-docs.mozilla.org/setup/macos_build.html#macos-sdk-is-unsupported
sdk_min_version = Version("11.3")

def macos_sdk(sdk, host, bootstrapped):
if bootstrapped:
sdk = [bootstrapped]
if sdk:
sdk = sdk[0]
try:
Expand Down Expand Up @@ -144,13 +151,10 @@ with only_when(host_is_osx | target_is_osx):
"tools are selected during the Xcode/Developer Tools installation."
% sdk
)
sdk_installation_docs_url = "https://firefox-source-docs.mozilla.org/setup/macos_build.html#macos-sdk-is-unsupported"
if version < sdk_min_version:
if version < Version(sdk_min_version()):
die(
'SDK version "%s" is too old. Please upgrade to at least %s. Try '
"updating your system Xcode. If that's not sufficient, see the manual "
"SDK installation docs: %s"
% (version, sdk_min_version, sdk_installation_docs_url)
"updating your system Xcode." % (version, sdk_min_version())
)
return sdk

Expand Down
38 changes: 0 additions & 38 deletions docs/setup/macos_build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,41 +120,3 @@ say hello in the `Introduction channel
start working on <https://codetribute.mozilla.org/>`_.
See the :ref:`Firefox Contributors' Quick Reference` to learn how to test your changes,
send patches to Mozilla, update your source code locally, and more.

Troubleshooting
---------------

macOS SDK is unsupported
~~~~~~~~~~~~~~~~~~~~~~~~

.. only:: comment

If you are editing this section to bump the SDK and Xcode version, I'd recommend
following the steps to ensure that they're not obsolete. Apple doesn't guarantee
the structure of Xcode, so the SDK could be moved to a different location or
stored differently.

If the SDK included with your Xcode installation is not supported by Firefox,
you'll need to manually install one that is compatible.
We're currently using the 11 SDK on our build servers, so that's the one that you
should install:

1. Go to the `More Downloads for Apple Developers <https://developer.apple.com/download/more/>`_ page
and download Xcode 12.5.1.
2. Once downloaded, extract ``Xcode_12.5.1.xip``.
3. In your terminal, copy the SDK from the installer:

.. code-block:: shell
mkdir -p ~/.mozbuild/macos-sdk
# This assumes that Xcode is in your "Downloads" folder
cp -aH ~/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk ~/.mozbuild/macos-sdk/
4. Finally, inform the Firefox build about this SDK by creating (or editing) a file called ``mozconfig`` file
in the Firefox source code directory. Add the following line:

.. code-block::
ac_add_options --with-macos-sdk=$HOME/.mozbuild/macos-sdk/MacOSX11.3.sdk
5. Now, you should be able to successfully run ``./mach build``.
3 changes: 3 additions & 0 deletions taskcluster/ci/toolchain/macos-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ macosx64-sdk-11.3:
- b075d3d2f3b066607209a5bbf7cf727a40b98fe65629c5b6abc17f156897af4a
- Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
toolchain-artifact: project/gecko/mac-sdk/MacOSX11.3.sdk.tar.zst
toolchain-alias:
- MacOSX11.3.sdk
resources:
- python/mozbuild/mozpack/macpkg.py
- taskcluster/scripts/misc/unpack-sdk.py
Expand All @@ -68,6 +70,7 @@ macosx64-sdk-13.0:
toolchain-alias:
- macosx64-sdk
- macosx64-sdk-toolchain
- MacOSX13.0.sdk
resources:
- python/mozbuild/mozpack/macpkg.py
- taskcluster/scripts/misc/unpack-sdk.py
4 changes: 2 additions & 2 deletions widget/cocoa/docs/sdks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Apple distributes SDKs as part of the Xcode app bundle. Each Xcode version comes
the SDK for the most recent released version of macOS at the time of the Xcode release.
The SDK is located at `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk`.

Compiling Firefox for macOS requires a macOS SDK. The build system uses the SDK from Xcode.app by
default, and you can select a different SDK using the `mozconfig` option `--with-macos-sdk`:
Compiling Firefox for macOS requires a macOS SDK. The build system bootstraps an adequate SDK by
default, but you can select a different SDK using the `mozconfig` option `--with-macos-sdk`:

```text
ac_add_options --with-macos-sdk=/Users/username/SDKs/MacOSX11.3.sdk
Expand Down

0 comments on commit 7d5e528

Please sign in to comment.