-
Notifications
You must be signed in to change notification settings - Fork 102
Create xcodeproj_extra_files aspect hint #3150
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
Open
jflan-dd
wants to merge
4
commits into
MobileNativeFoundation:main
Choose a base branch
from
jflan-dd:jflan/extra-files-aspect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load(":xcodeproj_extra_files_tests.bzl", "xcodeproj_extra_files_test_suite") | ||
|
||
xcodeproj_extra_files_test_suite(name = "xcodeproj_extra_files_test") | ||
|
||
test_suite(name = "xcodeproj_extra_files") | ||
|
||
bzl_library( | ||
name = "bzls", | ||
srcs = glob( | ||
["*.bzl"], | ||
exclude = ["utils.bzl"], | ||
), | ||
visibility = ["//test:__pkg__"], | ||
) |
39 changes: 39 additions & 0 deletions
39
test/internal/xcodeproj_extra_files/xcodeproj_extra_files_tests.bzl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("//xcodeproj:xcodeproj_extra_files.bzl", "xcodeproj_extra_files") | ||
load("//xcodeproj/internal:providers.bzl", "XcodeProjExtraFilesHintInfo") | ||
|
||
def _provider_contents_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
|
||
target_under_test = analysistest.target_under_test(env) | ||
|
||
files_list = target_under_test[XcodeProjExtraFilesHintInfo].files.to_list() | ||
|
||
asserts.equals(env, len(files_list), 1) | ||
asserts.equals(env, files_list[0].path, "test/internal/xcodeproj_extra_files/BUILD") | ||
|
||
return analysistest.end(env) | ||
|
||
provider_contents_test = analysistest.make(_provider_contents_test_impl) | ||
|
||
def _test_provider_contents(): | ||
xcodeproj_extra_files( | ||
name = "xcodeproj_extra_files_subject", | ||
files = ["BUILD"], | ||
tags = ["manual"], | ||
) | ||
|
||
provider_contents_test( | ||
name = "provider_contents_test", | ||
target_under_test = ":xcodeproj_extra_files_subject", | ||
) | ||
|
||
def xcodeproj_extra_files_test_suite(name): | ||
_test_provider_contents() | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":provider_contents_test", | ||
], | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""# Aspect Hints | ||
|
||
Aspect hints that can be used to provide additional information during project generation. | ||
""" | ||
|
||
load("//xcodeproj:xcodeproj_extra_files.bzl", _xcodeproj_extra_files = "xcodeproj_extra_files") | ||
|
||
xcodeproj_extra_files = _xcodeproj_extra_files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Rule for providing extra files from targets to the project generator""" | ||
|
||
load("//xcodeproj/internal:providers.bzl", "XcodeProjExtraFilesHintInfo") | ||
|
||
def _xcodeproj_extra_files_impl(ctx): | ||
"""Create a provider to surface extra files via an aspect hint. | ||
|
||
Args: | ||
ctx: The rule context. | ||
|
||
Returns: | ||
A `XcodeProjExtraFilesHintInfo` provider. | ||
""" | ||
return [XcodeProjExtraFilesHintInfo(files = depset(ctx.files.files))] | ||
|
||
xcodeproj_extra_files = rule( | ||
doc = """\ | ||
This rule is used to surface extra files that should be included in the Xcode | ||
project navigator, but otherwise aren't inputs to a target. The provider | ||
created by this rule should be attached to the related target via an aspect | ||
hint. | ||
|
||
This is only used when xcodeproj.generation_mode = "incremental" is set. | ||
|
||
**EXAMPLE** | ||
|
||
```starlark | ||
load("@rules_xcodeproj//xcodeproj:xcodeproj_extra_files.bzl", "xcodeproj_extra_files") | ||
|
||
swift_library( | ||
... | ||
aspect_hints = [":library_extra_files"], | ||
... | ||
) | ||
|
||
# Display the README.md file located alongside the Swift library in Xcode | ||
xcodeproj_extra_files( | ||
name = "library_extra_files", | ||
files = ["README.md"], | ||
) | ||
``` | ||
""", | ||
implementation = _xcodeproj_extra_files_impl, | ||
attrs = { | ||
"files": attr.label_list( | ||
doc = "The list of extra files to surface in the Xcode navigator.", | ||
allow_files = True, | ||
), | ||
}, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.