#ifndef TOOLS_GN_TARGET_GENERATOR_H_
#define TOOLS_GN_TARGET_GENERATOR_H_
#include <string>
#include <vector>
#include "gn/label_ptr.h"
#include "gn/unique_vector.h"
class BuildSettings;
class Err;
class FunctionCallNode;
class Scope;
class SubstitutionPattern;
class Value;
class TargetGenerator {
public:
TargetGenerator(Target* target,
Scope* scope,
const FunctionCallNode* function_call,
Err* err);
virtual ~TargetGenerator();
void Run();
static void GenerateTarget(Scope* scope,
const FunctionCallNode* function_call,
const std::vector<Value>& args,
const std::string& output_type,
Err* err);
protected:
virtual void DoRun() = 0;
const BuildSettings* GetBuildSettings() const;
virtual bool FillSources();
bool FillIncludes();
bool FillPublic();
bool FillConfigs();
bool FillOwnConfigs();
bool FillOutputs(bool allow_substitutions);
bool FillCheckIncludes();
bool FillOutputExtension();
bool EnsureSubstitutionIsInOutputDir(const SubstitutionPattern& pattern,
const Value& original_value);
Target* target_;
Scope* scope_;
const FunctionCallNode* function_call_;
Err* err_;
private:
bool FillDependentConfigs();
bool FillData();
bool FillDependencies();
bool FillMetadata();
bool FillTestonly();
bool FillAssertNoDeps();
bool FillWriteRuntimeDeps();
void FillCheckFlag();
bool FillGenericConfigs(const char* var_name,
UniqueVector<LabelConfigPair>* dest);
bool FillGenericDeps(const char* var_name, LabelTargetVector* dest);
bool FillOhosComponentDeps(const char* var_name, LabelTargetVector* dest,
LabelTargetVector* whole_dest, LabelTargetVector* no_whole_dest);
bool FillGenericDepsWithWholeArchive(const char* var_name, LabelTargetVector* dest,
LabelTargetVector* whole_dest, LabelTargetVector* no_whole_dest);
TargetGenerator(const TargetGenerator&) = delete;
TargetGenerator& operator=(const TargetGenerator&) = delete;
};
#endif