#ifndef TOOLS_GN_C_TOOL_H_
#define TOOLS_GN_C_TOOL_H_
#include <string>
#include "base/logging.h"
#include "gn/label.h"
#include "gn/label_ptr.h"
#include "gn/scope.h"
#include "gn/substitution_list.h"
#include "gn/substitution_pattern.h"
#include "gn/tool.h"
#include "gn/toolchain.h"
class CTool : public Tool {
public:
static const char* kCToolCc;
static const char* kCToolCxx;
static const char* kCToolCxxModule;
static const char* kCToolObjC;
static const char* kCToolObjCxx;
static const char* kCToolRc;
static const char* kCToolAsm;
static const char* kCToolSwift;
static const char* kCToolAlink;
static const char* kCToolSolink;
static const char* kCToolSolinkModule;
static const char* kCToolLink;
enum DepsFormat { DEPS_GCC = 0, DEPS_MSVC = 1 };
enum PrecompiledHeaderType { PCH_NONE = 0, PCH_GCC = 1, PCH_MSVC = 2 };
CTool(const char* n);
~CTool();
bool InitTool(Scope* block_scope, Toolchain* toolchain, Err* err);
bool ValidateName(const char* name) const override;
void SetComplete() override;
bool ValidateSubstitution(const Substitution* sub_type) const override;
CTool* AsC() override;
const CTool* AsC() const override;
DepsFormat depsformat() const { return depsformat_; }
void set_depsformat(DepsFormat f) {
DCHECK(!complete_);
depsformat_ = f;
}
PrecompiledHeaderType precompiled_header_type() const {
return precompiled_header_type_;
}
void set_precompiled_header_type(PrecompiledHeaderType pch_type) {
DCHECK(!complete_);
precompiled_header_type_ = pch_type;
}
const SubstitutionPattern& link_output() const { return link_output_; }
void set_link_output(SubstitutionPattern link_out) {
DCHECK(!complete_);
link_output_ = std::move(link_out);
}
const SubstitutionPattern& depend_output() const { return depend_output_; }
void set_depend_output(SubstitutionPattern dep_out) {
DCHECK(!complete_);
depend_output_ = std::move(dep_out);
}
int toolchain_whole_status() const { return toolchain_whole_status_; }
void set_toolchain_whole_status(int status) {
DCHECK(!complete_);
toolchain_whole_status_ = status;
}
private:
bool ValidateOutputSubstitution(const Substitution* sub_type) const;
bool ValidateRuntimeOutputs(Err* err);
bool ValidateLinkAndDependOutput(const SubstitutionPattern& pattern,
const char* variable_name,
Err* err);
bool ReadOutputsPatternList(Scope* scope,
const char* var,
bool required,
SubstitutionList* field,
Err* err);
bool ReadPrecompiledHeaderType(Scope* scope, Err* err);
bool ReadDepsFormat(Scope* scope, Err* err);
DepsFormat depsformat_;
PrecompiledHeaderType precompiled_header_type_;
SubstitutionPattern link_output_;
SubstitutionPattern depend_output_;
int toolchain_whole_status_ = -1;
CTool(const CTool&) = delete;
CTool& operator=(const CTool&) = delete;
};
#endif