Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2490)

Unified Diff: build/config/mac/base_rules.gni

Issue 2475893002: Add template to compile plist files. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/mac/base_rules.gni
diff --git a/build/config/mac/base_rules.gni b/build/config/mac/base_rules.gni
index 8adb6cca5205192f943390a4afb3e5f629d17bc8..074074eb347f1eb73e1b31e32a7a6f4711ebd52c 100644
--- a/build/config/mac/base_rules.gni
+++ b/build/config/mac/base_rules.gni
@@ -56,48 +56,41 @@ template("convert_plist") {
}
}
-# The base template used to generate Info.plist files for iOS and Mac apps and
-# frameworks.
+# Template to merge multiple plist files and perform variable substitutions.
#
# Arguments
#
# plist_templates:
# string array, paths to plist files which will be used for the bundle.
#
-# executable_name:
-# string, name of the generated target used for the product
-# and executable name as specified in the output Info.plist.
-#
# format:
# string, the format to `plutil -convert` the plist to when
# generating the output.
#
-# extra_substitutions:
-# (optional) string array, 'key=value' pairs for extra fields which are
-# specified in a source Info.plist template.
+# substitutions:
+# string array, 'key=value' pairs used to replace ${key} by value
+# when generating the output plist file.
#
# output_name:
-# (optional) string, name of the generated plist file, default to
-# "$target_gen_dir/$target_name.plist".
-template("info_plist") {
+# string, name of the generated plist file.
+template("compile_plist") {
assert(defined(invoker.plist_templates),
"A list of template plist files must be specified for $target_name")
- assert(defined(invoker.executable_name),
- "The executable_name must be specified for $target_name")
assert(defined(invoker.format),
"The plist format must be specified for $target_name")
- executable_name = invoker.executable_name
-
- _output_name = "$target_gen_dir/$target_name.plist"
- if (defined(invoker.output_name)) {
- _output_name = invoker.output_name
- }
+ assert(defined(invoker.substitutions),
+ "A list of key=value pairs must be specified for $target_name")
+ assert(defined(invoker.output_name),
+ "The name of the output file must be specified for $target_name")
+ _output_name = invoker.output_name
_merged_name = get_path_info(_output_name, "dir") + "/" +
- get_path_info(_output_name, "name") + "_merged" +
+ get_path_info(_output_name, "name") + "_merged." +
get_path_info(_output_name, "extension")
- action(target_name + "_merge_templates") {
+ _merge_target = target_name + "_merge"
+
+ action(_merge_target) {
forward_variables_from(invoker,
[
"deps",
@@ -113,7 +106,7 @@ template("info_plist") {
"merge",
"-f=" + invoker.format,
"-o=" + rebase_path(_merged_name, root_build_dir),
- ] + rebase_path(sources, root_build_dir)
+ ] + rebase_path(invoker.plist_templates, root_build_dir)
}
action(target_name) {
@@ -129,29 +122,79 @@ template("info_plist") {
outputs = [
_output_name,
]
- args = [ "substitute" ]
- if (defined(invoker.extra_substitutions)) {
- foreach(substitution, invoker.extra_substitutions) {
- args += [ "-s=$substitution" ]
- }
- }
- args += [
- "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
- "-s=EXECUTABLE_NAME=$executable_name",
- "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
- "-s=PRODUCT_NAME=$executable_name",
- "-s=XCODE_BUILD=$xcode_build",
- "-s=XCODE_VERSION=$xcode_version",
+ args = [
+ "substitute",
+ "-f=" + invoker.format,
"-o=" + rebase_path(_output_name, root_build_dir),
"-t=" + rebase_path(_merged_name, root_build_dir),
- "-f=" + invoker.format,
]
+ foreach(_substitution, invoker.substitutions) {
+ args += [ "-s=$_substitution" ]
+ }
deps = [
- ":" + target_name + "_merge_templates",
+ ":$_merge_target",
]
}
}
+# The base template used to generate Info.plist files for iOS and Mac apps and
+# frameworks.
+#
+# Arguments
+#
+# plist_templates:
+# string array, paths to plist files which will be used for the bundle.
+#
+# executable_name:
+# string, name of the generated target used for the product
+# and executable name as specified in the output Info.plist.
+#
+# format:
+# string, the format to `plutil -convert` the plist to when
+# generating the output.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+#
+# output_name:
+# (optional) string, name of the generated plist file, default to
+# "$target_gen_dir/$target_name.plist".
+template("info_plist") {
+ assert(defined(invoker.executable_name),
+ "The executable_name must be specified for $target_name")
+ executable_name = invoker.executable_name
+
+ compile_plist(target_name) {
+ forward_variables_from(invoker,
+ [
+ "plist_templates",
+ "testonly",
+ "deps",
+ "visibility",
+ "format",
+ ])
+
+ if (defined(invoker.output_name)) {
+ output_name = invoker.output_name
+ } else {
+ output_name = "$target_gen_dir/$target_name.plist"
+ }
+
+ substitutions = [
+ "BUILD_MACHINE_OS_BUILD=$machine_os_build",
+ "EXECUTABLE_NAME=$executable_name",
+ "GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
+ "PRODUCT_NAME=$executable_name",
+ "XCODE_BUILD=$xcode_build",
+ "XCODE_VERSION=$xcode_version",
+ ]
+ if (defined(invoker.extra_substitutions)) {
+ substitutions += invoker.extra_substitutions
+ }
+ }
+}
+
# Template to combile .xib or .storyboard files.
#
# Arguments
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698