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

feat: fix apple toolchain apple framework #740

Conversation

pollend
Copy link
Contributor

@pollend pollend commented Aug 16, 2024

I've just been roughly trying to get this to work for my local setup. some of this is a bit hacked away to get this to work but I think its in the general right direction.

this is what I have in mind for resolving the apple tools

find_apple_tools(
    name = "apple",
    architecture = "amr64",
    sdk_name= "macosx",
    visibility = ["PUBLIC"],
)

here is the working code I'm trying to test


apple_binary(
    name = "main-apple",
    srcs = ["main.mm"],
    link_style = "static",
    frameworks =  ["$SDKROOT/System/Library/Foundation.framework"],
    compatible_with = ["config//os:macos" ],
    target_sdk_version = "14.5",
    deps = [":print"],
)

here is my sample application that I've been testing these changes with: https://github.com/OSS-Cosmic/buck2-samples/tree/main/hello_world

I need to build this locally and verify it on my own system but this is what I have so far.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 16, 2024
@pollend pollend force-pushed the feature/fix-apple-toolchain-apple-framework branch from 254c5ca to 8bc770a Compare August 17, 2024 07:18
@pollend pollend marked this pull request as ready for review August 17, 2024 07:19

def _system_apple_toolschain_impl(ctx: AnalysisContext) -> list[Provider]:
xcode_bin_path = "{}/Contents/Developer/usr/bin".format(ctx.attrs.xcode_app)
sdk_path = "{}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk".format(ctx.attrs.xcode_app)
Copy link
Contributor Author

@pollend pollend Aug 17, 2024

Choose a reason for hiding this comment

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

I'm a little confused on how to handle this.

there is

 buck2 % xcrun --sdk macosx --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14
.5.sdk

Comment on lines 24 to +28
def get_apple_toolchain_attr():
# FIXME: prelude// should be standalone (not refer to fbcode//)
return attrs.toolchain_dep(default = "fbcode//buck2/platform/toolchain:apple-default", providers = [AppleToolchainInfo])
return attrs.toolchain_dep(default = "toolchains//:apple", providers = [AppleToolchainInfo])

def get_apple_bundle_toolchain_attr():
# FIXME: prelude// should be standalone (not refer to fbcode//)
return attrs.toolchain_dep(default = "fbcode//buck2/platform/toolchain:apple-bundle", providers = [AppleToolchainInfo])
return attrs.toolchain_dep(default = "toolchains//:apple", providers = [AppleToolchainInfo])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a situation for multiple toolchains to be needed?

@pollend
Copy link
Contributor Author

pollend commented Aug 17, 2024

I added a small example to hello world to demonstrate this working. how does cxx_library and cxx_binary fit into this because those break if they don't have an sdk version available

Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
@pollend pollend force-pushed the feature/fix-apple-toolchain-apple-framework branch from 3a4d150 to c9d58c8 Compare August 18, 2024 07:59
@pollend pollend closed this Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants