@@ -15,6 +15,7 @@ private: | |||
toolchain::FileType type_; | |||
bool checkHasChanged(const std::string &outDir) override; | |||
toolchain::FileType doGetLinkType() override { return type_; } | |||
void doBuild(const std::string &outDir) override; | |||
void doWriteCompDB(const std::string &outDir, compdb::Writer &w) override; | |||
std::vector<std::string> getPublicLDFlags(const std::string &outDir) override; |
@@ -9,17 +9,20 @@ | |||
#include <condition_variable> | |||
#include "compdb.h" | |||
#include "toolchain.h" | |||
class DepNode { | |||
public: | |||
virtual ~DepNode() = default; | |||
const std::vector<std::shared_ptr<DepNode>> &children() { return deps_; } | |||
toolchain::FileType linkType() { return doGetLinkType(); } | |||
void addChild(std::shared_ptr<DepNode> node); | |||
bool hasChanged(const std::string &outDir); | |||
void startBuild(const std::string &outDir); | |||
void joinBuild(); | |||
void writeCompDB(const std::string &outDir, compdb::Writer &w); | |||
virtual std::vector<std::string> publicLDFlags(const std::string &outDir); | |||
virtual std::vector<std::string> publicLDLibs(const std::string &outDir); | |||
virtual std::vector<std::string> publicObjects(const std::string &outDir); | |||
@@ -30,6 +33,7 @@ protected: | |||
}; | |||
virtual bool checkHasChanged(const std::string &outDir) = 0; | |||
virtual toolchain::FileType doGetLinkType() = 0; | |||
virtual void doBuild(const std::string &outDir) = 0; | |||
virtual void doWriteCompDB(const std::string &outDir, compdb::Writer &w) {} | |||
virtual std::vector<std::string> getPublicLDFlags(const std::string &outDir) { return {}; } |
@@ -61,6 +61,16 @@ void LinkStep::doBuild(const std::string &outDir) { | |||
sys::execute(command, conf); | |||
} | |||
toolchain::FileType LinkStep::doGetLinkType() { | |||
for (auto &child: children()) { | |||
if (child->linkType() == toolchain::FileType::CXX) { | |||
return toolchain::FileType::CXX; | |||
} | |||
} | |||
return toolchain::FileType::C; | |||
} | |||
std::vector<std::string> &LinkStep::linkCommand(const std::string &outDir) { | |||
if (hasLinkCommand_) { | |||
return linkCommand_; | |||
@@ -76,7 +86,7 @@ std::vector<std::string> &LinkStep::linkCommand(const std::string &outDir) { | |||
// TODO: Don't use FileType::CXX hard-coded here | |||
linkCommand_ = toolchain::getLinkCommand( | |||
publicLDFlags(outDir), publicLDLibs(outDir), | |||
toolchain::FileType::CXX, type_, objs, path_, outDir); | |||
linkType(), type_, objs, path_, outDir); | |||
hasLinkCommand_ = true; | |||
return linkCommand_; | |||
} |
@@ -15,6 +15,7 @@ private: | |||
toolchain::TargetType type_; | |||
bool checkHasChanged(const std::string &outDir) override; | |||
toolchain::FileType doGetLinkType() override; | |||
void doBuild(const std::string &outDir) override; | |||
bool hasLinkCommand_ = false; |