Index: tools/gn/ninja_create_bundle_target_writer_unittest.cc |
diff --git a/tools/gn/ninja_create_bundle_target_writer_unittest.cc b/tools/gn/ninja_create_bundle_target_writer_unittest.cc |
index d35b519adc2649e7253469185763c05b7443b463..1c6f8e019947919430f852d08e7f865363636345 100644 |
--- a/tools/gn/ninja_create_bundle_target_writer_unittest.cc |
+++ b/tools/gn/ninja_create_bundle_target_writer_unittest.cc |
@@ -53,7 +53,6 @@ TEST(NinjaCreateBundleTargetWriter, Run) { |
"../../foo/input1.txt\n" |
"build bar.bundle/Resources/input2.txt: copy_bundle_data " |
"../../foo/input2.txt\n" |
- "\n" |
"build obj/baz/bar.stamp: stamp " |
"bar.bundle/Resources/input1.txt " |
"bar.bundle/Resources/input2.txt\n" |
@@ -98,7 +97,6 @@ TEST(NinjaCreateBundleTargetWriter, AssetCatalog) { |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29.png " |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@2x.png " |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@3x.png\n" |
- "\n" |
"build obj/baz/bar.stamp: stamp bar.bundle/Resources/Assets.car\n" |
"build bar.bundle: phony obj/baz/bar.stamp\n"; |
std::string out_str = out.str(); |
@@ -141,7 +139,6 @@ TEST(NinjaCreateBundleTargetWriter, BundleRootDirOutput) { |
"../../foo/input1.txt\n" |
"build bar.bundle/Contents/Resources/input2.txt: copy_bundle_data " |
"../../foo/input2.txt\n" |
- "\n" |
"build obj/baz/bar.stamp: stamp " |
"bar.bundle/Contents/Resources/input1.txt " |
"bar.bundle/Contents/Resources/input2.txt\n" |
@@ -152,7 +149,7 @@ TEST(NinjaCreateBundleTargetWriter, BundleRootDirOutput) { |
// Tests complex target with multiple bundle_data sources, including |
// some asset catalog. |
-TEST(NinjaCreateBundleTargetWriter, OrderOnlyDeps) { |
+TEST(NinjaCreateBundleTargetWriter, ImplicitDeps) { |
TestWithScope setup; |
Err err; |
@@ -203,14 +200,14 @@ TEST(NinjaCreateBundleTargetWriter, OrderOnlyDeps) { |
"../../foo/input1.txt\n" |
"build bar.bundle/Resources/input2.txt: copy_bundle_data " |
"../../foo/input2.txt\n" |
- "build bar.bundle/Info.plist: copy_bundle_data ../../qux/Info.plist\n" |
+ "build bar.bundle/Info.plist: copy_bundle_data " |
+ "../../qux/Info.plist\n" |
"build bar.bundle/Resources/Assets.car: compile_xcassets " |
"../../foo/Foo.xcassets | " |
"../../foo/Foo.xcassets/foo.imageset/Contents.json " |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29.png " |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@2x.png " |
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@3x.png\n" |
- "\n" |
"build obj/baz/bar.stamp: stamp " |
"bar.bundle/Resources/input1.txt " |
"bar.bundle/Resources/input2.txt " |
@@ -220,3 +217,82 @@ TEST(NinjaCreateBundleTargetWriter, OrderOnlyDeps) { |
std::string out_str = out.str(); |
EXPECT_EQ(expected, out_str); |
} |
+ |
+// Tests multiple files with an output pattern. |
+TEST(NinjaCreateBundleTargetWriter, CodeSigning) { |
+ TestWithScope setup; |
+ Err err; |
+ |
+ setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
+ |
+ // Simulate a binary build by another target. Since no toolchain is defined |
+ // use an action instead of an executable target for simplicity. |
+ Target binary(setup.settings(), Label(SourceDir("//baz/"), "quz")); |
+ binary.set_output_type(Target::EXECUTABLE); |
+ binary.visibility().SetPublic(); |
+ binary.sources().push_back(SourceFile("//baz/quz.c")); |
+ binary.set_output_name("obj/baz/quz/bin"); |
+ binary.set_output_prefix_override(true); |
+ binary.SetToolchain(setup.toolchain()); |
+ ASSERT_TRUE(binary.OnResolved(&err)); |
+ |
+ Target target(setup.settings(), |
+ Label(SourceDir("//baz/"), "bar", |
+ setup.toolchain()->label().dir(), |
+ setup.toolchain()->label().name())); |
+ target.set_output_type(Target::CREATE_BUNDLE); |
+ |
+ SetupBundleDataDir(&target.bundle_data(), "//out/Debug"); |
+ |
+ std::vector<SourceFile> sources; |
+ sources.push_back(SourceFile("//foo/input1.txt")); |
+ sources.push_back(SourceFile("//foo/input2.txt")); |
+ target.bundle_data().file_rules().push_back(BundleFileRule( |
+ sources, SubstitutionPattern::MakeForTest( |
+ "{{bundle_resources_dir}}/{{source_file_part}}"))); |
+ |
+ target.bundle_data().set_code_signing_script( |
+ SourceFile("//build/codesign.py")); |
+ target.bundle_data().code_signing_sources().push_back( |
+ SourceFile("//out/Debug/obj/baz/quz/bin")); |
+ target.bundle_data().code_signing_outputs() = SubstitutionList::MakeForTest( |
+ "//out/Debug/bar.bundle/quz", |
+ "//out/Debug/bar.bundle/_CodeSignature/CodeResources"); |
+ target.bundle_data().code_signing_args() = SubstitutionList::MakeForTest( |
+ "-b=obj/baz/quz/bin", |
+ "bar.bundle"); |
+ |
+ target.public_deps().push_back(LabelTargetPair(&binary)); |
+ |
+ target.SetToolchain(setup.toolchain()); |
+ ASSERT_TRUE(target.OnResolved(&err)); |
+ |
+ std::ostringstream out; |
+ NinjaCreateBundleTargetWriter writer(&target, out); |
+ writer.Run(); |
+ |
+ const char expected[] = |
+ "rule __baz_bar___toolchain_default__code_signing_rule\n" |
+ " command = ../../build/codesign.py -b=obj/baz/quz/bin bar.bundle\n" |
+ " description = CODE SIGNING //baz:bar(//toolchain:default)\n" |
+ " restat = 1\n" |
+ "\n" |
+ "build bar.bundle/Resources/input1.txt: copy_bundle_data " |
+ "../../foo/input1.txt\n" |
+ "build bar.bundle/Resources/input2.txt: copy_bundle_data " |
+ "../../foo/input2.txt\n" |
+ "build obj/baz/bar.codesigning.inputdeps.stamp: stamp " |
+ "../../build/codesign.py " |
+ "obj/baz/quz/bin " |
+ "bar.bundle/Resources/input1.txt " |
+ "bar.bundle/Resources/input2.txt\n" |
+ "build bar.bundle/quz bar.bundle/_CodeSignature/CodeResources: " |
+ "__baz_bar___toolchain_default__code_signing_rule " |
+ "| obj/baz/bar.codesigning.inputdeps.stamp\n" |
+ "build obj/baz/bar.stamp: stamp " |
+ "bar.bundle/quz " |
+ "bar.bundle/_CodeSignature/CodeResources\n" |
+ "build bar.bundle: phony obj/baz/bar.stamp\n"; |
+ std::string out_str = out.str(); |
+ EXPECT_EQ(expected, out_str); |
+} |