-
Notifications
You must be signed in to change notification settings - Fork 69
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
Switch to Bazel 4, migrate ObjcProvider compile info to CcCompilationContext #174
Conversation
--strategy=SwiftCompile=worker \ | ||
--swiftcopt=-Xwrapped-swift=-debug-prefix-pwd-is-dot \ | ||
--experimental_strict_action_env=true | ||
|
||
test \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spawn_strategy standalone
is deprecated. Docs say "Please use local instead."
https://docs.bazel.build/versions/master/user-manual.html#flag--spawn_strategy
@@ -15,3 +15,4 @@ external | |||
Pods/ | |||
PodsHost/ | |||
*.xcworkspace | |||
PodToBUILD.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be checked in, but is produced by e.g. make build-test
@@ -1,5 +1,6 @@ | |||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | |||
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_command_line_application", "macos_unit_test") | |||
load("@rules_cc//cc:defs.bzl", "objc_library") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buildifier now warns
Function "objc_library" is not global anymore and needs to be loaded from "@rules_cc//cc:defs.bzl".buildifier(native-cc)
@@ -8,7 +9,7 @@ objc_library( | |||
includes = ["Sources/ObjcSupport/include"] | |||
) | |||
|
|||
# PodToBUILD is a core library enabling Skylark code generation | |||
# PodToBUILD is a core library enabling Starlark code generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skylark was renamed to "Starlark" in August 2018 https://blog.bazel.build/2018/08/17/starlark.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix 👍
@@ -1,5 +1,5 @@ | |||
# This file is part of PodSpecToBUILD | |||
# Warning: this file is not accounted for as an explict imput into the build. | |||
# Warning: this file is not accounted for as an explicit input into the build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"imput" typo
if ctx.attr.module_map_name == "module.modulemap": | ||
provider_hdr = [module_map] + ([umbrella_header_file] if umbrella_header_file else []) | ||
objc_provider = apple_common.new_objc_provider( | ||
module_map=depset([module_map]), | ||
include=depset([ctx.outputs.module_map.dirname]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjcProvider no longer takes include
. bazelbuild/bazel#10674
remote = "https://github.com/bazelbuild/rules_apple.git", | ||
commit = "1cdaf74e44c4c969d7ee739b3a0f11b993c49d2a", | ||
sha256 = "a41a75c291c69676b9974458ceee09aea60cee0e1ee282e27cdc90b679dfd30f", | ||
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.21.2/rules_apple.0.21.2.tar.gz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading to the latest release of rules_apple.
generate_header_map = True | ||
) | ||
|
||
new_pod_repository( | ||
name = "PINCache", | ||
url = "https://github.com/pinterest/PINCache/archive/d886490de6d297e38f80bb750ff2dec4822fb870.zip", | ||
url = "https://github.com/pinterest/PINCache/archive/3.0.3.zip", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing #173
The older version of PINCache does not compile in Xcode 12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgcoffman - thank you kindly for the nice PR and updating it to work with 4.0 🥳 Overall this LGTM, my only question was around the top level symlinks and transitive hmap merging
) | ||
|
||
apple_rules_dependencies() | ||
apple_support_dependencies() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this automatically pull in rules_swift
and rules_cc
now - nice
build: | ||
@tools/bazel build \ | ||
--disk_cache=$(HOME)/Library/Caches/Bazel \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ | ||
--use_top_level_targets_for_symlinks \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgcoffman is this now required for the non header map build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't understand the question. What's the "non header map build"?
I added --use_top_level_targets_for_symlinks
here because something (I'm not sure what but I think the updated rules_apple?) causes an additional bindir to be created, which bazel-bin then symlinks to instead of the one which actually contains RepoTools and Compiler. use_top_level_targets_for_symlinks
just makes bazel-bin point at the directory it did previously.
BazelExtensions/extensions.bzl
Outdated
@@ -313,7 +330,8 @@ def _make_headermap_impl(ctx): | |||
if not hasattr(hdr_provider, "objc"): | |||
continue | |||
|
|||
hdrs = hdr_provider.objc.header.to_list() | |||
hdrs = hdr_provider.objc.direct_headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm if this has the same impact as it previously did? I believe here it merges transitive header maps in order to propagate the transitive includes, but would need to look more into that. If it still builds the top 50 swift cocoa pods and passes tests it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the migration description in bazelbuild/bazel#10674, it sounds like the right thing would be to change this to
hdrs = hdr_provider[CcInfo].compilation_context.headers.to_list())
but that actually fails, while direct_headers
works fine!
I'm considering
hdrs = []
if CcInfo in hdr_provider:
hdrs.extend(hdr_provider[CcInfo].compilation_context.headers.to_list())
if hasattr(hdr_provider, "objc"):
hdrs.extend(hdr_provider.objc.direct_headers)
which should cover all bases, but since there's no case of which we're aware that fails with direct_headers
alone, I'm not sure...
What do you think @jerrymarino?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgcoffman I'll have to pull this down and take a look at to give a clear answer or on it but - adding direct headers at the end seems right. There are likely some edge cases here which may or may not be exhibited in an integration test. If RN was running on the CI and this PR broke it that's probably something to look out for and vet the logic against. The CI is green, for what it's worth
BazelExtensions/extensions.bzl
Outdated
|
||
hdrs = hdr_provider.objc.direct_headers | ||
if CcInfo in hdr_provider: | ||
hdrs.extend(hdr_provider[CcInfo].compilation_context.headers.to_list()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, I think what you've done here seems more aligned with what we were doing before as opposed to only passing direct_headers
. It may have been failing under darwin-sandbox
if it didn't get all the headers.
I'm trying to build the
Looks like some include paths didn't propagate properly? |
@farcaller I think you need the specific BAZEL_OPTS from Examples/React/Makefile. Does |
Thanks for 47f2d72, makes a bit more sense now! |
], | ||
) | ||
|
||
ios_application( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerrymarino I expanded the React example to actually build the iOS app because there are a few gotchas in there that took me some time to figure out:
- The 2016 version of Folly doesn't compile, and the newer v2020.01.13.00 requires an odd workaround
- You have to use the React_hmap in order for your application code to import from
<React/Whatever>
- It's necessary to include certain SDK frameworks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating @dgcoffman!
Agree, the docs could probably clarify how to use the hmap better, or even use the new flag provider to pass upwards, that’d be a great addition
Just curious if there is a plan to cut a release with this merged? Thanks in advance! |
Beyond the initial done in bazel-xcode#174, we also need to include 'headers' in the generated CcCompilationContext and return a CcInfo provider with our headermap generation rule.
Beyond the initial done in #174, we also need to include 'headers' in the generated CcCompilationContext and return a CcInfo provider with our headermap generation rule.
Resolves
#170
#171
#173