Skip to content
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

Merged
merged 7 commits into from
Jun 12, 2020

Conversation

segiddins
Copy link
Member

This way, their artifacts can be shared across multiple apps/test targets, regardless of the deployment targets used in the final packaged product

segiddins added 2 commits June 8, 2020 18:54
# Conflicts:
#	rules/framework.bzl
#	rules/xcodeproj.bzl
rules/library.bzl Outdated Show resolved Hide resolved
rules/precompiled_apple_resource_bundle.bzl Outdated Show resolved Hide resolved
tests/framework/platforms/BUILD.bazel Outdated Show resolved Hide resolved
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member Author

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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"
Copy link
Member Author

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

Copy link
Member Author

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

@segiddins segiddins requested a review from ob June 10, 2020 00:09
@segiddins segiddins marked this pull request as ready for review June 10, 2020 00:09
@segiddins segiddins force-pushed the segiddins/precomp-resources-shared-frameworks branch from 5a3ff81 to 6964eca Compare June 10, 2020 00:17
Copy link
Member

@ob ob left a 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
Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

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.",
Copy link
Member

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,
Copy link
Member

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?

Copy link
Member Author

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"?>
Copy link
Member

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]),
Copy link
Member Author

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

@segiddins
Copy link
Member Author

Do we have concerns about blowing up the build graph by using transitions?

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,
Copy link
Collaborator

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),

Copy link
Collaborator

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!

Copy link
Collaborator

@amberdixon amberdixon left a comment

Choose a reason for hiding this comment

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

resources_to_bundle = glob(["Resources/**/*"]),
)

make_applications(
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator

@amberdixon amberdixon left a 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:

  1. 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.
  2. resource bundle rules change to avoid unnecessarily rebuilding resource bundles
  3. 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.

@segiddins segiddins merged commit 70a5b7a into master Jun 12, 2020
@segiddins segiddins deleted the segiddins/precomp-resources-shared-frameworks branch June 12, 2020 18:51
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.

3 participants