Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Sync with upstream (#63)
Browse files Browse the repository at this point in the history
* Fix broken external BuildLabel filename parsing (#257)

External BuildLabels were keeping their // halfway through their path, leading to projects xcode would refuse to load.

As an example: @google_toolbox_for_mac//Foundation:BUILD was going to external//Foundation/BUILD, not external/Foundation/BUILD.
This lead the pbjproj to assign the file the path //Foundation/BUILD, which Xcode refuses to load, along with groups named '/' and the omission of other associated source files.

* Add support for ios_sim_arm64 CPU type

* Point External Paths into Stable External Directory instead of Unstable Execroot (#255)

* Fix breaking of external workspaces after builds

Previously, paths to files in external workspaces went through execroot.
Execroot is reconfigured on every rebuild to contain only the external
workspaces (and top-level packages) required by that build. Therefore,
executing a build that used a subset of the project's external
workspaces broke the file references and include paths for the other
external workspaces. Bad times.

This commit points to external workspaces through the stable external
subdirectory of output_base instead of the unstable external subdir
of execroot. This requires a new tulsi symlink for output base; Xcode
doesn't properly resolve ../ paths through symlinks for file references.
Plus, we should probably try to move away from linking through a
temporary build sandbox anyway; it'll just keep leading to subtle bugs.

This should close bazelbuild/tulsi#164
This patches bazelbuild/tulsi#227 and
bazelbuild/tulsi#229.

This commit also contains a fix for an (I think unreported) bug I
noticed while editing ProjectPatcher. In trying to fix paths for files
not on disk, it was unintentionally setting their paths to (an
incorrect) path that was group relative, but meant to be project
relative. It also created inconsistent state in the PBGroup hierarchy.
Since this fixes the paths for generated Info.plists in most projects,
it leads to many of the file ref path changes in the tests. The code
now does what the author clearly intended, and I've added some defence
against future issues into PBXObjects.

* Make execroot symlink's names reflect what it is

tulsi-workspace -> tulsi-execution-root
TULSI_BWRS -> TULSI_EXECUTION_ROOT

* Re-add legacy names for execroot build setting and symlink for backwards compatibility

Fixes bazelbuild/tulsi#164.

* Add `generates_header = True` to `swift_library` targets used by Tulsi's E2E tests.

PiperOrigin-RevId: 367058875
(cherry picked from commit debe5ac)

* Add a setting to the Tulsi-generated lldbinit to explicitly enable implicit module maps. LLDB will transitively include an option that disables implicit module maps when importing a Swift module that depends on an Objective-C library that was built with explicit modules. Depending on the build graph, this can mean LLDB's clang module importer can fail to find the required module maps and provide no debug info.

PiperOrigin-RevId: 371927956
(cherry picked from commit dbb0fc4)

* Updates version number to 0.4.372144887.20210505.

PiperOrigin-RevId: 372147605
(cherry picked from commit 5ef399c)

* Internal Change

PiperOrigin-RevId: 373199701
(cherry picked from commit 9939243)

* Only show one amibigous rule warning per build label.

PiperOrigin-RevId: 374475916
(cherry picked from commit ee965f2)

* Updates version number to 0.4.374474001.20210518.

PiperOrigin-RevId: 374489201
(cherry picked from commit 21cc1c8)

* Change 1/3 to add a new tool that handles pruning the LLDB module cache of any modules that are found in a metadata file that is intended to be created by a bazel aspect that collects explicit module build outputs. This tool is needed to avoid a crash with LLDB that occurs when the LLDB module cache contains a module that is also generated in a build as an explicit module.

This chnage handles reading metadata files that a bazel aspect will write to come up with a list of names of all explicit modules that will have been created from a build.

PiperOrigin-RevId: 378248354
(cherry picked from commit 078e311)

* Change 2/3 to add a new tool that handles pruning the LLDB module cache of any modules that are found in a metadata file that is intended to be created by a bazel aspect that collects explicit module build outputs. This tool is needed to avoid a crash with LLDB that occurs when the LLDB module cache contains a module that is also generated in a build as an explicit module.

This change handles reading the contents of the implicit module cache and map the name of each module to the absolute path of that module.

PiperOrigin-RevId: 378402314
(cherry picked from commit a03f6ef)

* Change 3/3 to add a new tool that handles pruning the LLDB module cache of any modules that are found in a metadata file that is intended to be created by a bazel aspect that collects explicit module build outputs. This tool is needed to avoid a crash with LLDB that occurs when the LLDB module cache contains a module that is also generated in a build as an explicit module.

To summarize how this works:
 - Read the contents of the implicit module cache and map the name of each module to the absolute path of that module.
 - Read metadata files that a bazel aspect will write to come up with a list of names of all explicit modules created from a build.
 - Iterate through the list of explicit module names and delete any module with the same name from the implicit module cache.
 - Compute a hash of the list of explicit module names that were used to prune the implicit module cache.
 - Save that hash to a special sentinel file in the implicit module cache.
 - Compare the hash of subsequent builds to the one in the file to determine if subsequent builds should prune the implicit module cache.

PiperOrigin-RevId: 378666180
(cherry picked from commit 55b6a92)

* Disable legacy build system error in Xcode 13

Disable this as it can annoy users; we're working on new build system support.

PiperOrigin-RevId: 378916679
(cherry picked from commit 3f25dd7)

* Removing this ios_static_framework target that isn't covered by any tests.

Tulsi doesn't allow list ios_static_framework rules, so the e2e test appears to ignore this target.

PiperOrigin-RevId: 378933587
(cherry picked from commit 31da848)

* Revert "Point External Paths into Stable External Directory instead of Unstable Execroot (#255)"

This reverts commit c7609aa.

* Prevent a crash in lldb-rpc-server that can occur after migrating a rule in the build graph to use Swift explicit modules.
  - Updates the Tulsi outputs aspect to output the Swift explicit modules generated from a build.
  - Bundles the module cache pruning tool with the Tulsi app bundle and installs it to the same location as the bazel_cache_reader.
  - Runs the module cache pruning tool after each Tulsi build, providing the output from the aspect, to prevent lldb from loading the outdated implicit module.

PiperOrigin-RevId: 378936605
(cherry picked from commit 98d6f25)

* Updates version number to 0.4.374498161.20210614.

Significant changes:
- Fixed a crash with lldb-rpc-server that can occur after
  migrating a rule to use Swift explicit modules.

PiperOrigin-RevId: 379284179
(cherry picked from commit e4fcc3c)

* Add @discardableResult to pruneModuleCache function so we can avoid needing to explicitly drop the return value when not using it.

PiperOrigin-RevId: 382075141
(cherry picked from commit 552b356)

* Move entitlements handling into the rule implementations.

This allows us to remove the special internal entitlements rule and convert nearly all of the existing macro-wrapped rules into pure rules, with the exception of some macOS rules which still have some straggling items to migrate.

PiperOrigin-RevId: 382347912
(cherry picked from commit 286d21b)

* Move usage of bazel_cache_reader behind a Tulsi option and leave it disabled by default. bazel_cache_reader has been observed to result in significant hits to symbolication in some cases.

PiperOrigin-RevId: 382537207
(cherry picked from commit 6fe2926)

* Skip over unsupported test targets in test_suites

PiperOrigin-RevId: 382571317
(cherry picked from commit d3e3536)

* Updates version number to 0.4.384524523.20210713.

Significant changes:
- Unsupported tests in test_suites are now skipped instead of
  throwing an error.
- Disable fallback dSYM searching by default. The fallback can be
  reenabled with the "Enable fallback dSYM searches" option.
  Reenabling is only recommended if Spotlight is disabled as it
  can impact time to symbolicate a binary.
- Fixed a crash with lldb-rpc-server that can occur after
  migrating a rule to use Swift explicit modules.

PiperOrigin-RevId: 384527057
(cherry picked from commit 7440ba0)

* Automatic code cleanup.

PiperOrigin-RevId: 386871254
(cherry picked from commit febfc91)

* Improve failure messages when goldens are outdated

Show the entire diff at once instead of line-by-line

PiperOrigin-RevId: 389889488
(cherry picked from commit d16d184)

* Improve performance of fetching build/bzl files for a project

```
buildfiles(deps($T1)+deps($T2)+deps($T3)+[...])
```

is equivalent to, but generally much slower than

```
buildfiles(deps($T1+$T2+$T3+[...]))
```

PiperOrigin-RevId: 389912462
(cherry picked from commit a5ef86e)

* Swap to build and test with Xcode 12.5.1

Also fix an issue with the OSS tests.

PiperOrigin-RevId: 390164332
(cherry picked from commit d1a4d3c)

#  Conflicts:
# 	.bazelci/presubmit.yml
# 	.bazelrc
# 	WORKSPACE

* Updates version number to 0.4.391542404.20210818.

Significant changes:
- Improved performance when querying for BUILD/bzl files

PiperOrigin-RevId: 391546363
(cherry picked from commit 53d31b0)

* Slight tweaks to build flags used for project generation

- Use the newer `--run_validations` flag
- Disable the `dsyms` output group that some folks might manually enable by accident

PiperOrigin-RevId: 393791135
(cherry picked from commit 043040df1bc175b5f71d7af80877af0fa98e28f1)

* Updates version number to 0.4.396915249.20210915.

PiperOrigin-RevId: 396918740
(cherry picked from commit f151befb3900ae1f122fdf5a4dc2b0870dffd95c)

* Update iOS sim device to use for E2E tests

Updated to be in sync with our current Xcode target of Xcode 12.5.1

PiperOrigin-RevId: 399783838
(cherry picked from commit a3dec4cc165ca4044215f523bac06b1bf7623861)

* Update Tulsi to Xcode 13.0.

PiperOrigin-RevId: 404053261
(cherry picked from commit 4fd4d4caa99220b55fb592488bddc89c73b86d22)

* Automatic code cleanup.

PiperOrigin-RevId: 406138012
(cherry picked from commit 152959785010edc7cc99afde2bbb5e6a54f0a5bf)

* Fix some warnings in the Tulsi module

Also remove some sneaky semicolons.

PiperOrigin-RevId: 406397098
(cherry picked from commit fe0cc3c1f39cf9d66346dbba45f795900e1b9a73)

* Fix some warnings in TulsiGenerator + a xib

Just have some hashable warnings left now plus
2 xibs with clipping warnings.

PiperOrigin-RevId: 407392908
(cherry picked from commit ec25d2f8b4076d7bfeb17ae1b5a925e3dc512aa1)

* Updates version number to 0.4.408971104.20211110.

PiperOrigin-RevId: 408976515
(cherry picked from commit 619e87e1db4c72a59a37803978bd9eba06cea2db)

* Add GitHub Actions

* Use rules_apple and rules_swift at HEADs

* Update golden

* Revert "Revert "Point External Paths into Stable External Directory instead of Unstable Execroot (#255)""

This reverts commit c681436feee92d038b6cf87343771ffae667afc2.

* Point to master branch for the reusing workflow

* remove unused file

* use bazel 5.0.0rc1

* Fix tulsi tests after unknown commit.

PiperOrigin-RevId: 411826911
(cherry picked from commit 45060a05093fd8614680d298456b78ae2d381986)

* Fix signing of test runners with Xcode 13

Xcode 13 adds new frameworks which are injected into the test runner.
These must be resigned as well otherwise the app will fail to install
due to a certificate expired/revoked error.

PiperOrigin-RevId: 417654389
(cherry picked from commit 7ff52cd4f8482bac6db148be1c5dea3408a7dd80)

* Add UseLegacyBuildSystem option to swap between new/old build systems

The new build system isn't officially supported yet, so I've added
this flag in preparation for support although it's `true` (legacy)
by default.

This should supplement #277 although I haven't thoroughly tested the new build system support (especially on device + for tests) yet.

PiperOrigin-RevId: 417654737
(cherry picked from commit 2cbc9236818025b471689bd8a1810e6c0655a18a)

* Use `--noexperimental_run_validations` instead of `--norun_validations` to make Tulsi works with projects that are still using Bazel 4 (#297)

Note that building Tulsi itself still requires Bazel 5.0+.

* fix conflict merge

* reset makefile

* Update Tulsi python 2.7 scripts to python 3. This will silence the warning that Tulsi needs to be updated when running on macOS Big Sur or newer.

PiperOrigin-RevId: 419846379
(cherry picked from commit 81a5f30fdcb035b3b4e7b53fe27c8d668c5c9f36)

* Increase timeout of //src/TulsiGeneratorIntegrationTests:EndToEndGenerationTests

GitHub Actions provides not so high spec macOS instances, which makes
this test easy to reach the previous timeout setting (900s).

* Updates version number to 0.4.419907671.20220105.

Significant changes:
- Fixed issue running UI tests on device with Xcode 13.

PiperOrigin-RevId: 419910944
(cherry picked from commit 8f850c2aca9d369ec50bbdde9efd82a66abde30c)

* minor README updates (#298)

clarify that the current installation requires cloning the entire project

* Add minimum bazel version check (#302)

This validates folks who are building tulsi don't hit surprising errors.
We should bump this over time

* Update rules_apple (#281)

* reenable TulsiGeneratorTests

* Switch back to building with latest Bazel (#306)

* Move the attributes for which Tulsi will search for dependencies into a separate file and add a function that computes the subset of those attributes for a given rule kind.

PiperOrigin-RevId: 420149963
(cherry picked from commit acb9f1c0cef59064a40825161e9621edd825918e)

* Add the ability to specify extra build flags via the CLI during project generation

We'll use + test this ourselves during the E2E generation tests.

PiperOrigin-RevId: 424868778
(cherry picked from commit c305374b0a9be7fcdf3f0f146ef8dc1b12546cc0)

* Fetch E2E build flags from the BazelIntegrationTestCase

This avoids the needs to use a separate file for the build flags.

Note the number of indexer targets changed since CppLib and ObjCLib
are no longer built for iOS 10.

PiperOrigin-RevId: 425623765
(cherry picked from commit 9652ca7468416573b7b7f2a398e09963f24b0e8a)

* Update to build with Xcode 13.2.1

Need to bump rules_apple + Bazel requirement since we require a flag new in Bazel 5
for our tests.

PiperOrigin-RevId: 425968191
(cherry picked from commit 81d85ec1ca222bef40601193909e19812020a30c)

* Update GitHub Actions' `xcode_version` config to 13.2.1

* Fix minor warning in TulsiGenerator

Only warnings left now are hashValue, which are a bit more complicated
to fix due to our usage in PBXObjectProtocol.

PiperOrigin-RevId: 426146113
(cherry picked from commit 0ea4f83afa7f378294c642e9c7994d5ce33335e0)

* Updates version number to 0.4.427587075.20220209.

Significant changes:
- Extra build flags can now be specified during project
  generation via `--build-options`, e.g. `--build-options
  "--keep_going --verbose_failures"`
- Fix a warning about root-level library targets that was being
  printed under incorrect conditions.

PiperOrigin-RevId: 427737504
(cherry picked from commit d4d0e2cd7a8f3ecff3a8efda0fb43c4f470564d5)

* Do not override user-defined output groups

Since Tulsi appends this flag to the build command,
`--output_groups=tulsi_outputs,default` would override any previously
defined `--output_groups` flag.

From the
[documentation](https://bazel.build/reference/command-line-reference#flag--output_groups):
`--output_groups=+foo,+bar` builds the union of the `default` set,
`foo`, and `bar`, while `--output_groups=foo,bar` overrides the default
set such that only `foo` and `bar` are built.

* Add swiftsourceinfo/swiftdoc to list of copied includes (#317)

* Use an unreleased revision of rules_apple for now (#319)

To work around the drop of `should_lipo` in
`apple_common.link_multi_arch_binary`.

* Add support for stub binaries

Currently this will only be used if the `UseLegacyBuildSystem` option
is false.

PiperOrigin-RevId: 428076981
(cherry picked from commit 0fb177476c76043167546a9a7b3aae692738e1b0)

* fix build file

Co-authored-by: Christopher Sauer <cpsauer@users.noreply.github.com>
Co-authored-by: Thi Doãn <t@thi.im>
Co-authored-by: Googler <noreply@google.com>
Co-authored-by: ivanhernandez <ivanhernandez@google.com>
Co-authored-by: davg <davg@google.com>
Co-authored-by: nglevin <nglevin@google.com>
Co-authored-by: Roland <skofgar@users.noreply.github.com>
Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
Co-authored-by: Erik Kerber <ekerber@slack-corp.com>
  • Loading branch information
10 people authored Mar 15, 2022
1 parent 9cbf256 commit 3bdbc5e
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 99 deletions.
25 changes: 6 additions & 19 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# TODO: Remove once https://github.com/bazelbuild/bazel-skylib/pull/307 is merged and patch is removed from rules_apple
http_archive(
name = "io_bazel_stardoc",
sha256 = "f89bda7b6b696c777b5cf0ba66c80d5aa97a6701977d43789a9aee319eef71e8",
strip_prefix = "stardoc-d93ee5347e2d9c225ad315094507e018364d5a67",
url = "https://github.com/bazelbuild/stardoc/archive/d93ee5347e2d9c225ad315094507e018364d5a67.tar.gz",
)

# TODO: Remove with next rules_swift + rules_apple release
http_archive(
name = "build_bazel_rules_swift",
sha256 = "fff70e28e9b28a4249fbfb413f860cb9b5df567fe20a1bc4017dd89e678dd9b5",
strip_prefix = "rules_swift-35ddf9f6e8c0fcd8bcb521e92dd4fd11c3f181b6",
url = "https://github.com/bazelbuild/rules_swift/archive/35ddf9f6e8c0fcd8bcb521e92dd4fd11c3f181b6.tar.gz",
)

# Using a newer revision of rules_apple to work around the drop of
# `should_lipo` in `apple_common.link_multi_arch_binary`.
# TODO: Switch back to a release once rules_apple gets a new release
http_archive(
name = "build_bazel_rules_apple",
sha256 = "2e6c88b66c671b4abb7cebc5d072804d6fc42bd18aa31586b060e2629aae7251",
strip_prefix = "rules_apple-0bba769a9aafe9bd3349b32a326e599553886e98",
url = "https://github.com/bazelbuild/rules_apple/archive/0bba769a9aafe9bd3349b32a326e599553886e98.tar.gz",
sha256 = "1c883b02ac84abe42eb6e9ee0b99aa7f1bad8e1ebda5b2143d6d8cb2014ea4be",
strip_prefix = "rules_apple-2efc349db20823fc64f1487d80943aceee2a6195",
url = "https://github.com/bazelbuild/rules_apple/archive/2efc349db20823fc64f1487d80943aceee2a6195.tar.gz",
)

load(
Expand Down
4 changes: 4 additions & 0 deletions src/Tulsi/HeadlessXcodeProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ struct HeadlessXcodeProjectGenerator {
if let project = projectDocument.project {
config = config.configByResolvingInheritedSettingsFromProject(project)
}
if let extraFlags = arguments.buildOptions {
config.options[.BazelBuildOptionsDebug].appendProjectValue(extraFlags)
config.options[.BazelBuildOptionsRelease].appendProjectValue(extraFlags)
}

let workspaceRootURL: URL
let projectWorkspaceRootURL = projectDocument.workspaceRootURL
Expand Down
11 changes: 6 additions & 5 deletions src/Tulsi/TulsiCommandlineParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class TulsiCommandlineParser {

static let ParamAdditionalPathFilters = "--additionalSourceFilters"
static let ParamBazel = "--bazel"
static let ParamBuildOptions = "--build-options"

// Xcode project generation mode:
static let ParamGeneratorConfigShort = "-c"
Expand All @@ -117,7 +118,6 @@ class TulsiCommandlineParser {
// Tulsi project creation mode:
static let ParamCreateTulsiProj = "--create-tulsiproj"
static let ParamBuildStartupOptions = "--startup-options"
static let ParamBuildOptions = "--build-options"
static let ParamBuildTargetShort = "-t"
static let ParamBuildTargetLong = "--target"

Expand Down Expand Up @@ -194,6 +194,10 @@ class TulsiCommandlineParser {
storeValueAt(i, forArgument: TulsiCommandlineParser.ParamBazel)
i += 1

case TulsiCommandlineParser.ParamBuildOptions:
storeValueAt(i, forArgument: TulsiCommandlineParser.ParamBuildOptions)
i += 1

case TulsiCommandlineParser.ParamOutputFolderShort:
fallthrough
case TulsiCommandlineParser.ParamOutputFolderLong:
Expand Down Expand Up @@ -242,10 +246,6 @@ class TulsiCommandlineParser {
storeValueAt(i, forArgument: TulsiCommandlineParser.ParamBuildStartupOptions)
i += 1

case TulsiCommandlineParser.ParamBuildOptions:
storeValueAt(i, forArgument: TulsiCommandlineParser.ParamBuildOptions)
i += 1

case TulsiCommandlineParser.ParamBuildTargetShort:
fallthrough
case TulsiCommandlineParser.ParamBuildTargetLong:
Expand Down Expand Up @@ -285,6 +285,7 @@ class TulsiCommandlineParser {
" is equivalent to ",
" \"MyProject.tulsiproj:MyProject\"",
" \(ParamNoOpenXcode): Do not automatically open the generated project in Xcode.",
" \(ParamBuildOptions) <options>: Extra Bazel build options to add.",
"",
" \(ParamCreateTulsiProj) <tulsiproj_bundle_name>:",
" Generates a Tulsi project suitable for building the given Bazel target.",
Expand Down
1 change: 1 addition & 0 deletions src/TulsiGenerator/Bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ apple_resource_group(
structured_resources = [
"tulsi/tulsi_aspects.bzl",
"tulsi/tulsi_aspects_paths.bzl",
"tulsi/tulsi_aspects_propagation_attrs.bzl",
],
)
44 changes: 14 additions & 30 deletions src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ load(
"IosExtensionBundleInfo",
"SwiftInfo",
)
load(
":tulsi/tulsi_aspects_propagation_attrs.bzl",
"TULSI_COMPILE_DEPS",
"attrs_for_target_kind",
)
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

ObjcInfo = apple_common.Objc
Expand All @@ -42,31 +47,6 @@ UNSUPPORTED_FEATURES = [
"fdo_optimize",
]

# List of all of the attributes that can link from a Tulsi-supported rule to a
# Tulsi-supported dependency of that rule.
# For instance, an ios_application's "binary" attribute might link to an
# objc_binary rule which in turn might have objc_library's in its "deps"
# attribute.
_TULSI_COMPILE_DEPS = [
"app_clips", # For ios_application which can include app clips.
"bundles",
"deps",
"extension",
"extensions",
"frameworks",
"settings_bundle",
"srcs", # To propagate down onto rules which generate source files.
"tests", # for test_suite when the --noexpand_test_suites flag is used.
"_implicit_tests", # test_suites without a `tests` attr have an '$implicit_tests' attr instead.
"test_host",
"additional_contents", # macos_application can specify a dict with supported rules as keys.
# Special attribute name which serves as an escape hatch intended for custom
# rule creators who use non-standard attribute names for rule dependencies
# and want those dependencies to show up in Xcode.
"tulsi_deps",
"watch_application",
]

# These are attributes that contain bundles but should not be considered as
# embedded bundles. For example, test bundles depend on app bundles
# to be test hosts in bazel semantics, but in reality, Xcode treats the test
Expand Down Expand Up @@ -124,6 +104,8 @@ _GENERATED_SOURCE_FILE_EXTENSIONS = [
"mm",
"swift",
"swiftmodule",
"swiftsourceinfo",
"swiftdoc",
]

TulsiSourcesAspectInfo = provider(
Expand Down Expand Up @@ -735,12 +717,13 @@ def _tulsi_sources_aspect(target, ctx):
"""Extracts information from a given rule, emitting it as a JSON struct."""
rule = ctx.rule
target_kind = rule.kind
attrs = attrs_for_target_kind(ctx.rule.kind)
rule_attr = _get_opt_attr(rule, "attr")
filter = _filter_for_rule(rule)

transitive_info_files = []
transitive_attributes = dict()
for attr_name in _TULSI_COMPILE_DEPS:
for attr_name in attrs:
deps = _collect_dependencies(rule_attr, attr_name)
for dep in _filter_deps(filter, deps):
if TulsiSourcesAspectInfo in dep:
Expand Down Expand Up @@ -782,7 +765,7 @@ def _tulsi_sources_aspect(target, ctx):

# Collect the dependencies of this rule, dropping any .jar files (which may be
# created as artifacts of java/j2objc rules).
dep_labels = _collect_dependency_labels(rule, filter, _TULSI_COMPILE_DEPS)
dep_labels = _collect_dependency_labels(rule, filter, attrs)
compile_deps = [str(d) for d in dep_labels if not d.name.endswith(".jar")]

supporting_files = (_collect_supporting_files(rule_attr) +
Expand Down Expand Up @@ -1101,6 +1084,7 @@ def _tulsi_outputs_aspect(target, ctx):

rule = ctx.rule
target_kind = rule.kind
attrs = attrs_for_target_kind(ctx.rule.kind)
rule_attr = _get_opt_attr(rule, "attr")
transitive_generated_files = []

Expand All @@ -1116,7 +1100,7 @@ def _tulsi_outputs_aspect(target, ctx):
# A list of all explicit modules that have been built from this targets dependencies.
transitive_explicit_modules = []

for attr_name in _TULSI_COMPILE_DEPS:
for attr_name in attrs:
deps = _collect_dependencies(rule_attr, attr_name)
for dep in deps:
if TulsiOutputAspectInfo in dep:
Expand Down Expand Up @@ -1244,7 +1228,7 @@ def _tulsi_outputs_aspect(target, ctx):
]

tulsi_sources_aspect = aspect(
attr_aspects = _TULSI_COMPILE_DEPS,
attr_aspects = TULSI_COMPILE_DEPS,
attrs = {
"_tulsi_xcode_config": attr.label(default = configuration_field(
name = "xcode_config_label",
Expand All @@ -1266,7 +1250,7 @@ tulsi_sources_aspect = aspect(
# This aspect does not propagate past the top-level target because we only need
# the top target outputs.
tulsi_outputs_aspect = aspect(
attr_aspects = _TULSI_COMPILE_DEPS,
attr_aspects = TULSI_COMPILE_DEPS,
attrs = {
"_cc_toolchain": attr.label(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
Expand Down
41 changes: 41 additions & 0 deletions src/TulsiGenerator/Bazel/tulsi/tulsi_aspects_propagation_attrs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2022 The Tulsi Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Attributes to propagate into for Tulsi aspects."""

# List of all of the attributes that can link from a Tulsi-supported rule to a
# Tulsi-supported dependency of that rule.
TULSI_COMPILE_DEPS = [
"app_clips", # For ios_application which can include app clips.
"bundles",
"deps",
"extension",
"extensions",
"frameworks",
"settings_bundle",
"srcs", # To propagate down onto rules which generate source files.
"tests", # for test_suite when the --noexpand_test_suites flag is used.
"_implicit_tests", # test_suites without a `tests` attr have an '$implicit_tests' attr instead.
"test_host",
"additional_contents", # macos_application can specify a dict with supported rules as keys.
# Special attribute name which serves as an escape hatch intended for custom
# rule creators who use non-standard attribute names for rule dependencies
# and want those dependencies to show up in Xcode.
"tulsi_deps",
"watch_application",
]

def attrs_for_target_kind(rule_kind):
"""Returns the attrs we should propagate/collect for the given target."""
return TULSI_COMPILE_DEPS
6 changes: 5 additions & 1 deletion src/TulsiGenerator/PBXObjects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ final class PBXShellScriptBuildPhase: PBXBuildPhase {
let outputPaths: [String]
let shellPath: String
let shellScript: String
let name: String?
var showEnvVarsInLog = false

override var isa: String {
Expand All @@ -633,17 +634,19 @@ final class PBXShellScriptBuildPhase: PBXBuildPhase {
private let _hashValue: Int

override var comment: String? {
return "ShellScript"
return name ?? "ShellScript"
}

init(shellScript: String,
shellPath: String = "/bin/sh",
name: String?,
inputPaths: [String] = [String](),
outputPaths: [String] = [String](),
buildActionMask: Int = 0,
runOnlyForDeploymentPostprocessing: Bool = false) {
self.shellScript = shellScript
self.shellPath = shellPath
self.name = name
self.inputPaths = inputPaths
self.outputPaths = outputPaths
self._hashValue = shellPath.hashValue &+ shellScript.hashValue
Expand All @@ -656,6 +659,7 @@ final class PBXShellScriptBuildPhase: PBXBuildPhase {
try super.serializeInto(serializer)
try serializer.addField("inputPaths", inputPaths)
try serializer.addField("outputPaths", outputPaths)
try serializer.addField("name", name)
try serializer.addField("shellPath", shellPath)
try serializer.addField("shellScript", shellScript)
try serializer.addField("showEnvVarsInLog", showEnvVarsInLog)
Expand Down
Loading

0 comments on commit 3bdbc5e

Please sign in to comment.