-
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
Changes from 16 commits
6427656
bd4fb41
c5dbf58
c4f6cc5
bd0b3e0
4df6f47
763f038
8b9a425
f3253ee
fad7587
fcc7b50
d53e8c0
7cc97f1
bca80ef
a051d4d
90ce6dd
93efb03
2a32559
47f2d72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# A few settings for XCHammer's .bazelrc | ||
# Debugging: Use the remapping feature of rules_swift. | ||
build \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ | ||
--strategy=SwiftCompile=worker \ | ||
--swiftcopt=-Xwrapped-swift=-debug-prefix-pwd-is-dot \ | ||
--experimental_strict_action_env=true | ||
|
||
test \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
4.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ external | |
Pods/ | ||
PodsHost/ | ||
*.xcworkspace | ||
PodToBUILD.zip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Buildifier now warns
|
||
|
||
objc_library( | ||
name = "ObjcSupport", | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Nice fix 👍 |
||
swift_library( | ||
name = "PodToBUILD", | ||
srcs = glob(["Sources/PodToBUILD/*.swift"]), | ||
|
@@ -53,7 +54,7 @@ swift_library( | |
|
||
alias(name = "update_pods", actual = "//bin:update_pods") | ||
|
||
# This tests RepoToolsCore and Skylark logic | ||
# This tests RepoToolsCore and Starlark logic | ||
swift_library( | ||
name = "PodToBUILDTestsLib", | ||
srcs = glob(["Tests/PodToBUILDTests/*.swift"]), | ||
|
@@ -68,13 +69,13 @@ macos_unit_test( | |
) | ||
|
||
swift_library( | ||
name = "BuildTestsLib", | ||
name = "BuildTestsLib", | ||
srcs = glob(["Tests/BuildTests/*.swift"]), | ||
deps = [":RepoToolsCore", "@podtobuild-SwiftCheck//:SwiftCheck"], | ||
data = glob(["Examples/**/*.podspec.json"]) | ||
) | ||
|
||
# This tests RepoToolsCore and Skylark logic | ||
# This tests RepoToolsCore and Starlark logic | ||
macos_unit_test( | ||
name = "BuildTests", | ||
deps = [":BuildTestsLib"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. "imput" typo |
||
# Therefore, bin/RepoTools must be updated when this changes. | ||
|
||
# Acknowledgements | ||
|
@@ -157,7 +157,7 @@ def _module_map_impl(ctx): | |
relative_path = "".join(["../" for i in range(len(module_map.dirname.split("/")))]) | ||
|
||
system_tag = " [system] " | ||
content = "module " + module_name + (system_tag if ctx.attr.is_system else "" ) + " {\n" | ||
content = "module " + module_name + (system_tag if ctx.attr.is_system else "" ) + " {\n" | ||
umbrella_header_file = None | ||
if ctx.attr.umbrella_hdr: | ||
# Note: this umbrella header is created internally. | ||
|
@@ -190,24 +190,31 @@ module {module_name}.Swift {{ | |
# If the name is `module.modulemap` we propagate this as an include. If a | ||
# module map is added to `objc_library` as a dep, bazel will add these | ||
# automatically and add a _single_ include to this module map. Ideally there | ||
# would be an API to invoke clang with -fmodule-map= | ||
# would be an API to invoke clang with -fmodule-map= | ||
providers = [] | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. ObjcProvider no longer takes |
||
header=depset(provider_hdr) | ||
) | ||
|
||
compilation_context = cc_common.create_compilation_context( | ||
includes=depset([ctx.outputs.module_map.dirname])) | ||
|
||
providers.append(CcInfo(compilation_context=compilation_context)) | ||
else: | ||
# This is an explicit module map. Currently, we use these for swift only | ||
provider_hdr = [module_map] + ([umbrella_header_file] if umbrella_header_file else []) | ||
objc_provider = apple_common.new_objc_provider( | ||
header=depset(provider_hdr + [module_map]) | ||
) | ||
|
||
providers.append(objc_provider) | ||
|
||
return struct( | ||
files=depset([module_map]), | ||
providers=[objc_provider], | ||
providers=providers, | ||
objc=objc_provider, | ||
headers=depset([module_map]), | ||
) | ||
|
@@ -257,12 +264,22 @@ def gen_module_map(name, | |
def _gen_includes_impl(ctx): | ||
includes = [] | ||
includes.extend(ctx.attr.include) | ||
|
||
for target in ctx.attr.include_files: | ||
for f in target.files.to_list(): | ||
includes.append(f.path) | ||
|
||
return apple_common.new_objc_provider( | ||
include=depset(includes)) | ||
compilation_context = cc_common.create_compilation_context( | ||
includes=depset(includes)) | ||
|
||
providers = [] | ||
dgcoffman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
providers.append(CcInfo(compilation_context=compilation_context)) | ||
|
||
# objc_library deps requires an ObjcProvider | ||
providers.append(apple_common.new_objc_provider()) | ||
|
||
return providers | ||
|
||
_gen_includes = rule( | ||
implementation=_gen_includes_impl, | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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
but that actually fails, while I'm considering
which should cover all bases, but since there's no case of which we're aware that fails with What do you think @jerrymarino? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
for hdr in hdrs: | ||
if hdr.path.endswith(".hmap"): | ||
# Add headermaps | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
4.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
load("@rules_cc//cc:defs.bzl", "objc_library") | ||
|
||
objc_library(name="all", deps=["//Vendor/ArcSplitting:ArcSplitting"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_pods", | ||
urls = ["https://note-this-is-overridden"], | ||
) | ||
|
||
git_repository( | ||
http_archive( | ||
name = "build_bazel_rules_apple", | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Upgrading to the latest release of rules_apple. |
||
) | ||
|
||
load( | ||
"@build_bazel_rules_apple//apple:repositories.bzl", | ||
"apple_rules_dependencies", | ||
) | ||
|
||
git_repository( | ||
name = "build_bazel_rules_swift", | ||
remote = "https://github.com/bazelbuild/rules_swift.git", | ||
commit = "d07d880dcf939e0ad98df4dd723f8516bf8a2867", | ||
apple_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_apple_support//lib:repositories.bzl", | ||
"apple_support_dependencies", | ||
) | ||
|
||
apple_rules_dependencies() | ||
apple_support_dependencies() | ||
|
||
load( | ||
"@build_bazel_rules_swift//swift:repositories.bzl", | ||
|
@@ -32,16 +32,9 @@ load( | |
|
||
swift_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_apple_support//lib:repositories.bzl", | ||
"apple_support_dependencies", | ||
) | ||
|
||
apple_support_dependencies() | ||
load( | ||
"@com_google_protobuf//:protobuf_deps.bzl", | ||
"protobuf_deps", | ||
) | ||
|
||
protobuf_deps() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# A few settings for XCHammer's .bazelrc | ||
# Debugging: Use the remapping feature of rules_swift. | ||
build \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ | ||
--strategy=SwiftCompile=worker \ | ||
--swiftcopt=-Xwrapped-swift=-debug-prefix-pwd-is-dot \ | ||
--experimental_strict_action_env=true | ||
|
||
test \ | ||
--spawn_strategy=standalone \ | ||
--spawn_strategy=local \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
4.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
4.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
load("@rules_cc//cc:defs.bzl", "objc_library") | ||
|
||
objc_library(name="all", deps=["//Vendor/Parent:Parent"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_pods", | ||
urls = ["https://note-this-is-overridden"], | ||
) | ||
|
||
git_repository( | ||
http_archive( | ||
name = "build_bazel_rules_apple", | ||
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", | ||
) | ||
|
||
load( | ||
"@build_bazel_rules_apple//apple:repositories.bzl", | ||
"apple_rules_dependencies", | ||
) | ||
|
||
git_repository( | ||
name = "build_bazel_rules_swift", | ||
remote = "https://github.com/bazelbuild/rules_swift.git", | ||
commit = "d07d880dcf939e0ad98df4dd723f8516bf8a2867", | ||
apple_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_apple_support//lib:repositories.bzl", | ||
"apple_support_dependencies", | ||
) | ||
|
||
apple_rules_dependencies() | ||
apple_support_dependencies() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this automatically pull in |
||
|
||
load( | ||
"@build_bazel_rules_swift//swift:repositories.bzl", | ||
|
@@ -32,12 +32,6 @@ load( | |
|
||
swift_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_apple_support//lib:repositories.bzl", | ||
"apple_support_dependencies", | ||
) | ||
|
||
apple_support_dependencies() | ||
load( | ||
"@com_google_protobuf//:protobuf_deps.bzl", | ||
"protobuf_deps", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.4.1 | ||
4.0.0 |
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