Skip to content

Commit aea12b7

Browse files
committed
Put back aspect hint. Fix unit tests
1 parent 3beb132 commit aea12b7

File tree

8 files changed

+62
-10
lines changed

8 files changed

+62
-10
lines changed

docs/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ _DOC_COMPONENTS = [
2121
out = "{}.md".format(component),
2222
input = "//xcodeproj/internal/docs:{}.bzl".format(component),
2323
tags = ["manual"],
24-
deps = ["//xcodeproj/internal"],
24+
deps = [
25+
"//xcodeproj/internal",
26+
"//xcodeproj/internal/files",
27+
],
2528
)
2629
for component in _DOC_COMPONENTS
2730
]

docs/bazel.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcodeproj")
5050
- [Providers](#providers)
5151
- [`XcodeProjAutomaticTargetProcessingInfo`](#XcodeProjAutomaticTargetProcessingInfo)
5252
- [`XcodeProjInfo`](#XcodeProjInfo)
53+
- [Aspect Hints](#aspect-hints)
54+
- [`xcodeproj_extra_files`](#xcodeproj_extra_files)
5355

5456
# Core
5557

@@ -1095,3 +1097,47 @@ Provides information needed to generate an Xcode project.
10951097
| <a id="XcodeProjInfo-xcode_targets"></a>xcode_targets | A `depset` of values from `xcode_targets.make`, which potentially will become targets in the Xcode project. |
10961098

10971099

1100+
# Aspect Hints
1101+
1102+
Aspect hints that can be used to provide additional information during project generation.
1103+
1104+
<a id="xcodeproj_extra_files"></a>
1105+
1106+
## xcodeproj_extra_files
1107+
1108+
<pre>
1109+
xcodeproj_extra_files(<a href="#xcodeproj_extra_files-name">name</a>, <a href="#xcodeproj_extra_files-files">files</a>)
1110+
</pre>
1111+
1112+
This rule is used to surface extra files that should be included in the Xcode
1113+
project navigator, but otherwise aren't inputs to a target. The provider
1114+
created by this rule should be attached to the related target via an aspect
1115+
hint.
1116+
1117+
This is only used when xcodeproj.generation_mode = "incremental" is set.
1118+
1119+
**EXAMPLE**
1120+
1121+
```starlark
1122+
swift_library(
1123+
...
1124+
aspect_hints = [":library_extra_files"],
1125+
...
1126+
)
1127+
1128+
# Display the README.md file located alongside the Swift library in Xcode
1129+
xcodeproj_extra_files(
1130+
name = "library_extra_files",
1131+
files = ["README.md"],
1132+
)
1133+
```
1134+
1135+
**ATTRIBUTES**
1136+
1137+
1138+
| Name | Description | Type | Mandatory | Default |
1139+
| :------------- | :------------- | :------------- | :------------- | :------------- |
1140+
| <a id="xcodeproj_extra_files-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
1141+
| <a id="xcodeproj_extra_files-files"></a>files | The list of extra files to surface in the Xcode navigator. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
1142+
1143+

test/internal/xcodeproj_extra_files/xcodeproj_extra_files_tests.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
load("@bazel_skylib//lib:unittest.bzl", "asserts", "analysistest")
2-
load("//xcodeproj:xcodeproj_extra_files.bzl", "xcodeproj_extra_files", "XcodeProjExtraFilesHintInfo")
2+
load("//xcodeproj/internal/files:xcodeproj_extra_files.bzl", "xcodeproj_extra_files", "XcodeProjExtraFilesHintInfo")
33

44
def _provider_contents_test_impl(ctx):
55
env = analysistest.begin(ctx)
66

77
target_under_test = analysistest.target_under_test(env)
88

9-
asserts.equals(env, depset(["BUILD"]), target_under_test[XcodeProjExtraFilesHintInfo].files)
9+
files_list = target_under_test[XcodeProjExtraFilesHintInfo].files.to_list()
10+
11+
asserts.equals(env, len(files_list), 1)
12+
asserts.equals(env, files_list[0].path, "test/internal/xcodeproj_extra_files/BUILD")
1013

1114
return analysistest.end(env)
1215

xcodeproj/defs.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ load(
2323
_xcodeproj = "xcodeproj",
2424
)
2525
load("//xcodeproj/internal:xcodeprojinfo.bzl", _XcodeProjInfo = "XcodeProjInfo")
26+
load("//xcodeproj/internal/files:xcodeproj_extra_files.bzl", _xcodeproj_extra_files = "xcodeproj_extra_files")
2627
load("//xcodeproj/internal/xcschemes:xcschemes.bzl", _xcschemes = "xcschemes")
2728

2829
# Re-exporting providers
@@ -34,6 +35,7 @@ project_options = _project_options
3435
top_level_target = _top_level_target
3536
top_level_targets = _top_level_targets
3637
xcodeproj = _xcodeproj
38+
xcodeproj_extra_files = _xcodeproj_extra_files
3739
xcode_provisioning_profile = _xcode_provisioning_profile
3840

3941
# Re-exporting APIs
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
"""# Aspect Hints
22
3-
Some comment...
4-
5-
```starlark
6-
load("@rules_xcodeproj//xcodeproj:xcodeproj_extra_files.bzl", "xcodeproj_extra_files")
7-
```
3+
Aspect hints that can be used to provide additional information during project generation.
84
"""
95

10-
load("//xcodeproj:xcodeproj_extra_files.bzl", _xcodeproj_extra_files = "xcodeproj_extra_files")
6+
load("//xcodeproj/internal/files:xcodeproj_extra_files.bzl", _xcodeproj_extra_files = "xcodeproj_extra_files")
117

128
xcodeproj_extra_files = _xcodeproj_extra_files

xcodeproj/internal/docs/bazel.header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcodeproj")
5050
- [Providers](#providers)
5151
- [`XcodeProjAutomaticTargetProcessingInfo`](#XcodeProjAutomaticTargetProcessingInfo)
5252
- [`XcodeProjInfo`](#XcodeProjInfo)
53+
- [Aspect Hints](#aspect-hints)
54+
- [`xcodeproj_extra_files`](#xcodeproj_extra_files)
5355

5456
# Core

xcodeproj/internal/files/incremental_input_files.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ load(
1111
"memory_efficient_depset",
1212
)
1313
load("//xcodeproj/internal:xcodeprojinfo.bzl", "XcodeProjInfo")
14-
load("//xcodeproj:xcodeproj_extra_files.bzl", "XcodeProjExtraFilesHintInfo")
14+
load(":xcodeproj_extra_files.bzl", "XcodeProjExtraFilesHintInfo")
1515
load(":incremental_resources.bzl", resources_module = "incremental_resources")
1616
load(":linker_input_files.bzl", "linker_input_files")
1717

0 commit comments

Comments
 (0)