summaryrefslogtreecommitdiff
path: root/gn/tools/gn/ninja_create_bundle_target_writer.h
blob: 072e02c2a7377eabfcef8126f21619058a57c079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_
#define TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_

#include "base/macros.h"
#include "tools/gn/ninja_target_writer.h"

class BundleFileRule;

// Writes a .ninja file for a bundle_data target type.
class NinjaCreateBundleTargetWriter : public NinjaTargetWriter {
 public:
  NinjaCreateBundleTargetWriter(const Target* target, std::ostream& out);
  ~NinjaCreateBundleTargetWriter() override;

  void Run() override;

 private:
  // Writes the Ninja rule for invoking the code signing script.
  //
  // Returns the name of the custom rule generated for the code signing step if
  // defined, otherwise returns an empty string.
  std::string WriteCodeSigningRuleDefinition();

  // Writes the steps to copy files into the bundle.
  //
  // The list of newly created files will be added to |output_files|.
  void WriteCopyBundleDataSteps(const std::vector<OutputFile>& order_only_deps,
                                std::vector<OutputFile>* output_files);

  // Writes the step to copy files BundleFileRule into the bundle.
  //
  // The list of newly created files will be added to |output_files|.
  void WriteCopyBundleFileRuleSteps(
      const BundleFileRule& file_rule,
      const std::vector<OutputFile>& order_only_deps,
      std::vector<OutputFile>* output_files);

  // Writes the step to compile assets catalogs.
  //
  // The list of newly created files will be added to |output_files|.
  void WriteCompileAssetsCatalogStep(
      const std::vector<OutputFile>& order_only_deps,
      std::vector<OutputFile>* output_files);

  // Writes the stamp file for the assets catalog compilation input
  // dependencies.
  OutputFile WriteCompileAssetsCatalogInputDepsStamp(
      const std::vector<const Target*>& dependencies);

  // Writes the code signing 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
  // 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);

  // Writes the stamp file for the code signing input dependencies.
  OutputFile WriteCodeSigningInputDepsStamp(
      const std::vector<OutputFile>& order_only_deps,
      std::vector<OutputFile>* output_files);

  DISALLOW_COPY_AND_ASSIGN(NinjaCreateBundleTargetWriter);
};

#endif  // TOOLS_GN_NINJA_CREATE_BUNDLE_TARGET_WRITER_H_