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/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "tools/gn/source_dir.h"
14 #include "tools/gn/target.h"
18 class FunctionCallNode
;
23 // Fills the variables in a Target object from a Scope (the result of a script
24 // execution). Target-type-specific derivations of this class will be used
25 // for each different type of function call. This class implements the common
27 class TargetGenerator
{
29 TargetGenerator(Target
* target
,
31 const FunctionCallNode
* function_call
,
37 // The function call is the parse tree node that invoked the target.
38 // err() will be set on failure.
39 static void GenerateTarget(Scope
* scope
,
40 const FunctionCallNode
* function_call
,
41 const std::vector
<Value
>& args
,
42 const std::string
& output_type
,
46 // Derived classes implement this to do type-specific generation.
47 virtual void DoRun() = 0;
49 const BuildSettings
* GetBuildSettings() const;
55 bool FillOutputs(bool allow_substitutions
);
56 bool FillCheckIncludes();
58 // Rrturns true if the given pattern will expand to a file in the output
59 // directory. If not, returns false and sets the error, blaming the given
61 bool EnsureSubstitutionIsInOutputDir(
62 const SubstitutionPattern
& pattern
,
63 const Value
& original_value
);
67 const FunctionCallNode
* function_call_
;
71 bool FillDependentConfigs(); // Includes all types of dependent configs.
73 bool FillDependencies(); // Includes data dependencies.
76 // Reads configs/deps from the given var name, and uses the given setting on
77 // the target to save them.
78 bool FillGenericConfigs(const char* var_name
,
79 UniqueVector
<LabelConfigPair
>* dest
);
80 bool FillGenericDeps(const char* var_name
, LabelTargetVector
* dest
);
82 bool FillForwardDependentConfigs();
84 DISALLOW_COPY_AND_ASSIGN(TargetGenerator
);
87 #endif // TOOLS_GN_TARGET_GENERATOR_H_