apple_bundle_version(name, build_label_pattern, build_version, capture_groups,
short_version_string)
Produces a target that contains versioning information for an Apple bundle.
This rule allows version numbers to be hard-coded into the BUILD file or
extracted from the build label passed into Bazel using the --embed_label
command line flag.
Targets created by this rule do not generate outputs themselves, but instead
should be used in the version
attribute of an Apple application or extension
bundle target to set the version keys in that bundle's Info.plist file.
# A version scheme that uses hard-coded versions checked into your
# BUILD files.
apple_bundle_version(
name = "simple",
build_version = "1.0.134",
short_version_string = "1.0",
)
ios_application(
name = "foo_app",
...,
version = ":simple",
)
# A version scheme that parses version information out of the build
# label. For example, the following command
#
# bazel build //myapp:myapp --embed_label=MyApp_1.2_build_345
#
# would yield the Info.plist values:
#
# CFBundleVersion = "1.2.345"
# CFBundleShortVersionString = "1.2"
#
apple_bundle_version(
name = "build_label_version",
build_label_pattern = "MyApp_{version}_build_{build}",
build_version = "{version}.{build}",
capture_group = {
"version": "\d+\.\d+",
"build": "\d+",
},
short_version_string = "{version}",
)
ios_application(
name = "bar_app",
...,
version = ":build_label_version",
)
Attributes | |
---|---|
name |
A unique name for the target. |
build_label_pattern |
A pattern that should contain placeholders inside curly braces
(e.g., |
build_version |
A string that will be used as the value for the
|
capture_groups |
A dictionary where each key is the name of a placeholder found
in |
short_version_string |
A string that will be used as the value for the
|
Variation of genrule
that provides an Apple-specific environment and make
variables. This rule will only run on macOS.
This rule takes the same attributes as Bazel's native genrule
; please refer to
its
documentation
for a full description of those attributes.
Example of use:
load("@build_bazel_rules_apple//apple:apple_genrule.bzl", "apple_genrule")
apple_genrule(
name = "world",
outs = ["hi"],
cmd = "touch $(@)",
)
This rule also does location expansion, much like the native genrule
. For
example, $(location hi)
may be used to refer to the output in the above
example.
The set of make
variables that are supported for this rule:
$OUTS
: Theouts
list. If you have only one output file, you can also use$@
.$SRCS
: Thesrcs
list (or more precisely, the path names of the files corresponding to labels in thesrcs
list). If you have only one source file, you can also use$<
.$<
:srcs
, if it's a single file.$@
:outs
, if it's a single file.
The following environment variables are added to the rule action:
$DEVELOPER_DIR
: The base developer directory as defined on Apple architectures, most commonly used in invoking Apple tools such asxcrun
.