-
Notifications
You must be signed in to change notification settings - Fork 90
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
Build frameworks/resource_bundles behind a transition #73
Build frameworks/resource_bundles behind a transition #73
Conversation
# Conflicts: # rules/framework.bzl # rules/xcodeproj.bzl
@@ -1,8 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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.
Deleted since I don't think these files actually get generated anywhere (except maybe by Xcode)
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.
cc @amberdixon
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.
+1
cp -r "${project_path}" "$tmp_dest" | ||
chmod -R +w "${tmp_dest}" | ||
|
||
readonly stubs_dir="${tmp_dest}/bazelstubs" |
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.
installing the stubs into the tmp dir means they will get chmod'd, allowing them to be overwritten by subsequent invocations
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.
cc @amberdixon this is the change I showed you on Tuesday
5a3ff81
to
6964eca
Compare
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.
Do we have concerns about blowing up the build graph by using transitions?
I also hit a strange problem where I had to remove shallow_since
form the rules_apple
repository or git wouldn't find the commit specified in repositories.bzl
. Unrelated but I thought it might be worth mentioning it.
visibility = kwargs.get("visibility", None), | ||
tags = kwargs.get("tags", None), | ||
platforms = library.platforms, | ||
**framework_packaging_kwargs |
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.
Heh, cute.
output_plist = ctx.actions.declare_file( | ||
paths.join("%s-intermediates" % ctx.label.name, "Info.plist"), | ||
) | ||
bundle_id = ctx.attr.bundle_id or "com.cocoapods." + bundle_name |
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.
Would it make sense to make the bundle_id
required instead of providing a default?
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.
Maybe? We could push the default out to the apple_library
macro if you think that's better, but we do need a default at some layer
), | ||
bundle_id = attr.string( | ||
mandatory = False, | ||
doc = "The bundle identifier of the resource bundle.", |
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.
Or if we are providing a default (which I suggest we don't) it should be documented here.
_FAKE_BUNDLE_PRODUCT_TYPE_BY_PLATFORM_TYPE = { | ||
"ios": apple_product_type.application, | ||
"tvos": apple_product_type.application, | ||
"watchos": apple_product_type.watch2_application, |
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.
Should we add macos
here since why not?
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.
macos is tested, it just doesnt need a fake bundle product type since the rule descriptors have one for a macos resource bundle
@@ -1,8 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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.
+1
tags = _MANUAL, | ||
) | ||
apple_resource_bundle( | ||
precompiled_apple_resource_bundle( | ||
name = target_name, | ||
bundle_name = bundle_name, | ||
resources = [ | ||
library_tools["wrap_resources_in_filegroup"](name = target_name + "_resources", srcs = resource_bundles[bundle_name]), |
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.
In a follow-up, it would be nice to get rid of this extra target as well
I think that this will actually shrink the build graph, because it's an incoming edge transition rather than an outgoing one. Before, we could build a framework (and therefore its library targets) N times, depending on what app/test binary was linking it in. Now, it's guaranteed to only be built once per platform when an explicit list of platform/deployment target pairs is passed in. |
minimum_os_version = str(current_apple_platform.target_os_version), | ||
platform_type = str(current_apple_platform.platform.platform_type), | ||
product_type = ctx.attr._product_type, | ||
uses_swift = swiftmodule_out != None, |
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.
nit, can you add parens here to keep the order of operations obvious?
suggestion:
uses_swift = (swiftmodule_out != None),
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.
I hope the RHS doesn't turn into an array/tuple if you do that!
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.
For other reviewers, I found the following bazel docs helpful when reviewing this PR:
https://docs.bazel.build/versions/master/skylark/lib/transition.html
https://docs.bazel.build/versions/master/skylark/config.html
https://docs.bazel.build/versions/master/skylark/config.html#incoming-edge-transitions
resources_to_bundle = glob(["Resources/**/*"]), | ||
) | ||
|
||
make_applications( |
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.
Did you confirm that this application would fail to run, if this transition was not applied?
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.
Yes
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.
LGTM! Looks like this PR does 3 things, correct my understanding if I'm wrong:
- adding a transition to change configs during dep graph traversal. Specifically, changes the configuration when traversing from a dependency of a framework to the framework packaging target.
- resource bundle rules change to avoid unnecessarily rebuilding resource bundles
- light xcodeproj changes to consume BundleInfo for frameworks through the framework rule's providers and fix up the installer to write the generated project to a tmpdir.
This way, their artifacts can be shared across multiple apps/test targets, regardless of the deployment targets used in the final packaged product