Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for macos in apple_*_xcframework rules #2459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luispadron
Copy link
Contributor

@luispadron luispadron commented May 26, 2024

This commit adds a macos attr to both the apple_xcframework and apple_static_xcframework rules.
This allows building for multiple architectures and platforms.

The new macos attr is a string_list (unlike the ios attr which is a dict for the simulator/device split).

Example:

apple_xcframework(
    name = "ios_and_macos_dynamic_xcframework",
    bundle_id = "com.google.example",
    extension_safe = True,
    infoplists = [
        "//test/starlark_tests/resources:Info.plist",
    ],
    ios = {
        "simulator": ["x86_64"],
        "device": ["arm64"],
    },
    macos = [
        "arm64",
        "x86_64",
    ],
    minimum_os_versions = {
        "ios": common.min_os_ios.baseline,
        "macos": common.min_os_macos.baseline,
    },
    public_hdrs = [
        "//test/starlark_tests/resources:shared.h",
    ],
    tags = common.fixture_tags,
    deps = [":fmwk_lib"],
)

Fixes #1475

@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch from d8a3282 to 83af71b Compare May 26, 2024 20:39
@luispadron luispadron changed the title Add support for macos in apple_*_xcframework rules Add support for macos in apple_*_xcframework rules May 26, 2024
@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch 6 times, most recently from df2c4f8 to a330f7f Compare May 26, 2024 23:56
@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch from a330f7f to 113bdd4 Compare June 10, 2024 13:43
@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch from 113bdd4 to 99d9b18 Compare September 14, 2024 22:34
Comment on lines +344 to +346
if environment_plist:
input_files.append(environment_plist)
forced_plists.append(environment_plist.path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't created for the macos platform (e.g. environment_plist is None here)

if not hasattr(attr, platform_type):
platform_attr = getattr(attr, platform_type, None)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use getattr with a None default instead of hasattr which will still return true even when ios for example is the default value of {}, this was causing a apple_xcframework with only a macos attr to also go through this transition for the ios platform.

With getattr we correctly get the value, for example the empty dict {}, which then matches on the if not check (it's an empty dict which is falsy), where hasattr would've returned true since the ios attr is technically available.

@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch from 99d9b18 to ef3a48c Compare September 14, 2024 22:39
This commit adds a `macos` attr to both the `apple_xcframework` and `apple_static_xcframework` rules.
This allows building for multiple architectures and platforms.

The new `macos` attr is a `string_list` (unlike the `ios` attr which is a dict for the simulator/device split).

Example:

```starlark
apple_xcframework(
    name = "ios_and_macos_dynamic_xcframework",
    bundle_id = "com.google.example",
    extension_safe = True,
    infoplists = [
        "//test/starlark_tests/resources:Info.plist",
    ],
    ios = {
        "simulator": ["x86_64"],
        "device": ["arm64"],
    },
    macos = [
        "arm64",
        "x86_64",
    ],
    minimum_os_versions = {
        "ios": common.min_os_ios.baseline,
        "macos": common.min_os_macos.baseline,
    },
    public_hdrs = [
        "//test/starlark_tests/resources:shared.h",
    ],
    tags = common.fixture_tags,
    deps = [":fmwk_lib"],
)
```

Fixes #1475
@luispadron luispadron force-pushed the luis/add-support-for-macos-xcframeworks branch from ef3a48c to 56c6864 Compare September 14, 2024 22:41
@luispadron luispadron marked this pull request as ready for review September 14, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XCFramework for macOS
1 participant