• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_
6 #define TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_
7 
8 #include "gn/ninja_target_writer.h"
9 
10 class BundleFileRule;
11 
12 // Writes a .ninja file for a bundle_data target type.
13 class NinjaCreateBundleTargetWriter : public NinjaTargetWriter {
14  public:
15   NinjaCreateBundleTargetWriter(const Target* target, std::ostream& out);
16   ~NinjaCreateBundleTargetWriter() override;
17 
18   void Run() override;
19 
20  private:
21   // Writes the Ninja rule for invoking the code signing script.
22   //
23   // Returns the name of the custom rule generated for the code signing step if
24   // defined, otherwise returns an empty string.
25   std::string WriteCodeSigningRuleDefinition();
26 
27   // Writes the steps to copy files into the bundle.
28   //
29   // The list of newly created files will be added to |output_files|.
30   void WriteCopyBundleDataSteps(const std::vector<OutputFile>& order_only_deps,
31                                 std::vector<OutputFile>* output_files);
32 
33   // Writes the step to copy files BundleFileRule into the bundle.
34   //
35   // The list of newly created files will be added to |output_files|.
36   void WriteCopyBundleFileRuleSteps(
37       const BundleFileRule& file_rule,
38       const std::vector<OutputFile>& order_only_deps,
39       std::vector<OutputFile>* output_files);
40 
41   // Writes the step to compile assets catalogs.
42   //
43   // The list of newly created files will be added to |output_files|.
44   void WriteCompileAssetsCatalogStep(
45       const std::vector<OutputFile>& order_only_deps,
46       std::vector<OutputFile>* output_files);
47 
48   // Writes the stamp file for the assets catalog compilation input
49   // dependencies.
50   OutputFile WriteCompileAssetsCatalogInputDepsStamp(
51       const std::vector<const Target*>& dependencies);
52 
53   // Writes the code signing step (if a script is defined).
54   //
55   // The list of newly created files will be added to |output_files|. As the
56   // code signing may depends on the full bundle structure, this step will
57   // depends on all files generated via other rules.
58   void WriteCodeSigningStep(const std::string& code_signing_rule_name,
59                             const std::vector<OutputFile>& order_only_deps,
60                             std::vector<OutputFile>* output_files);
61 
62   // Writes the stamp file for the code signing input dependencies.
63   OutputFile WriteCodeSigningInputDepsStamp(
64       const std::vector<OutputFile>& order_only_deps,
65       std::vector<OutputFile>* output_files);
66 
67   NinjaCreateBundleTargetWriter(const NinjaCreateBundleTargetWriter&) = delete;
68   NinjaCreateBundleTargetWriter& operator=(
69       const NinjaCreateBundleTargetWriter&) = delete;
70 };
71 
72 #endif  // TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_
73