Skip to content

Commit

Permalink
Update for multiple targets
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Aug 5, 2019
1 parent 72ba222 commit 107c3ac
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
27 changes: 26 additions & 1 deletion apple/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,32 @@ filegroup(
)

environment_plist(
name = "environment_plist",
name = "environment_plist_ios",
platform_type = "ios",
visibility = [
"//visibility:public",
],
)

environment_plist(
name = "environment_plist_macos",
platform_type = "macos",
visibility = [
"//visibility:public",
],
)

environment_plist(
name = "environment_plist_watchos",
platform_type = "watchos",
visibility = [
"//visibility:public",
],
)

environment_plist(
name = "environment_plist_tvos",
platform_type = "tvos",
visibility = [
"//visibility:public",
],
Expand Down
13 changes: 4 additions & 9 deletions apple/internal/environment_plist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,20 @@ load(
)

def _environment_plist(ctx):
environment_plist = ctx.actions.declare_file(
paths.join("{}-intermediates".format(ctx.label.name), "Environment-Info.plist"),
)

platform, sdk_version = platform_support.platform_and_sdk_version(ctx)
platform_with_version = platform.name_in_plist.lower() + str(sdk_version)
legacy_actions.run(
ctx,
outputs = [environment_plist],
outputs = [ctx.outputs.plist],
executable = ctx.executable._environment_plist,
arguments = [
"--platform",
platform_with_version,
"--output",
environment_plist.path,
ctx.outputs.plist.path,
],
)

return [DefaultInfo(files = depset([environment_plist]))]

environment_plist = rule(
attrs = dicts.add(
rule_factory.common_tool_attributes,
Expand All @@ -49,9 +43,10 @@ environment_plist = rule(
executable = True,
default = Label("@build_bazel_rules_apple//tools/environment_plist"),
),
"platform_type": attr.string(default = str(apple_common.platform_type.ios)),
"platform_type": attr.string(mandatory = True),
},
),
fragments = ["apple"],
outputs = {"plist": "%{name}.plist"},
implementation = _environment_plist,
)
10 changes: 4 additions & 6 deletions apple/internal/resource_actions/plist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,18 @@ def merge_root_infoplists(
else:
plist_key = "MinimumOSVersion"

if hasattr(ctx.attr, "_environment_plist"):
input_files.extend(ctx.attr._environment_plist.files.to_list())
forced_plists.extend([x.path for x in ctx.attr._environment_plist.files.to_list()])

input_files.append(ctx.file._environment_plist)
platform, sdk_version = platform_support.platform_and_sdk_version(ctx)
platform_with_version = platform.name_in_plist.lower() + str(sdk_version)
forced_plists.append(
forced_plists.extend([
ctx.file._environment_plist.path,
struct(
CFBundleSupportedPlatforms = [platform.name_in_plist],
DTPlatformName = platform.name_in_plist.lower(),
DTSDKName = platform_with_version,
**{plist_key: platform_support.minimum_os(ctx)}
),
)
])

output_files = [output_plist]
if output_pkginfo:
Expand Down
15 changes: 8 additions & 7 deletions apple/internal/rule_factory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,6 @@ in the bundle.
doc = """
An `apple_bundle_version` target that represents the version for this target. See
[`apple_bundle_version`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-general.md?cl=head#apple_bundle_version).
""",
),
"_environment_plist": attr.label(
default = "@build_bazel_rules_apple//apple/internal:environment_plist",
doc = """
A generated Info.plist containing environment information required for uploading
builds to Apple.
""",
),
})
Expand Down Expand Up @@ -834,6 +827,10 @@ def _create_apple_binary_rule(implementation, platform_type, product_type, doc):
# API.
"platform_type": attr.string(default = platform_type),
"_product_type": attr.string(default = product_type),
"_environment_plist": attr.label(
allow_single_file = True,
default = "@build_bazel_rules_apple//apple/internal:environment_plist_{}".format(platform_type),
),
},
]

Expand Down Expand Up @@ -870,6 +867,10 @@ def _create_apple_bundling_rule(implementation, platform_type, product_type, doc
# API.
"platform_type": attr.string(default = platform_type),
"_product_type": attr.string(default = product_type),
"_environment_plist": attr.label(
allow_single_file = True,
default = "@build_bazel_rules_apple//apple/internal:environment_plist_{}".format(platform_type),
),
},
]

Expand Down

0 comments on commit 107c3ac

Please sign in to comment.