Skip to content

Add apple_support 0.11.0#63

Merged
meteorcloudy merged 12 commits intobazelbuild:mainfrom
BalestraPatrick:apple_support
Jan 21, 2022
Merged

Add apple_support 0.11.0#63
meteorcloudy merged 12 commits intobazelbuild:mainfrom
BalestraPatrick:apple_support

Conversation

@BalestraPatrick
Copy link
Copy Markdown
Member

This is my first PR to this project and I'm still trying to get my head around all the tooling, so feedback is welcome.

This PR specifically adds apple_support for the release 0.11.0. I'm also about to open a PR to the same repo which adds a MODULE.bazel so that future releases won't need to have the same file checked-in into the registry.

@meteorcloudy
Copy link
Copy Markdown
Member

I'm also about to open a PR to the same repo which adds a MODULE.bazel so that future releases won't need to have the same file checked-in into the registry.

To be clear, even if the MODULE.bazel is upstreamed, we still need to check it into the BCR, because this will allow us to do dependency resolution without downloading and unpacking the whole source archive.

@BalestraPatrick BalestraPatrick deleted the apple_support branch January 18, 2022 15:04
@BalestraPatrick BalestraPatrick restored the apple_support branch January 18, 2022 15:17
Comment thread modules/apple_support/0.11.0/presubmit.yml Outdated
Comment thread modules/apple_support/metadata.json Outdated
Comment thread modules/apple_support/metadata.json
Comment thread modules/apple_support/0.11.0/MODULE.bazel
Comment thread modules/apple_support/0.11.0/presubmit.yml
Comment thread modules/apple_support/0.11.0/presubmit.yml
- '@apple_support//lib/...'

bcr_test_module:
module_path: "test"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

still surprised by this, and I assume this would break things in more complex repos wiht inter dependencies on absolute labels outside of the tests directory? 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You are right, this isn't working correctly right now. Because the "test" directory needs to have a WORKSPACE file and work as a separate Bazel project which depends on the target module. I replied more here: bazelbuild/apple_support#100 (comment)

run_test_module:
name: "Run test module"
platform: ${{ platform }}
build_targets:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this not be test_targets or something? maybe one of the other identifiers is magic instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. I copy/pasted from protobuf, so I assume that's a bug?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, the protobuf examples directory doesn't contain any tests, just build targets, which is also useful to verify if protobuf works correctly. That's why we have build_targets here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed it to test_targets for us.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See bazelbuild/apple_support#100 (comment), without a WORKSPACE under test directory, you're actually running the tests from main module instead of a test module.

Comment thread modules/apple_support/0.11.0/presubmit.yml Outdated
Comment thread modules/apple_support/0.11.0/presubmit.yml Outdated
@meteorcloudy
Copy link
Copy Markdown
Member

@meteorcloudy
Copy link
Copy Markdown
Member

meteorcloudy commented Jan 20, 2022

/cc @Wyverald
https://github.com/bazelbuild/apple_support/blob/a448644dce247e59268864fd66b6578195412b59/lib/apple_support.bzl#L163

IIUC, Label("//tools:xcode_path_wrapper") should correctly resolve to the apple support repo which contains the bzl file even if apple_support.action_required_attrs is used from a different repo, right?

@Wyverald
Copy link
Copy Markdown
Member

Yes -- even without bzlmod, a repo-relative label there should work. In fact I believe it doesn't even need to be a Label(...) call; a bare string "//tools:xcode_path_wrapper" would work.

@fmeum
Copy link
Copy Markdown
Contributor

fmeum commented Jan 20, 2022

Yes -- even without bzlmod, a repo-relative label there should work. In fact I believe it doesn't even need to be a Label(...) call; a bare string "//tools:xcode_path_wrapper" would work.

This would be very useful to know with certainty: Does attr.label automatically turn string arguments into labels based on its call site or does that only work when passed to rule's attrs? The latter definitely works.

@Wyverald
Copy link
Copy Markdown
Member

Does attr.label automatically turn string arguments into labels based on its call site

Yes, so attr.label(default="X") and attr.label(default=Label("X")) are exactly equivalent, wherever they occur. (See source code in StarlarkAttrModule.java)

fmeum added a commit to CodeIntelligenceTesting/bazel that referenced this pull request Jan 20, 2022
Label strings passed to the `default` argument of `attr.label()` are
resolved to a `Label` immediately relative to the call site of
`attr.label()`, so wrapping the argument with `Label(...)` is entirely
redundant.

More context at:
bazelbuild/bazel-central-registry#63 (comment)
index bd7c50b..33c9cbb 100644
--- a/lib/apple_support.bzl
+++ b/lib/apple_support.bzl
@@ -160,7 +160,7 @@ def _action_required_attrs():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you remove def _action_required_attrs():?

Copy link
Copy Markdown
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

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

Looks great!

"""Definition of a test rule to test apple_support."""

load(
- "@build_bazel_apple_support//lib:apple_support.bzl",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The whole patch file will be upstreamed, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes I will!

@meteorcloudy meteorcloudy merged commit 455e4c6 into bazelbuild:main Jan 21, 2022
@BalestraPatrick BalestraPatrick deleted the apple_support branch January 21, 2022 15:44
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.

6 participants