Add window.gc back to Smoothness.WillNavigateToPageHook
[chromium-blink-merge.git] / tools / gn / target_generator.h
blob83e3af1d9f0bb34c76ee81be05d1895406e14b6a
1 // Copyright (c) 2013 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.
5 #ifndef TOOLS_GN_TARGET_GENERATOR_H_
6 #define TOOLS_GN_TARGET_GENERATOR_H_
8 #include <string>
9 #include <vector>
11 #include "base/macros.h"
12 #include "tools/gn/label_ptr.h"
13 #include "tools/gn/unique_vector.h"
15 class BuildSettings;
16 class Err;
17 class FunctionCallNode;
18 class Scope;
19 class SubstitutionPattern;
20 class Value;
22 // Fills the variables in a Target object from a Scope (the result of a script
23 // execution). Target-type-specific derivations of this class will be used
24 // for each different type of function call. This class implements the common
25 // behavior.
26 class TargetGenerator {
27 public:
28 TargetGenerator(Target* target,
29 Scope* scope,
30 const FunctionCallNode* function_call,
31 Err* err);
32 virtual ~TargetGenerator();
34 void Run();
36 // The function call is the parse tree node that invoked the target.
37 // err() will be set on failure.
38 static void GenerateTarget(Scope* scope,
39 const FunctionCallNode* function_call,
40 const std::vector<Value>& args,
41 const std::string& output_type,
42 Err* err);
44 protected:
45 // Derived classes implement this to do type-specific generation.
46 virtual void DoRun() = 0;
48 const BuildSettings* GetBuildSettings() const;
50 bool FillSources();
51 bool FillPublic();
52 bool FillInputs();
53 bool FillConfigs();
54 bool FillOutputs(bool allow_substitutions);
55 bool FillCheckIncludes();
57 // Rrturns true if the given pattern will expand to a file in the output
58 // directory. If not, returns false and sets the error, blaming the given
59 // Value.
60 bool EnsureSubstitutionIsInOutputDir(const SubstitutionPattern& pattern,
61 const Value& original_value);
63 Target* target_;
64 Scope* scope_;
65 const FunctionCallNode* function_call_;
66 Err* err_;
68 private:
69 bool FillDependentConfigs(); // Includes all types of dependent configs.
70 bool FillData();
71 bool FillDependencies(); // Includes data dependencies.
72 bool FillTestonly();
74 // Reads configs/deps from the given var name, and uses the given setting on
75 // the target to save them.
76 bool FillGenericConfigs(const char* var_name,
77 UniqueVector<LabelConfigPair>* dest);
78 bool FillGenericDeps(const char* var_name, LabelTargetVector* dest);
80 bool FillForwardDependentConfigs();
82 DISALLOW_COPY_AND_ASSIGN(TargetGenerator);
85 #endif // TOOLS_GN_TARGET_GENERATOR_H_