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_
11 #include "base/macros.h"
12 #include "tools/gn/label_ptr.h"
13 #include "tools/gn/unique_vector.h"
17 class FunctionCallNode
;
19 class SubstitutionPattern
;
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
26 class TargetGenerator
{
28 TargetGenerator(Target
* target
,
30 const FunctionCallNode
* function_call
,
32 virtual ~TargetGenerator();
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
,
45 // Derived classes implement this to do type-specific generation.
46 virtual void DoRun() = 0;
48 const BuildSettings
* GetBuildSettings() const;
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
60 bool EnsureSubstitutionIsInOutputDir(const SubstitutionPattern
& pattern
,
61 const Value
& original_value
);
65 const FunctionCallNode
* function_call_
;
69 bool FillDependentConfigs(); // Includes all types of dependent configs.
71 bool FillDependencies(); // Includes data dependencies.
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_