[apple] Rename the code-signing properties of create_bundle To support the NLU training step for Swift intents, a more generic post-processing step will have to be applied to application bundle. Rename `code_signing_$var` properties of the create_bundle targets to `post_processing_$var` and update the documentation. Change the code loading the properties for the target to still look them under the old name to avoid breaking Chromium when this roll changes. Bug: none Change-Id: Ia005180f85fb073075c7005ab8083045cc4d67b1 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/16960 Reviewed-by: Brett Wilson <brettw@google.com> Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
diff --git a/docs/reference.md b/docs/reference.md index 4d912b6..81f58e8 100644 --- a/docs/reference.md +++ b/docs/reference.md
@@ -108,10 +108,10 @@ * [cflags_objc: [string list] Flags passed to the Objective C compiler.](#var_cflags_objc) * [cflags_objcc: [string list] Flags passed to the Objective C++ compiler.](#var_cflags_objcc) * [check_includes: [boolean] Controls whether a target's files are checked.](#var_check_includes) - * [code_signing_args: [string list] Arguments passed to code signing script.](#var_code_signing_args) - * [code_signing_outputs: [file list] Output files for code signing step.](#var_code_signing_outputs) - * [code_signing_script: [file name] Script for code signing.](#var_code_signing_script) - * [code_signing_sources: [file list] Sources for code signing step.](#var_code_signing_sources) + * [code_signing_args: [string list] [deprecated] Args for the post-processing script.](#var_code_signing_args) + * [code_signing_outputs: [file list] [deprecated] Outputs of the post-processing step.](#var_code_signing_outputs) + * [code_signing_script: [file name] [deprecated] Script for the post-processing step.](#var_code_signing_script) + * [code_signing_sources: [file list] [deprecated] Sources for the post-processing step.](#var_code_signing_sources) * [complete_static_lib: [boolean] Links all deps into a static library.](#var_complete_static_lib) * [configs: [label list] Configs applying to this target or config.](#var_configs) * [contents: Contents to write to file.](#var_contents) @@ -145,6 +145,10 @@ * [outputs: [file list] Output files for actions and copy targets.](#var_outputs) * [partial_info_plist: [filename] Path plist from asset catalog compiler.](#var_partial_info_plist) * [pool: [string] Label of the pool used by binary targets and actions.](#var_pool) + * [post_processing_args: [string list] Args for the post-processing script.](#var_post_processing_args) + * [post_processing_outputs: [file list] Outputs of the post-processing step.](#var_post_processing_outputs) + * [post_processing_script: [file name] Script for the post-processing step.](#var_post_processing_script) + * [post_processing_sources: [file list] Sources for the post-processing step.](#var_post_processing_sources) * [precompiled_header: [string] Header file to precompile.](#var_precompiled_header) * [precompiled_header_type: [string] "gcc" or "msvc".](#var_precompiled_header_type) * [precompiled_source: [file name] Source file to precompile.](#var_precompiled_source) @@ -1748,22 +1752,30 @@ data_deps, however. ``` -#### **Code signing** +#### **Post-processing** ``` - Some bundle needs to be code signed as part of the build (on iOS all - application needs to be code signed to run on a device). The code signature - can be configured via the code_signing_script variable. + Some bundle needs to be post-processed as part of the build (e.g. on iOS all + application needs to be code signed to run on a device). The post processing + step can be configured via the post_processing_script variable. - If set, code_signing_script is the path of a script that invoked after all - files have been moved into the bundle. The script must not change any file in - the bundle, but may add new files. + If set, `post_processing_script` is the path of a script that invoked after + all files have been moved into the bundle. The script must not change any file + in the bundle, but may add new files. - If code_signing_script is defined, then code_signing_outputs must also be - defined and non-empty to inform when the script needs to be re-run. The - code_signing_args will be passed as is to the script (so path have to be - rebased) and additional inputs may be listed with the variable - code_signing_sources. + If `post_processing_script` is defined, then `post_processing_outputs` must + be defined and non-empty to inform when the script needs to be re-run. The + `post_processing_args` will be passed as is to the script (so path have to be + rebased) and additional inputs may be listed via `post_processing_sources`. +``` + +#### **Migration** + +``` + The post-processing step used to be limited to code-signing. The properties + used to be named `code_signing_$name` instead of `post_processing_$name`. The + old names are still accepted as alias to facilitate migration but a warning + will be emitted and the alias eventually be removed. ``` #### **Variables** @@ -1777,9 +1789,10 @@ visibility Bundle vars: bundle_root_dir, bundle_contents_dir, bundle_resources_dir, bundle_executable_dir, bundle_deps_filter, product_type, - code_signing_args, code_signing_script, code_signing_sources, - code_signing_outputs, xcode_extra_attributes, - xcode_test_application_name, partial_info_plist + post_processing_args, post_processing_script, + post_processing_sources, post_processing_outputs, + xcode_extra_attributes, xcode_test_application_name, + partial_info_plist ``` #### **Example** @@ -1853,19 +1866,19 @@ deps = [ ":${app_name}_bundle_info_plist" ] if (is_ios && code_signing) { deps += [ ":${app_name}_generate_executable" ] - code_signing_script = "//build/config/ios/codesign.py" - code_signing_sources = [ + post_processing_script = "//build/config/ios/codesign.py" + post_processing_sources = [ invoker.entitlements_path, "$target_gen_dir/$app_name", ] - code_signing_outputs = [ + post_processing_outputs = [ "$bundle_root_dir/$app_name", "$bundle_root_dir/_CodeSignature/CodeResources", "$bundle_root_dir/embedded.mobileprovision", "$target_gen_dir/$app_name.xcent", ] - code_signing_args = [ - "-i=" + ios_code_signing_identity, + post_processing_args = [ + "-i=" + ios_post_processing_identity, "-b=" + rebase_path( "$target_gen_dir/$app_name", root_build_dir), "-e=" + rebase_path( @@ -5370,39 +5383,55 @@ ... } ``` -### <a name="var_code_signing_args"></a>**code_signing_args**: [string list] Arguments passed to code signing script. +### <a name="var_code_signing_args"></a>**code_signing_args**: [string list] [deprecated] Args for the post-processing script. ``` - For create_bundle targets, code_signing_args is the list of arguments to pass - to the code signing script. Typically you would use source expansion (see "gn - help source_expansion") to insert the source file names. + For create_bundle targets, post_processing_args is the list of arguments to + pass to the post-processing script. Typically you would use source expansion + (see "gn help source_expansion") to insert the source file names. - See also "gn help create_bundle". + Deprecated: this is an old name for the "post_processing_args" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". ``` -### <a name="var_code_signing_outputs"></a>**code_signing_outputs**: [file list] Output files for code signing step. +### <a name="var_code_signing_outputs"></a>**code_signing_outputs**: [file list] [deprecated] Outputs of the post-processing step. ``` - Outputs from the code signing step of a create_bundle target. Must refer to + Outputs from the post-processing step of a create_bundle target. Must refer to files in the build directory. - See also "gn help create_bundle". + Deprecated: this is an old name for the "post_processing_outputs" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". ``` -### <a name="var_code_signing_script"></a>**code_signing_script**: [file name] Script for code signing." +### <a name="var_code_signing_script"></a>**code_signing_script**: [file name] [deprecated] Script for the post-processing step." ``` An absolute or buildfile-relative file name of a Python script to run for a - create_bundle target to perform code signing step. + create_bundle target to perform the post-processing step. - See also "gn help create_bundle". + Deprecated: this is an old name for the "post_processing_script" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". ``` -### <a name="var_code_signing_sources"></a>**code_signing_sources**: [file list] Sources for code signing step. +### <a name="var_code_signing_sources"></a>**code_signing_sources**: [file list] [deprecated] Sources for the post-processing step. ``` - A list of files used as input for code signing script step of a create_bundle + A list of files used as input for the post-processing step of a create_bundle target. Non-absolute paths will be resolved relative to the current build file. - See also "gn help create_bundle". + Deprecated: this is an old name for the "post_processing_sources" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". ``` ### <a name="var_complete_static_lib"></a>**complete_static_lib**: [boolean] Links all deps into a static library. @@ -6346,7 +6375,7 @@ ``` Valid for create_bundle target, corresponds to the path for the partial Info.plist created by the asset catalog compiler that needs to be merged - with the application Info.plist (usually done by the code signing script). + with the application Info.plist (usually done by the post-processing script). The file will be generated regardless of whether the asset compiler has been invoked or not. See "gn help create_bundle". @@ -6371,6 +6400,40 @@ ... } ``` +### <a name="var_post_processing_args"></a>**post_processing_args**: [string list] Args for the post-processing script. + +``` + For create_bundle targets, post_processing_args is the list of arguments to + pass to the post-processing script. Typically you would use source expansion + (see "gn help source_expansion") to insert the source file names. + + See also "gn help create_bundle". +``` +### <a name="var_post_processing_outputs"></a>**post_processing_outputs**: [file list] Outputs of the post-processing step. + +``` + Outputs from the post-processing step of a create_bundle target. Must refer to + files in the build directory. + + See also "gn help create_bundle". +``` +### <a name="var_post_processing_script"></a>**post_processing_script**: [file name] Script for the post-processing step." + +``` + An absolute or buildfile-relative file name of a Python script to run for a + create_bundle target to perform the post-processing step. + + See also "gn help create_bundle". +``` +### <a name="var_post_processing_sources"></a>**post_processing_sources**: [file list] Sources for the post-processing step. + +``` + A list of files used as input for the post-processing step of a create_bundle + target. Non-absolute paths will be resolved relative to the current build + file. + + See also "gn help create_bundle". +``` ### <a name="var_precompiled_header"></a>**precompiled_header**: [string] Header file to precompile. ```
diff --git a/misc/emacs/gn-mode.el b/misc/emacs/gn-mode.el index dc92c9b..f98093e 100644 --- a/misc/emacs/gn-mode.el +++ b/misc/emacs/gn-mode.el
@@ -84,8 +84,8 @@ '("all_dependent_configs" "allow_circular_includes_from" "arflags" "args" "asmflags" "assert_no_deps" "bundle_deps_filter" "bundle_executable_dir" "bundle_resources_dir" "bundle_root_dir" "cflags" "cflags_c" "cflags_cc" - "cflags_objc" "cflags_objcc" "check_includes" "code_signing_args" - "code_signing_outputs" "code_signing_script" "code_signing_sources" + "cflags_objc" "cflags_objcc" "check_includes" "post_processing_args" + "post_processing_outputs" "post_processing_script" "post_processing_sources" "complete_static_lib" "configs" "data" "data_deps" "defines" "depfile" "deps" "framework_dir" "frameworks" "include_dirs" "inputs" "ldflags" "lib_dirs" "libs" "output_dir" "output_extension" "output_name"
diff --git a/src/gn/bundle_data.cc b/src/gn/bundle_data.cc index fdc22fd..86f7abf 100644 --- a/src/gn/bundle_data.cc +++ b/src/gn/bundle_data.cc
@@ -102,9 +102,9 @@ } sources->insert(sources->end(), assets_catalog_sources_.begin(), assets_catalog_sources_.end()); - if (!code_signing_script_.is_null()) { - sources->insert(sources->end(), code_signing_sources_.begin(), - code_signing_sources_.end()); + if (!post_processing_script_.is_null()) { + sources->insert(sources->end(), post_processing_sources_.begin(), + post_processing_sources_.end()); } } @@ -140,13 +140,13 @@ if (!partial_info_plist_.is_null()) outputs_as_source->push_back(partial_info_plist_); - if (!code_signing_script_.is_null()) { - std::vector<SourceFile> code_signing_output_files; - SubstitutionWriter::GetListAsSourceFiles(code_signing_outputs_, - &code_signing_output_files); + if (!post_processing_script_.is_null()) { + std::vector<SourceFile> post_processing_output_files; + SubstitutionWriter::GetListAsSourceFiles(post_processing_outputs_, + &post_processing_output_files); outputs_as_source->insert(outputs_as_source->end(), - code_signing_output_files.begin(), - code_signing_output_files.end()); + post_processing_output_files.begin(), + post_processing_output_files.end()); } if (!root_dir_.is_null())
diff --git a/src/gn/bundle_data.h b/src/gn/bundle_data.h index bf0d460..2e03694 100644 --- a/src/gn/bundle_data.h +++ b/src/gn/bundle_data.h
@@ -142,26 +142,30 @@ } const SourceFile& partial_info_plist() const { return partial_info_plist_; } - void set_code_signing_script(const SourceFile& script_file) { - code_signing_script_ = script_file; + void set_post_processing_script(const SourceFile& script_file) { + post_processing_script_ = script_file; } - const SourceFile& code_signing_script() const { return code_signing_script_; } - - std::vector<SourceFile>& code_signing_sources() { - return code_signing_sources_; - } - const std::vector<SourceFile>& code_signing_sources() const { - return code_signing_sources_; + const SourceFile& post_processing_script() const { + return post_processing_script_; } - SubstitutionList& code_signing_outputs() { return code_signing_outputs_; } - const SubstitutionList& code_signing_outputs() const { - return code_signing_outputs_; + std::vector<SourceFile>& post_processing_sources() { + return post_processing_sources_; + } + const std::vector<SourceFile>& post_processing_sources() const { + return post_processing_sources_; } - SubstitutionList& code_signing_args() { return code_signing_args_; } - const SubstitutionList& code_signing_args() const { - return code_signing_args_; + SubstitutionList& post_processing_outputs() { + return post_processing_outputs_; + } + const SubstitutionList& post_processing_outputs() const { + return post_processing_outputs_; + } + + SubstitutionList& post_processing_args() { return post_processing_args_; } + const SubstitutionList& post_processing_args() const { + return post_processing_args_; } std::vector<LabelPattern>& bundle_deps_filter() { @@ -233,11 +237,11 @@ SourceFile partial_info_plist_; // Holds the values (script name, sources, outputs, script arguments) for the - // code signing step if defined. - SourceFile code_signing_script_; - std::vector<SourceFile> code_signing_sources_; - SubstitutionList code_signing_outputs_; - SubstitutionList code_signing_args_; + // post-processing step if defined. + SourceFile post_processing_script_; + std::vector<SourceFile> post_processing_sources_; + SubstitutionList post_processing_outputs_; + SubstitutionList post_processing_args_; SubstitutionList xcasset_compiler_flags_; BundleData(const BundleData&) = delete;
diff --git a/src/gn/create_bundle_target_generator.cc b/src/gn/create_bundle_target_generator.cc index 5569e75..b12819e 100644 --- a/src/gn/create_bundle_target_generator.cc +++ b/src/gn/create_bundle_target_generator.cc
@@ -7,6 +7,7 @@ #include <map> #include "base/logging.h" +#include "base/strings/stringprintf.h" #include "gn/filesystem_utils.h" #include "gn/label_pattern.h" #include "gn/parse_tree.h" @@ -17,6 +18,34 @@ #include "gn/value_extractors.h" #include "gn/variables.h" +namespace { + +// Retrieves value from `scope` named `name` or `old_name`. If the value comes +// from the `old_name` a warning is emitted to inform the name is obsolete. +const Value* GetValueFromScope(Scope* scope, + std::string_view name, + std::string_view old_name) { + const Value* value = scope->GetValue(name, true); + if (value) + return value; + + value = scope->GetValue(old_name, true); + if (value) { + // If there is a value found with the old name, print a warning to the + // console and use that value. This is to avoid breaking the existing + // build rules in the wild. + Err err(*value, "Deprecated variable name", + base::StringPrintf( + "The name \"%s\" is deprecated, use \"%s\" instead.", + std::string(old_name).c_str(), std::string(name).c_str())); + err.PrintNonfatalToStdout(); + } + + return value; +} + +} // namespace + CreateBundleTargetGenerator::CreateBundleTargetGenerator( Target* target, Scope* scope, @@ -55,16 +84,16 @@ if (!FillXcodeTestApplicationName()) return; - if (!FillCodeSigningScript()) + if (!FillPostProcessingScript()) return; - if (!FillCodeSigningSources()) + if (!FillPostProcessingSources()) return; - if (!FillCodeSigningOutputs()) + if (!FillPostProcessingOutputs()) return; - if (!FillCodeSigningArgs()) + if (!FillPostProcessingArgs()) return; if (!FillBundleDepsFilter()) @@ -96,12 +125,13 @@ return false; if (str != bundle_root_dir.value() && !IsStringInOutputDir(bundle_root_dir, str)) { - *err_ = Err( - value->origin(), "Path is not in bundle root dir.", - "The given file should be in the bundle root directory or below.\n" - "Normally you would do \"$bundle_root_dir/foo\". I interpreted this\n" - "as \"" + - str + "\"."); + *err_ = + Err(value->origin(), "Path is not in bundle root dir.", + base::StringPrintf("The given file should be in the bundle root " + "directory or below.Normally you would do " + "\"$bundle_root_dir/foo\". I interpreted this " + "as \"%s\".", + str.c_str())); return false; } *bundle_dir = SourceDir(std::move(str)); @@ -188,8 +218,9 @@ return true; } -bool CreateBundleTargetGenerator::FillCodeSigningScript() { - const Value* value = scope_->GetValue(variables::kCodeSigningScript, true); +bool CreateBundleTargetGenerator::FillPostProcessingScript() { + const Value* value = GetValueFromScope( + scope_, variables::kPostProcessingScript, variables::kCodeSigningScript); if (!value) return true; @@ -201,20 +232,21 @@ if (err_->has_error()) return false; - target_->bundle_data().set_code_signing_script(script_file); + target_->bundle_data().set_post_processing_script(script_file); return true; } -bool CreateBundleTargetGenerator::FillCodeSigningSources() { - const Value* value = scope_->GetValue(variables::kCodeSigningSources, true); +bool CreateBundleTargetGenerator::FillPostProcessingSources() { + const Value* value = + GetValueFromScope(scope_, variables::kPostProcessingSources, + variables::kCodeSigningSources); if (!value) return true; - if (target_->bundle_data().code_signing_script().is_null()) { - *err_ = Err( - function_call_, - "No code signing script." - "You must define code_signing_script if you use code_signing_sources."); + if (target_->bundle_data().post_processing_script().is_null()) { + *err_ = Err(function_call_, "No post-processing script.", + "You must define post_processing_script if you use " + "post_processing_sources."); return false; } @@ -224,36 +256,35 @@ err_)) return false; - target_->bundle_data().code_signing_sources() = std::move(script_sources); + target_->bundle_data().post_processing_sources() = std::move(script_sources); return true; } -bool CreateBundleTargetGenerator::FillCodeSigningOutputs() { - const Value* value = scope_->GetValue(variables::kCodeSigningOutputs, true); +bool CreateBundleTargetGenerator::FillPostProcessingOutputs() { + const Value* value = + GetValueFromScope(scope_, variables::kPostProcessingOutputs, + variables::kCodeSigningOutputs); if (!value) return true; - if (target_->bundle_data().code_signing_script().is_null()) { - *err_ = Err( - function_call_, - "No code signing script." - "You must define code_signing_script if you use code_signing_outputs."); + if (target_->bundle_data().post_processing_script().is_null()) { + *err_ = Err(function_call_, "No post-processing script.", + "You must define post_processing_script if you use " + "post_processing_outputs."); return false; } if (!value->VerifyTypeIs(Value::LIST, err_)) return false; - SubstitutionList& outputs = target_->bundle_data().code_signing_outputs(); + SubstitutionList& outputs = target_->bundle_data().post_processing_outputs(); if (!outputs.Parse(*value, err_)) return false; if (outputs.list().empty()) { - *err_ = - Err(function_call_, - "Code signing script has no output." - "If you have no outputs, the build system can not tell when your\n" - "code signing script needs to be run."); + *err_ = Err(function_call_, "Post-processing script has no output.", + "If you have no outputs, the build system can not tell when " + "your post-processing script needs to be run."); return false; } @@ -268,23 +299,23 @@ return true; } -bool CreateBundleTargetGenerator::FillCodeSigningArgs() { - const Value* value = scope_->GetValue(variables::kCodeSigningArgs, true); +bool CreateBundleTargetGenerator::FillPostProcessingArgs() { + const Value* value = GetValueFromScope(scope_, variables::kPostProcessingArgs, + variables::kCodeSigningArgs); if (!value) return true; - if (target_->bundle_data().code_signing_script().is_null()) { - *err_ = Err( - function_call_, - "No code signing script." - "You must define code_signing_script if you use code_signing_args."); + if (target_->bundle_data().post_processing_script().is_null()) { + *err_ = Err(function_call_, "No post-processing script.", + "You must define post_processing_script if you use " + "post_processing_args."); return false; } if (!value->VerifyTypeIs(Value::LIST, err_)) return false; - return target_->bundle_data().code_signing_args().Parse(*value, err_); + return target_->bundle_data().post_processing_args().Parse(*value, err_); } bool CreateBundleTargetGenerator::FillBundleDepsFilter() {
diff --git a/src/gn/create_bundle_target_generator.h b/src/gn/create_bundle_target_generator.h index 0e7a535..c713368 100644 --- a/src/gn/create_bundle_target_generator.h +++ b/src/gn/create_bundle_target_generator.h
@@ -34,10 +34,10 @@ bool FillPartialInfoPlist(); bool FillXcodeTestApplicationName(); - bool FillCodeSigningScript(); - bool FillCodeSigningSources(); - bool FillCodeSigningOutputs(); - bool FillCodeSigningArgs(); + bool FillPostProcessingScript(); + bool FillPostProcessingSources(); + bool FillPostProcessingOutputs(); + bool FillPostProcessingArgs(); bool FillBundleDepsFilter(); bool FillXcassetCompilerFlags(); bool FillTransparent();
diff --git a/src/gn/functions_target.cc b/src/gn/functions_target.cc index 5a13779..7e262ee 100644 --- a/src/gn/functions_target.cc +++ b/src/gn/functions_target.cc
@@ -385,21 +385,27 @@ placed in the bundle. A create_bundle can declare its own explicit data and data_deps, however. -Code signing +Post-processing - Some bundle needs to be code signed as part of the build (on iOS all - application needs to be code signed to run on a device). The code signature - can be configured via the code_signing_script variable. + Some bundle needs to be post-processed as part of the build (e.g. on iOS all + application needs to be code signed to run on a device). The post processing + step can be configured via the post_processing_script variable. - If set, code_signing_script is the path of a script that invoked after all - files have been moved into the bundle. The script must not change any file in - the bundle, but may add new files. + If set, `post_processing_script` is the path of a script that invoked after + all files have been moved into the bundle. The script must not change any file + in the bundle, but may add new files. - If code_signing_script is defined, then code_signing_outputs must also be - defined and non-empty to inform when the script needs to be re-run. The - code_signing_args will be passed as is to the script (so path have to be - rebased) and additional inputs may be listed with the variable - code_signing_sources. + If `post_processing_script` is defined, then `post_processing_outputs` must + be defined and non-empty to inform when the script needs to be re-run. The + `post_processing_args` will be passed as is to the script (so path have to be + rebased) and additional inputs may be listed via `post_processing_sources`. + +Migration + + The post-processing step used to be limited to code-signing. The properties + used to be named `code_signing_$name` instead of `post_processing_$name`. The + old names are still accepted as alias to facilitate migration but a warning + will be emitted and the alias eventually be removed. Variables @@ -407,9 +413,10 @@ R"( Bundle vars: bundle_root_dir, bundle_contents_dir, bundle_resources_dir, bundle_executable_dir, bundle_deps_filter, product_type, - code_signing_args, code_signing_script, code_signing_sources, - code_signing_outputs, xcode_extra_attributes, - xcode_test_application_name, partial_info_plist + post_processing_args, post_processing_script, + post_processing_sources, post_processing_outputs, + xcode_extra_attributes, xcode_test_application_name, + partial_info_plist Example @@ -481,19 +488,19 @@ deps = [ ":${app_name}_bundle_info_plist" ] if (is_ios && code_signing) { deps += [ ":${app_name}_generate_executable" ] - code_signing_script = "//build/config/ios/codesign.py" - code_signing_sources = [ + post_processing_script = "//build/config/ios/codesign.py" + post_processing_sources = [ invoker.entitlements_path, "$target_gen_dir/$app_name", ] - code_signing_outputs = [ + post_processing_outputs = [ "$bundle_root_dir/$app_name", "$bundle_root_dir/_CodeSignature/CodeResources", "$bundle_root_dir/embedded.mobileprovision", "$target_gen_dir/$app_name.xcent", ] - code_signing_args = [ - "-i=" + ios_code_signing_identity, + post_processing_args = [ + "-i=" + ios_post_processing_identity, "-b=" + rebase_path( "$target_gen_dir/$app_name", root_build_dir), "-e=" + rebase_path(
diff --git a/src/gn/ninja_create_bundle_target_writer.cc b/src/gn/ninja_create_bundle_target_writer.cc index efa950e..a453fce 100644 --- a/src/gn/ninja_create_bundle_target_writer.cc +++ b/src/gn/ninja_create_bundle_target_writer.cc
@@ -76,18 +76,19 @@ if (!EnsureAllToolsAvailable(target_)) return; - // Stamp users are CopyBundleData, CompileAssetsCatalog, CodeSigning and + // Stamp users are CopyBundleData, CompileAssetsCatalog, PostProcessing and // StampForTarget. size_t num_stamp_uses = 4; std::vector<OutputFile> order_only_deps = WriteInputDepsStampAndGetDep( std::vector<const Target*>(), num_stamp_uses); - std::string code_signing_rule_name = WriteCodeSigningRuleDefinition(); + std::string post_processing_rule_name = WritePostProcessingRuleDefinition(); std::vector<OutputFile> output_files; WriteCopyBundleDataSteps(order_only_deps, &output_files); WriteCompileAssetsCatalogStep(order_only_deps, &output_files); - WriteCodeSigningStep(code_signing_rule_name, order_only_deps, &output_files); + WritePostProcessingStep(post_processing_rule_name, order_only_deps, + &output_files); for (const Target* data_dep : resolved().GetDataDeps(target_)) order_only_deps.push_back(data_dep->dependency_output_file()); @@ -106,22 +107,22 @@ out_ << std::endl; } -std::string NinjaCreateBundleTargetWriter::WriteCodeSigningRuleDefinition() { - if (target_->bundle_data().code_signing_script().is_null()) +std::string NinjaCreateBundleTargetWriter::WritePostProcessingRuleDefinition() { + if (target_->bundle_data().post_processing_script().is_null()) return std::string(); std::string target_label = target_->label().GetUserVisibleName(true); std::string custom_rule_name(target_label); base::ReplaceChars(custom_rule_name, ":/()", "_", &custom_rule_name); - custom_rule_name.append("_code_signing_rule"); + custom_rule_name.append("_post_processing_rule"); out_ << "rule " << custom_rule_name << std::endl; out_ << " command = "; path_output_.WriteFile(out_, settings_->build_settings()->python_path()); out_ << " "; - path_output_.WriteFile(out_, target_->bundle_data().code_signing_script()); + path_output_.WriteFile(out_, target_->bundle_data().post_processing_script()); - const SubstitutionList& args = target_->bundle_data().code_signing_args(); + const SubstitutionList& args = target_->bundle_data().post_processing_args(); EscapeOptions args_escape_options; args_escape_options.mode = ESCAPE_NINJA_COMMAND; @@ -130,7 +131,7 @@ SubstitutionWriter::WriteWithNinjaVariables(arg, args_escape_options, out_); } out_ << std::endl; - out_ << " description = CODE SIGNING " << target_label << std::endl; + out_ << " description = POST PROCESSING " << target_label << std::endl; out_ << " restat = 1" << std::endl; out_ << std::endl; @@ -302,65 +303,67 @@ return xcassets_input_stamp_file; } -void NinjaCreateBundleTargetWriter::WriteCodeSigningStep( - const std::string& code_signing_rule_name, +void NinjaCreateBundleTargetWriter::WritePostProcessingStep( + const std::string& post_processing_rule_name, const std::vector<OutputFile>& order_only_deps, std::vector<OutputFile>* output_files) { - if (code_signing_rule_name.empty()) + if (post_processing_rule_name.empty()) return; - OutputFile code_signing_input_stamp_file = - WriteCodeSigningInputDepsStamp(order_only_deps, output_files); - DCHECK(!code_signing_input_stamp_file.value().empty()); + OutputFile post_processing_input_stamp_file = + WritePostProcessingInputDepsStamp(order_only_deps, output_files); + DCHECK(!post_processing_input_stamp_file.value().empty()); out_ << "build"; - std::vector<OutputFile> code_signing_output_files; + std::vector<OutputFile> post_processing_output_files; SubstitutionWriter::GetListAsOutputFiles( - settings_, target_->bundle_data().code_signing_outputs(), - &code_signing_output_files); - WriteOutputs(code_signing_output_files); + settings_, target_->bundle_data().post_processing_outputs(), + &post_processing_output_files); + WriteOutputs(post_processing_output_files); - // Since the code signature step depends on all the files from the bundle, + // Since the post-processing step depends on all the files from the bundle, // the create_bundle stamp can just depends on the output of the signature // script (dependencies are transitive). - *output_files = std::move(code_signing_output_files); + *output_files = std::move(post_processing_output_files); - out_ << ": " << code_signing_rule_name; + out_ << ": " << post_processing_rule_name; out_ << " | "; - path_output_.WriteFile(out_, code_signing_input_stamp_file); + path_output_.WriteFile(out_, post_processing_input_stamp_file); out_ << std::endl; } -OutputFile NinjaCreateBundleTargetWriter::WriteCodeSigningInputDepsStamp( +OutputFile NinjaCreateBundleTargetWriter::WritePostProcessingInputDepsStamp( const std::vector<OutputFile>& order_only_deps, std::vector<OutputFile>* output_files) { - std::vector<SourceFile> code_signing_input_files; - code_signing_input_files.push_back( - target_->bundle_data().code_signing_script()); - code_signing_input_files.insert( - code_signing_input_files.end(), - target_->bundle_data().code_signing_sources().begin(), - target_->bundle_data().code_signing_sources().end()); + std::vector<SourceFile> post_processing_input_files; + post_processing_input_files.push_back( + target_->bundle_data().post_processing_script()); + post_processing_input_files.insert( + post_processing_input_files.end(), + target_->bundle_data().post_processing_sources().begin(), + target_->bundle_data().post_processing_sources().end()); for (const OutputFile& output_file : *output_files) { - code_signing_input_files.push_back( + post_processing_input_files.push_back( output_file.AsSourceFile(settings_->build_settings())); } - DCHECK(!code_signing_input_files.empty()); - if (code_signing_input_files.size() == 1 && order_only_deps.empty()) - return OutputFile(settings_->build_settings(), code_signing_input_files[0]); + DCHECK(!post_processing_input_files.empty()); + if (post_processing_input_files.size() == 1 && order_only_deps.empty()) + return OutputFile(settings_->build_settings(), + post_processing_input_files[0]); - OutputFile code_signing_input_stamp_file = + OutputFile post_processing_input_stamp_file = GetBuildDirForTargetAsOutputFile(target_, BuildDirType::OBJ); - code_signing_input_stamp_file.value().append(target_->label().name()); - code_signing_input_stamp_file.value().append(".codesigning.inputdeps.stamp"); + post_processing_input_stamp_file.value().append(target_->label().name()); + post_processing_input_stamp_file.value().append( + ".postprocessing.inputdeps.stamp"); out_ << "build "; - WriteOutput(code_signing_input_stamp_file); + WriteOutput(post_processing_input_stamp_file); out_ << ": " << GetNinjaRulePrefixForToolchain(settings_) << GeneralTool::kGeneralToolStamp; - for (const SourceFile& source : code_signing_input_files) { + for (const SourceFile& source : post_processing_input_files) { out_ << " "; path_output_.WriteFile(out_, source); } @@ -369,5 +372,5 @@ path_output_.WriteFiles(out_, order_only_deps); } out_ << std::endl; - return code_signing_input_stamp_file; + return post_processing_input_stamp_file; }
diff --git a/src/gn/ninja_create_bundle_target_writer.h b/src/gn/ninja_create_bundle_target_writer.h index 34951fb..609bc6b 100644 --- a/src/gn/ninja_create_bundle_target_writer.h +++ b/src/gn/ninja_create_bundle_target_writer.h
@@ -18,11 +18,11 @@ void Run() override; private: - // Writes the Ninja rule for invoking the code signing script. + // Writes the Ninja rule for invoking the post-processing script. // - // Returns the name of the custom rule generated for the code signing step if - // defined, otherwise returns an empty string. - std::string WriteCodeSigningRuleDefinition(); + // Returns the name of the custom rule generated for the post-processing step + // if defined, otherwise returns an empty string. + std::string WritePostProcessingRuleDefinition(); // Writes the steps to copy files into the bundle. // @@ -50,17 +50,17 @@ OutputFile WriteCompileAssetsCatalogInputDepsStamp( const std::vector<const Target*>& dependencies); - // Writes the code signing step (if a script is defined). + // Writes the post-processing step (if a script is defined). // // The list of newly created files will be added to |output_files|. As the - // code signing may depends on the full bundle structure, this step will + // post-processing may depends on the full bundle structure, this step will // depends on all files generated via other rules. - void WriteCodeSigningStep(const std::string& code_signing_rule_name, - const std::vector<OutputFile>& order_only_deps, - std::vector<OutputFile>* output_files); + void WritePostProcessingStep(const std::string& post_processing_rule_name, + const std::vector<OutputFile>& order_only_deps, + std::vector<OutputFile>* output_files); - // Writes the stamp file for the code signing input dependencies. - OutputFile WriteCodeSigningInputDepsStamp( + // Writes the stamp file for the post-processing input dependencies. + OutputFile WritePostProcessingInputDepsStamp( const std::vector<OutputFile>& order_only_deps, std::vector<OutputFile>* output_files);
diff --git a/src/gn/ninja_create_bundle_target_writer_unittest.cc b/src/gn/ninja_create_bundle_target_writer_unittest.cc index 997c058..4397643 100644 --- a/src/gn/ninja_create_bundle_target_writer_unittest.cc +++ b/src/gn/ninja_create_bundle_target_writer_unittest.cc
@@ -414,8 +414,8 @@ EXPECT_EQ(expected, out_str); } -// Tests code signing steps. -TEST(NinjaCreateBundleTargetWriter, CodeSigning) { +// Tests post-processing step. +TEST(NinjaCreateBundleTargetWriter, PostProcessing) { Err err; TestWithScope setup; @@ -445,15 +445,15 @@ setup.toolchain()->label().name())); SetupBundleDataDir(&create_bundle.bundle_data(), "//out/Debug"); create_bundle.set_output_type(Target::CREATE_BUNDLE); - create_bundle.bundle_data().set_code_signing_script( + create_bundle.bundle_data().set_post_processing_script( SourceFile("//build/codesign.py")); - create_bundle.bundle_data().code_signing_sources().push_back( + create_bundle.bundle_data().post_processing_sources().push_back( SourceFile("//out/Debug/quz")); - create_bundle.bundle_data().code_signing_outputs() = + create_bundle.bundle_data().post_processing_outputs() = SubstitutionList::MakeForTest( "//out/Debug/bar.bundle/Contents/quz", "//out/Debug/bar.bundle/_CodeSignature/CodeResources"); - create_bundle.bundle_data().code_signing_args() = + create_bundle.bundle_data().post_processing_args() = SubstitutionList::MakeForTest("-b=quz", "bar.bundle"); create_bundle.public_deps().push_back(LabelTargetPair(&executable)); create_bundle.private_deps().push_back(LabelTargetPair(&bundle_data)); @@ -468,24 +468,24 @@ const char expected[] = "build obj/baz/bar.inputdeps.stamp: stamp ./quz obj/foo/bar.stamp " "obj/foo/data.stamp\n" - "rule __baz_bar___toolchain_default__code_signing_rule\n" + "rule __baz_bar___toolchain_default__post_processing_rule\n" " command = ../../build/codesign.py -b=quz bar.bundle\n" - " description = CODE SIGNING //baz:bar(//toolchain:default)\n" + " description = POST PROCESSING //baz:bar(//toolchain:default)\n" " restat = 1\n" "\n" "build bar.bundle/Contents/Resources/input1.txt: copy_bundle_data " "../../foo/input1.txt || obj/baz/bar.inputdeps.stamp\n" "build bar.bundle/Contents/Resources/input2.txt: copy_bundle_data " "../../foo/input2.txt || obj/baz/bar.inputdeps.stamp\n" - "build obj/baz/bar.codesigning.inputdeps.stamp: stamp " + "build obj/baz/bar.postprocessing.inputdeps.stamp: stamp " "../../build/codesign.py " "quz " "bar.bundle/Contents/Resources/input1.txt " "bar.bundle/Contents/Resources/input2.txt || " "obj/baz/bar.inputdeps.stamp\n" "build bar.bundle/Contents/quz bar.bundle/_CodeSignature/CodeResources: " - "__baz_bar___toolchain_default__code_signing_rule " - "| obj/baz/bar.codesigning.inputdeps.stamp\n" + "__baz_bar___toolchain_default__post_processing_rule " + "| obj/baz/bar.postprocessing.inputdeps.stamp\n" "build obj/baz/bar.stamp: stamp " "bar.bundle/Contents/quz " "bar.bundle/_CodeSignature/CodeResources || obj/baz/bar.inputdeps.stamp\n"
diff --git a/src/gn/variables.cc b/src/gn/variables.cc index 4949929..710a3de 100644 --- a/src/gn/variables.cc +++ b/src/gn/variables.cc
@@ -857,52 +857,73 @@ const char kCodeSigningArgs[] = "code_signing_args"; const char kCodeSigningArgs_HelpShort[] = - "code_signing_args: [string list] Arguments passed to code signing script."; + "code_signing_args: [string list] [deprecated] Args for the " + "post-processing script."; const char kCodeSigningArgs_Help[] = - R"(code_signing_args: [string list] Arguments passed to code signing script. + R"(code_signing_args: [string list] [deprecated] Args for the post-processing script. - For create_bundle targets, code_signing_args is the list of arguments to pass - to the code signing script. Typically you would use source expansion (see "gn - help source_expansion") to insert the source file names. + For create_bundle targets, post_processing_args is the list of arguments to + pass to the post-processing script. Typically you would use source expansion + (see "gn help source_expansion") to insert the source file names. - See also "gn help create_bundle". -)"; + Deprecated: this is an old name for the "post_processing_args" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. -const char kCodeSigningScript[] = "code_signing_script"; -const char kCodeSigningScript_HelpShort[] = - "code_signing_script: [file name] Script for code signing."; -const char kCodeSigningScript_Help[] = - R"(code_signing_script: [file name] Script for code signing." - - An absolute or buildfile-relative file name of a Python script to run for a - create_bundle target to perform code signing step. - - See also "gn help create_bundle". -)"; - -const char kCodeSigningSources[] = "code_signing_sources"; -const char kCodeSigningSources_HelpShort[] = - "code_signing_sources: [file list] Sources for code signing step."; -const char kCodeSigningSources_Help[] = - R"(code_signing_sources: [file list] Sources for code signing step. - - A list of files used as input for code signing script step of a create_bundle - target. Non-absolute paths will be resolved relative to the current build - file. - - See also "gn help create_bundle". + See also "gn help create_bundle" and "gn help post_processing_args". )"; const char kCodeSigningOutputs[] = "code_signing_outputs"; const char kCodeSigningOutputs_HelpShort[] = - "code_signing_outputs: [file list] Output files for code signing step."; + "code_signing_outputs: [file list] [deprecated] Outputs of the " + "post-processing step."; const char kCodeSigningOutputs_Help[] = - R"(code_signing_outputs: [file list] Output files for code signing step. + R"(code_signing_outputs: [file list] [deprecated] Outputs of the post-processing step. - Outputs from the code signing step of a create_bundle target. Must refer to + Outputs from the post-processing step of a create_bundle target. Must refer to files in the build directory. - See also "gn help create_bundle". + Deprecated: this is an old name for the "post_processing_outputs" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". +)"; + +const char kCodeSigningScript[] = "code_signing_script"; +const char kCodeSigningScript_HelpShort[] = + "code_signing_script: [file name] [deprecated] Script for the " + "post-processing step."; +const char kCodeSigningScript_Help[] = + R"(code_signing_script: [file name] [deprecated] Script for the post-processing step." + + An absolute or buildfile-relative file name of a Python script to run for a + create_bundle target to perform the post-processing step. + + Deprecated: this is an old name for the "post_processing_script" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". +)"; + +const char kCodeSigningSources[] = "code_signing_sources"; +const char kCodeSigningSources_HelpShort[] = + "code_signing_sources: [file list] [deprecated] Sources for the " + "post-processing " + "step."; +const char kCodeSigningSources_Help[] = + R"(code_signing_sources: [file list] [deprecated] Sources for the post-processing step. + + A list of files used as input for the post-processing step of a create_bundle + target. Non-absolute paths will be resolved relative to the current build + file. + + Deprecated: this is an old name for the "post_processing_sources" property of + the "create_bundle" target. It is still supported to avoid breaking existing + build rules, but a warning will be emitted when it is used. + + See also "gn help create_bundle" and "gn help post_processing_args". )"; const char kCompleteStaticLib[] = "complete_static_lib"; @@ -1639,7 +1660,7 @@ Valid for create_bundle target, corresponds to the path for the partial Info.plist created by the asset catalog compiler that needs to be merged - with the application Info.plist (usually done by the code signing script). + with the application Info.plist (usually done by the post-processing script). The file will be generated regardless of whether the asset compiler has been invoked or not. See "gn help create_bundle". @@ -1694,6 +1715,57 @@ } )"; +const char kPostProcessingArgs[] = "post_processing_args"; +const char kPostProcessingArgs_HelpShort[] = + "post_processing_args: [string list] Args for the post-processing script."; +const char kPostProcessingArgs_Help[] = + R"(post_processing_args: [string list] Args for the post-processing script. + + For create_bundle targets, post_processing_args is the list of arguments to + pass to the post-processing script. Typically you would use source expansion + (see "gn help source_expansion") to insert the source file names. + + See also "gn help create_bundle". +)"; + +const char kPostProcessingOutputs[] = "post_processing_outputs"; +const char kPostProcessingOutputs_HelpShort[] = + "post_processing_outputs: [file list] Outputs of the post-processing step."; +const char kPostProcessingOutputs_Help[] = + R"(post_processing_outputs: [file list] Outputs of the post-processing step. + + Outputs from the post-processing step of a create_bundle target. Must refer to + files in the build directory. + + See also "gn help create_bundle". +)"; + +const char kPostProcessingScript[] = "post_processing_script"; +const char kPostProcessingScript_HelpShort[] = + "post_processing_script: [file name] Script for the post-processing step."; +const char kPostProcessingScript_Help[] = + R"(post_processing_script: [file name] Script for the post-processing step." + + An absolute or buildfile-relative file name of a Python script to run for a + create_bundle target to perform the post-processing step. + + See also "gn help create_bundle". +)"; + +const char kPostProcessingSources[] = "post_processing_sources"; +const char kPostProcessingSources_HelpShort[] = + "post_processing_sources: [file list] Sources for the post-processing " + "step."; +const char kPostProcessingSources_Help[] = + R"(post_processing_sources: [file list] Sources for the post-processing step. + + A list of files used as input for the post-processing step of a create_bundle + target. Non-absolute paths will be resolved relative to the current build + file. + + See also "gn help create_bundle". +)"; + const char kPrecompiledHeader[] = "precompiled_header"; const char kPrecompiledHeader_HelpShort[] = "precompiled_header: [string] Header file to precompile."; @@ -2355,9 +2427,9 @@ INSERT_VARIABLE(CflagsObjCC) INSERT_VARIABLE(CheckIncludes) INSERT_VARIABLE(CodeSigningArgs) + INSERT_VARIABLE(CodeSigningOutputs) INSERT_VARIABLE(CodeSigningScript) INSERT_VARIABLE(CodeSigningSources) - INSERT_VARIABLE(CodeSigningOutputs) INSERT_VARIABLE(CompleteStaticLib) INSERT_VARIABLE(Configs) INSERT_VARIABLE(Data) @@ -2384,6 +2456,10 @@ INSERT_VARIABLE(Outputs) INSERT_VARIABLE(PartialInfoPlist) INSERT_VARIABLE(Pool) + INSERT_VARIABLE(PostProcessingArgs) + INSERT_VARIABLE(PostProcessingOutputs) + INSERT_VARIABLE(PostProcessingScript) + INSERT_VARIABLE(PostProcessingSources) INSERT_VARIABLE(PrecompiledHeader) INSERT_VARIABLE(PrecompiledHeaderType) INSERT_VARIABLE(PrecompiledSource)
diff --git a/src/gn/variables.h b/src/gn/variables.h index 56d7000..b8a0d54 100644 --- a/src/gn/variables.h +++ b/src/gn/variables.h
@@ -162,6 +162,10 @@ extern const char kCodeSigningArgs_HelpShort[]; extern const char kCodeSigningArgs_Help[]; +extern const char kCodeSigningOutputs[]; +extern const char kCodeSigningOutputs_HelpShort[]; +extern const char kCodeSigningOutputs_Help[]; + extern const char kCodeSigningScript[]; extern const char kCodeSigningScript_HelpShort[]; extern const char kCodeSigningScript_Help[]; @@ -170,10 +174,6 @@ extern const char kCodeSigningSources_HelpShort[]; extern const char kCodeSigningSources_Help[]; -extern const char kCodeSigningOutputs[]; -extern const char kCodeSigningOutputs_HelpShort[]; -extern const char kCodeSigningOutputs_Help[]; - extern const char kCompleteStaticLib[]; extern const char kCompleteStaticLib_HelpShort[]; extern const char kCompleteStaticLib_Help[]; @@ -274,6 +274,22 @@ extern const char kPool_HelpShort[]; extern const char kPool_Help[]; +extern const char kPostProcessingArgs[]; +extern const char kPostProcessingArgs_HelpShort[]; +extern const char kPostProcessingArgs_Help[]; + +extern const char kPostProcessingOutputs[]; +extern const char kPostProcessingOutputs_HelpShort[]; +extern const char kPostProcessingOutputs_Help[]; + +extern const char kPostProcessingScript[]; +extern const char kPostProcessingScript_HelpShort[]; +extern const char kPostProcessingScript_Help[]; + +extern const char kPostProcessingSources[]; +extern const char kPostProcessingSources_HelpShort[]; +extern const char kPostProcessingSources_Help[]; + extern const char kPrecompiledHeader[]; extern const char kPrecompiledHeader_HelpShort[]; extern const char kPrecompiledHeader_Help[];