• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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_GENERATED_FILE_TARGET_GENERATOR_H_
6 #define TOOLS_GN_GENERATED_FILE_TARGET_GENERATOR_H_
7 
8 #include "base/macros.h"
9 #include "gn/target.h"
10 #include "gn/target_generator.h"
11 
12 // Collects and writes specified data.
13 class GeneratedFileTargetGenerator : public TargetGenerator {
14  public:
15   GeneratedFileTargetGenerator(Target* target,
16                                Scope* scope,
17                                const FunctionCallNode* function_call,
18                                Target::OutputType type,
19                                Err* err);
20   ~GeneratedFileTargetGenerator() override;
21 
22  protected:
23   void DoRun() override;
24 
25  private:
26   bool FillGeneratedFileOutput();
27   bool FillOutputConversion();
28   bool FillContents();
29   bool FillDataKeys();
30   bool FillWalkKeys();
31   bool FillRebase();
32 
33   // Returns false if `contents` is defined (i.e. if this target was provided
34   // with explicit contents to write). Returns false otherwise, indicating that
35   // it is okay to set metadata collection variables on this target.
36   //
37   // Should be called before FillContents().
38   bool IsMetadataCollectionTarget(const std::string_view& variable,
39                                   const ParseNode* origin);
40 
41   bool contents_defined_ = false;
42   bool data_keys_defined_ = false;
43 
44   Target::OutputType output_type_;
45 
46   DISALLOW_COPY_AND_ASSIGN(GeneratedFileTargetGenerator);
47 };
48 
49 #endif  // TOOLS_GN_GENERATED_FILE_TARGET_GENERATOR_H_
50