Fix issues with bundle_data/create_bundle targets
Remove the bundle_plugins_dir variable as it is not really required
(the value is always the same for both iOS and macOS) and the value
can be inlined instead ({{bundle_contents_dir}}/Plugins).
Fix NinjaCreateBundleTargetWriter to only complain about missing
compile_xcassets tool if the target require it (i.e. if it defines
a list of resources to compile in an asset catalog).
Fix incorrect use of deps instead of public_deps in bundle_data
documentation.
Bug: https://bugs.chromium.org/p/gn/issues/detail?id=64
Change-Id: I28a0a3d673dc1b39804c466499e6e91f034a2113
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/4480
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
diff --git a/docs/reference.md b/docs/reference.md
index 9571fb3..fe23b19 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -86,7 +86,6 @@
* [bundle_contents_dir: Expansion of {{bundle_contents_dir}} in create_bundle.](#var_bundle_contents_dir)
* [bundle_deps_filter: [label list] A list of labels that are filtered out.](#var_bundle_deps_filter)
* [bundle_executable_dir: Expansion of {{bundle_executable_dir}} in create_bundle](#var_bundle_executable_dir)
- * [bundle_plugins_dir: Expansion of {{bundle_plugins_dir}} in create_bundle.](#var_bundle_plugins_dir)
* [bundle_resources_dir: Expansion of {{bundle_resources_dir}} in create_bundle.](#var_bundle_resources_dir)
* [bundle_root_dir: Expansion of {{bundle_root_dir}} in create_bundle.](#var_bundle_root_dir)
* [cflags: [string list] Flags passed to all C compiler variants.](#var_cflags)
@@ -1423,11 +1422,10 @@
```
bundle_root_dir, bundle_contents_dir, bundle_resources_dir,
- bundle_executable_dir, bundle_plugins_dir, bundle_deps_filter, deps,
- data_deps, public_deps, visibility, product_type, code_signing_args,
- code_signing_script, code_signing_sources, code_signing_outputs,
- xcode_extra_attributes, xcode_test_application_name, partial_info_plist,
- metadata
+ bundle_executable_dir, bundle_deps_filter, deps, data_deps, public_deps,
+ visibility, product_type, code_signing_args, code_signing_script,
+ code_signing_sources, code_signing_outputs, xcode_extra_attributes,
+ xcode_test_application_name, partial_info_plist, metadata
```
#### **Example**
@@ -1454,7 +1452,7 @@
}
bundle_data("${app_name}_bundle_info_plist") {
- deps = [ ":${app_name}_generate_info_plist" ]
+ public_deps = [ ":${app_name}_generate_info_plist" ]
sources = [ "$gen_path/Info.plist" ]
outputs = [ "{{bundle_contents_dir}}/Info.plist" ]
}
@@ -1471,34 +1469,32 @@
code_signing =
defined(invoker.code_signing) && invoker.code_signing
- if (is_ios && !code_signing) {
+ if (!is_ios || !code_signing) {
bundle_data("${app_name}_bundle_executable") {
- deps = [ ":${app_name}_generate_executable" ]
+ public_deps = [ ":${app_name}_generate_executable" ]
sources = [ "$gen_path/$app_name" ]
outputs = [ "{{bundle_executable_dir}}/$app_name" ]
}
}
- create_bundle("${app_name}.app") {
+ create_bundle("$app_name.app") {
product_type = "com.apple.product-type.application"
if (is_ios) {
- bundle_root_dir = "${root_build_dir}/$target_name"
+ bundle_root_dir = "$root_build_dir/$target_name"
bundle_contents_dir = bundle_root_dir
bundle_resources_dir = bundle_contents_dir
bundle_executable_dir = bundle_contents_dir
- bundle_plugins_dir = "${bundle_contents_dir}/Plugins"
extra_attributes = {
ONLY_ACTIVE_ARCH = "YES"
DEBUG_INFORMATION_FORMAT = "dwarf"
}
} else {
- bundle_root_dir = "${root_build_dir}/target_name"
- bundle_contents_dir = "${bundle_root_dir}/Contents"
- bundle_resources_dir = "${bundle_contents_dir}/Resources"
- bundle_executable_dir = "${bundle_contents_dir}/MacOS"
- bundle_plugins_dir = "${bundle_contents_dir}/Plugins"
+ bundle_root_dir = "$root_build_dir/$target_name"
+ bundle_contents_dir = "$bundle_root_dir/Contents"
+ bundle_resources_dir = "$bundle_contents_dir/Resources"
+ bundle_executable_dir = "$bundle_contents_dir/MacOS"
}
deps = [ ":${app_name}_bundle_info_plist" ]
if (is_ios && code_signing) {
@@ -4302,17 +4298,6 @@
See "gn help bundle_root_dir" for examples.
```
-### <a name="var_bundle_plugins_dir"></a>**bundle_plugins_dir**: Expansion of {{bundle_plugins_dir}} in create_bundle.
-
-```
- A string corresponding to a path in $root_build_dir.
-
- This string is used by the "create_bundle" target to expand the
- {{bundle_plugins_dir}} of the "bundle_data" target it depends on. This must
- correspond to a path under "bundle_root_dir".
-
- See "gn help bundle_root_dir" for examples.
-```
### <a name="var_bundle_resources_dir"></a>**bundle_resources_dir**
```
@@ -4351,7 +4336,6 @@
bundle_contents_dir = "${bundle_root_dir}/Contents"
bundle_resources_dir = "${bundle_contents_dir}/Resources"
bundle_executable_dir = "${bundle_contents_dir}/MacOS"
- bundle_plugins_dir = "${bundle_contents_dir}/PlugIns"
}
```
### <a name="var_cflags"></a>**cflags***: Flags passed to the C compiler.
diff --git a/tools/gn/bundle_data.h b/tools/gn/bundle_data.h
index 60254a9..2379dbc 100644
--- a/tools/gn/bundle_data.h
+++ b/tools/gn/bundle_data.h
@@ -100,9 +100,6 @@
SourceDir& executable_dir() { return executable_dir_; }
const SourceDir& executable_dir() const { return executable_dir_; }
- SourceDir& plugins_dir() { return plugins_dir_; }
- const SourceDir& plugins_dir() const { return plugins_dir_; }
-
std::map<std::string, std::string>& xcode_extra_attributes() {
return xcode_extra_attributes_;
}
@@ -170,7 +167,6 @@
SourceDir contents_dir_;
SourceDir resources_dir_;
SourceDir executable_dir_;
- SourceDir plugins_dir_;
// The specified attributes will append to the build settings of the generated
// Xcode target.
diff --git a/tools/gn/bundle_file_rule.cc b/tools/gn/bundle_file_rule.cc
index 78012a0..5dffb07 100644
--- a/tools/gn/bundle_file_rule.cc
+++ b/tools/gn/bundle_file_rule.cc
@@ -87,14 +87,6 @@
}
output_path.append(bundle_data.executable_dir().value());
break;
- case SUBSTITUTION_BUNDLE_PLUGINS_DIR:
- if (bundle_data.contents_dir().is_null()) {
- *err = ErrMissingPropertyForExpansion(settings, target, this,
- variables::kBundlePlugInsDir);
- return false;
- }
- output_path.append(bundle_data.plugins_dir().value());
- break;
default:
output_path.append(SubstitutionWriter::GetSourceSubstitution(
target_, target_->settings(), source_file, subrange.type,
diff --git a/tools/gn/create_bundle_target_generator.cc b/tools/gn/create_bundle_target_generator.cc
index 768697d..3556b5d 100644
--- a/tools/gn/create_bundle_target_generator.cc
+++ b/tools/gn/create_bundle_target_generator.cc
@@ -42,9 +42,6 @@
if (!FillBundleDir(bundle_data.root_dir(), variables::kBundleExecutableDir,
&bundle_data.executable_dir()))
return;
- if (!FillBundleDir(bundle_data.root_dir(), variables::kBundlePlugInsDir,
- &bundle_data.plugins_dir()))
- return;
if (!FillXcodeExtraAttributes())
return;
diff --git a/tools/gn/desc_builder.cc b/tools/gn/desc_builder.cc
index d029843..57f27fd 100644
--- a/tools/gn/desc_builder.cc
+++ b/tools/gn/desc_builder.cc
@@ -662,8 +662,6 @@
RenderValue(bundle_data.resources_dir()));
data->SetWithoutPathExpansion("executable_dir",
RenderValue(bundle_data.executable_dir()));
- data->SetWithoutPathExpansion("plugins_dir",
- RenderValue(bundle_data.plugins_dir()));
data->SetKey("product_type", base::Value(bundle_data.product_type()));
data->SetWithoutPathExpansion(
"partial_info_plist", RenderValue(bundle_data.partial_info_plist()));
diff --git a/tools/gn/functions_target.cc b/tools/gn/functions_target.cc
index 72ccf93..be02fc4 100644
--- a/tools/gn/functions_target.cc
+++ b/tools/gn/functions_target.cc
@@ -360,11 +360,10 @@
Variables
bundle_root_dir, bundle_contents_dir, bundle_resources_dir,
- bundle_executable_dir, bundle_plugins_dir, bundle_deps_filter, deps,
- data_deps, public_deps, visibility, product_type, code_signing_args,
- code_signing_script, code_signing_sources, code_signing_outputs,
- xcode_extra_attributes, xcode_test_application_name, partial_info_plist,
- metadata
+ bundle_executable_dir, bundle_deps_filter, deps, data_deps, public_deps,
+ visibility, product_type, code_signing_args, code_signing_script,
+ code_signing_sources, code_signing_outputs, xcode_extra_attributes,
+ xcode_test_application_name, partial_info_plist, metadata
Example
@@ -389,7 +388,7 @@
}
bundle_data("${app_name}_bundle_info_plist") {
- deps = [ ":${app_name}_generate_info_plist" ]
+ public_deps = [ ":${app_name}_generate_info_plist" ]
sources = [ "$gen_path/Info.plist" ]
outputs = [ "{{bundle_contents_dir}}/Info.plist" ]
}
@@ -406,34 +405,32 @@
code_signing =
defined(invoker.code_signing) && invoker.code_signing
- if (is_ios && !code_signing) {
+ if (!is_ios || !code_signing) {
bundle_data("${app_name}_bundle_executable") {
- deps = [ ":${app_name}_generate_executable" ]
+ public_deps = [ ":${app_name}_generate_executable" ]
sources = [ "$gen_path/$app_name" ]
outputs = [ "{{bundle_executable_dir}}/$app_name" ]
}
}
- create_bundle("${app_name}.app") {
+ create_bundle("$app_name.app") {
product_type = "com.apple.product-type.application"
if (is_ios) {
- bundle_root_dir = "${root_build_dir}/$target_name"
+ bundle_root_dir = "$root_build_dir/$target_name"
bundle_contents_dir = bundle_root_dir
bundle_resources_dir = bundle_contents_dir
bundle_executable_dir = bundle_contents_dir
- bundle_plugins_dir = "${bundle_contents_dir}/Plugins"
extra_attributes = {
ONLY_ACTIVE_ARCH = "YES"
DEBUG_INFORMATION_FORMAT = "dwarf"
}
} else {
- bundle_root_dir = "${root_build_dir}/target_name"
- bundle_contents_dir = "${bundle_root_dir}/Contents"
- bundle_resources_dir = "${bundle_contents_dir}/Resources"
- bundle_executable_dir = "${bundle_contents_dir}/MacOS"
- bundle_plugins_dir = "${bundle_contents_dir}/Plugins"
+ bundle_root_dir = "$root_build_dir/$target_name"
+ bundle_contents_dir = "$bundle_root_dir/Contents"
+ bundle_resources_dir = "$bundle_contents_dir/Resources"
+ bundle_executable_dir = "$bundle_contents_dir/MacOS"
}
deps = [ ":${app_name}_bundle_info_plist" ]
if (is_ios && code_signing) {
diff --git a/tools/gn/misc/emacs/gn-mode.el b/tools/gn/misc/emacs/gn-mode.el
index aa33133..5930b58 100644
--- a/tools/gn/misc/emacs/gn-mode.el
+++ b/tools/gn/misc/emacs/gn-mode.el
@@ -83,17 +83,17 @@
(defvar gn-font-lock-var-keywords
'("all_dependent_configs" "allow_circular_includes_from" "arflags" "args"
"asmflags" "assert_no_deps" "bundle_deps_filter" "bundle_executable_dir"
- "bundle_plugins_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" "complete_static_lib" "configs" "data" "data_deps"
- "defines" "depfile" "deps" "include_dirs" "inputs" "ldflags" "lib_dirs"
- "libs" "output_dir" "output_extension" "output_name"
- "output_prefix_override" "outputs" "pool" "precompiled_header"
- "precompiled_header_type" "precompiled_source" "product_type" "public"
- "public_configs" "public_deps" "response_file_contents" "script" "sources"
- "testonly" "visibility" "write_runtime_deps" "bundle_contents_dir"
- "contents" "output_conversion" "rebase" "data_keys" "walk_keys"))
+ "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"
+ "complete_static_lib" "configs" "data" "data_deps" "defines" "depfile"
+ "deps" "include_dirs" "inputs" "ldflags" "lib_dirs" "libs" "output_dir"
+ "output_extension" "output_name" "output_prefix_override" "outputs" "pool"
+ "precompiled_header" "precompiled_header_type" "precompiled_source"
+ "product_type" "public" "public_configs" "public_deps"
+ "response_file_contents" "script" "sources" "testonly" "visibility"
+ "write_runtime_deps" "bundle_contents_dir" "contents" "output_conversion"
+ "rebase" "data_keys" "walk_keys"))
(defconst gn-font-lock-keywords
`((,(regexp-opt gn-font-lock-reserved-keywords 'words) .
diff --git a/tools/gn/ninja_create_bundle_target_writer.cc b/tools/gn/ninja_create_bundle_target_writer.cc
index cc816e1..cfc3d91 100644
--- a/tools/gn/ninja_create_bundle_target_writer.cc
+++ b/tools/gn/ninja_create_bundle_target_writer.cc
@@ -16,6 +16,11 @@
namespace {
+bool TargetRequireAssetCatalogCompilation(const Target* target) {
+ return !target->bundle_data().assets_catalog_sources().empty() ||
+ !target->bundle_data().partial_info_plist().is_null();
+}
+
void FailWithMissingToolError(Toolchain::ToolType tool, const Target* target) {
const std::string& tool_name = Toolchain::ToolTypeToName(tool);
g_scheduler->FailWithError(
@@ -33,7 +38,6 @@
bool EnsureAllToolsAvailable(const Target* target) {
const Toolchain::ToolType kRequiredTools[] = {
Toolchain::TYPE_COPY_BUNDLE_DATA,
- Toolchain::TYPE_COMPILE_XCASSETS,
Toolchain::TYPE_STAMP,
};
@@ -44,6 +48,15 @@
}
}
+ // The compile_xcassets tool is only required if the target has asset
+ // catalog resources to compile.
+ if (TargetRequireAssetCatalogCompilation(target)) {
+ if (!target->toolchain()->GetTool(Toolchain::TYPE_COMPILE_XCASSETS)) {
+ FailWithMissingToolError(Toolchain::TYPE_COMPILE_XCASSETS, target);
+ return false;
+ }
+ }
+
return true;
}
@@ -163,8 +176,7 @@
void NinjaCreateBundleTargetWriter::WriteCompileAssetsCatalogStep(
const std::vector<OutputFile>& order_only_deps,
std::vector<OutputFile>* output_files) {
- if (target_->bundle_data().assets_catalog_sources().empty() &&
- target_->bundle_data().partial_info_plist().is_null())
+ if (!TargetRequireAssetCatalogCompilation(target_))
return;
OutputFile compiled_catalog;
diff --git a/tools/gn/ninja_create_bundle_target_writer_unittest.cc b/tools/gn/ninja_create_bundle_target_writer_unittest.cc
index 3c62c59..af7a7f5 100644
--- a/tools/gn/ninja_create_bundle_target_writer_unittest.cc
+++ b/tools/gn/ninja_create_bundle_target_writer_unittest.cc
@@ -22,8 +22,6 @@
SourceDir(bundle_data->contents_dir().value() + "/Resources");
bundle_data->executable_dir() =
SourceDir(bundle_data->contents_dir().value() + "/MacOS");
- bundle_data->plugins_dir() =
- SourceDir(bundle_data->contents_dir().value() + "/Plug Ins");
}
std::unique_ptr<Target> NewAction(const TestWithScope& setup) {
diff --git a/tools/gn/substitution_type.cc b/tools/gn/substitution_type.cc
index 8c0fbb4..d47a8d0 100644
--- a/tools/gn/substitution_type.cc
+++ b/tools/gn/substitution_type.cc
@@ -54,7 +54,6 @@
"{{bundle_contents_dir}}", // SUBSTITUTION_BUNDLE_CONTENTS_DIR
"{{bundle_resources_dir}}", // SUBSTITUTION_BUNDLE_RESOURCES_DIR
"{{bundle_executable_dir}}", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR
- "{{bundle_plugins_dir}}", // SUBSTITUTION_BUNDLE_PLUGINS_DIR
"{{bundle_product_type}}", // SUBSTITUTION_BUNDLE_PRODUCT_TYPE
"{{bundle_partial_info_plist}}", // SUBSTITUTION_BUNDLE_PARTIAL_INFO_PLIST,
@@ -109,7 +108,6 @@
"bundle_contents_dir", // SUBSTITUTION_BUNDLE_CONTENTS_DIR
"bundle_resources_dir", // SUBSTITUTION_BUNDLE_RESOURCES_DIR
"bundle_executable_dir", // SUBSTITUTION_BUNDLE_EXECUTABLE_DIR
- "bundle_plugins_dir", // SUBSTITUTION_BUNDLE_PLUGINS_DIR
"product_type", // SUBSTITUTION_BUNDLE_PRODUCT_TYPE
"partial_info_plist", // SUBSTITUTION_BUNDLE_PARTIAL_INFO_PLIST
@@ -143,8 +141,7 @@
return type == SUBSTITUTION_BUNDLE_ROOT_DIR ||
type == SUBSTITUTION_BUNDLE_CONTENTS_DIR ||
type == SUBSTITUTION_BUNDLE_RESOURCES_DIR ||
- type == SUBSTITUTION_BUNDLE_EXECUTABLE_DIR ||
- type == SUBSTITUTION_BUNDLE_PLUGINS_DIR;
+ type == SUBSTITUTION_BUNDLE_EXECUTABLE_DIR;
}
bool IsValidBundleDataSubstitution(SubstitutionType type) {
@@ -155,8 +152,7 @@
type == SUBSTITUTION_BUNDLE_ROOT_DIR ||
type == SUBSTITUTION_BUNDLE_CONTENTS_DIR ||
type == SUBSTITUTION_BUNDLE_RESOURCES_DIR ||
- type == SUBSTITUTION_BUNDLE_EXECUTABLE_DIR ||
- type == SUBSTITUTION_BUNDLE_PLUGINS_DIR;
+ type == SUBSTITUTION_BUNDLE_EXECUTABLE_DIR;
}
bool IsValidSourceSubstitution(SubstitutionType type) {
diff --git a/tools/gn/substitution_type.h b/tools/gn/substitution_type.h
index 7363e18..9e2bdb7 100644
--- a/tools/gn/substitution_type.h
+++ b/tools/gn/substitution_type.h
@@ -69,7 +69,6 @@
SUBSTITUTION_BUNDLE_CONTENTS_DIR, // {{bundle_contents_dir}}
SUBSTITUTION_BUNDLE_RESOURCES_DIR, // {{bundle_resources_dir}}
SUBSTITUTION_BUNDLE_EXECUTABLE_DIR, // {{bundle_executable_dir}}
- SUBSTITUTION_BUNDLE_PLUGINS_DIR, // {{bundle_plugins_dir}}
// Valid for compile_xcassets tool.
SUBSTITUTION_BUNDLE_PRODUCT_TYPE, // {{bundle_product_type}}
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc
index b2d70fe..673422e 100644
--- a/tools/gn/target_unittest.cc
+++ b/tools/gn/target_unittest.cc
@@ -1053,8 +1053,8 @@
"{{bundle_resources_dir}}/{{source_file_part}}");
ASSERT_TRUE(b.OnResolved(&err));
- c.bundle_data().root_dir() = SourceDir("//out/foo_e.bundle");
- c.bundle_data().resources_dir() = SourceDir("//out/foo_e.bundle/Resources");
+ c.bundle_data().root_dir() = SourceDir("//out/foo_c.bundle");
+ c.bundle_data().resources_dir() = SourceDir("//out/foo_c.bundle/Resources");
d.sources().push_back(SourceFile("//foo/d.txt"));
d.action_values().outputs() = SubstitutionList::MakeForTest(
diff --git a/tools/gn/variables.cc b/tools/gn/variables.cc
index d63a2a7..a809a1c 100644
--- a/tools/gn/variables.cc
+++ b/tools/gn/variables.cc
@@ -592,7 +592,6 @@
bundle_contents_dir = "${bundle_root_dir}/Contents"
bundle_resources_dir = "${bundle_contents_dir}/Resources"
bundle_executable_dir = "${bundle_contents_dir}/MacOS"
- bundle_plugins_dir = "${bundle_contents_dir}/PlugIns"
}
)";
@@ -684,22 +683,6 @@
See "gn help bundle_root_dir" for examples.
)";
-const char kBundlePlugInsDir[] = "bundle_plugins_dir";
-const char kBundlePlugInsDir_HelpShort[] =
- "bundle_plugins_dir: "
- "Expansion of {{bundle_plugins_dir}} in create_bundle.";
-const char kBundlePlugInsDir_Help[] =
- R"(bundle_plugins_dir: Expansion of {{bundle_plugins_dir}} in create_bundle.
-
- A string corresponding to a path in $root_build_dir.
-
- This string is used by the "create_bundle" target to expand the
- {{bundle_plugins_dir}} of the "bundle_data" target it depends on. This must
- correspond to a path under "bundle_root_dir".
-
- See "gn help bundle_root_dir" for examples.
-)";
-
const char kCflags[] = "cflags";
const char kCflags_HelpShort[] =
"cflags: [string list] Flags passed to all C compiler variants.";
@@ -2169,7 +2152,6 @@
INSERT_VARIABLE(BundleResourcesDir)
INSERT_VARIABLE(BundleDepsFilter)
INSERT_VARIABLE(BundleExecutableDir)
- INSERT_VARIABLE(BundlePlugInsDir)
INSERT_VARIABLE(Cflags)
INSERT_VARIABLE(CflagsC)
INSERT_VARIABLE(CflagsCC)
diff --git a/tools/gn/variables.h b/tools/gn/variables.h
index 0ef15b8..09f2c18 100644
--- a/tools/gn/variables.h
+++ b/tools/gn/variables.h
@@ -123,10 +123,6 @@
extern const char kBundleExecutableDir_HelpShort[];
extern const char kBundleExecutableDir_Help[];
-extern const char kBundlePlugInsDir[];
-extern const char kBundlePlugInsDir_HelpShort[];
-extern const char kBundlePlugInsDir_Help[];
-
extern const char kCflags[];
extern const char kCflags_HelpShort[];
extern const char* kCflags_Help;