| toolchain::FileType type_; | toolchain::FileType type_; | ||||
| bool checkHasChanged(const std::string &outDir) override; | bool checkHasChanged(const std::string &outDir) override; | ||||
| toolchain::FileType doGetLinkType() override { return type_; } | |||||
| void doBuild(const std::string &outDir) override; | void doBuild(const std::string &outDir) override; | ||||
| void doWriteCompDB(const std::string &outDir, compdb::Writer &w) override; | void doWriteCompDB(const std::string &outDir, compdb::Writer &w) override; | ||||
| std::vector<std::string> getPublicLDFlags(const std::string &outDir) override; | std::vector<std::string> getPublicLDFlags(const std::string &outDir) override; |
| #include <condition_variable> | #include <condition_variable> | ||||
| #include "compdb.h" | #include "compdb.h" | ||||
| #include "toolchain.h" | |||||
| class DepNode { | class DepNode { | ||||
| public: | public: | ||||
| virtual ~DepNode() = default; | virtual ~DepNode() = default; | ||||
| const std::vector<std::shared_ptr<DepNode>> &children() { return deps_; } | const std::vector<std::shared_ptr<DepNode>> &children() { return deps_; } | ||||
| toolchain::FileType linkType() { return doGetLinkType(); } | |||||
| void addChild(std::shared_ptr<DepNode> node); | void addChild(std::shared_ptr<DepNode> node); | ||||
| bool hasChanged(const std::string &outDir); | bool hasChanged(const std::string &outDir); | ||||
| void startBuild(const std::string &outDir); | void startBuild(const std::string &outDir); | ||||
| void joinBuild(); | void joinBuild(); | ||||
| void writeCompDB(const std::string &outDir, compdb::Writer &w); | void writeCompDB(const std::string &outDir, compdb::Writer &w); | ||||
| virtual std::vector<std::string> publicLDFlags(const std::string &outDir); | 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> publicLDLibs(const std::string &outDir); | ||||
| virtual std::vector<std::string> publicObjects(const std::string &outDir); | virtual std::vector<std::string> publicObjects(const std::string &outDir); | ||||
| }; | }; | ||||
| virtual bool checkHasChanged(const std::string &outDir) = 0; | virtual bool checkHasChanged(const std::string &outDir) = 0; | ||||
| virtual toolchain::FileType doGetLinkType() = 0; | |||||
| virtual void doBuild(const std::string &outDir) = 0; | virtual void doBuild(const std::string &outDir) = 0; | ||||
| virtual void doWriteCompDB(const std::string &outDir, compdb::Writer &w) {} | virtual void doWriteCompDB(const std::string &outDir, compdb::Writer &w) {} | ||||
| virtual std::vector<std::string> getPublicLDFlags(const std::string &outDir) { return {}; } | virtual std::vector<std::string> getPublicLDFlags(const std::string &outDir) { return {}; } |
| sys::execute(command, conf); | 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) { | std::vector<std::string> &LinkStep::linkCommand(const std::string &outDir) { | ||||
| if (hasLinkCommand_) { | if (hasLinkCommand_) { | ||||
| return linkCommand_; | return linkCommand_; | ||||
| // TODO: Don't use FileType::CXX hard-coded here | // TODO: Don't use FileType::CXX hard-coded here | ||||
| linkCommand_ = toolchain::getLinkCommand( | linkCommand_ = toolchain::getLinkCommand( | ||||
| publicLDFlags(outDir), publicLDLibs(outDir), | publicLDFlags(outDir), publicLDLibs(outDir), | ||||
| toolchain::FileType::CXX, type_, objs, path_, outDir); | |||||
| linkType(), type_, objs, path_, outDir); | |||||
| hasLinkCommand_ = true; | hasLinkCommand_ = true; | ||||
| return linkCommand_; | return linkCommand_; | ||||
| } | } |
| toolchain::TargetType type_; | toolchain::TargetType type_; | ||||
| bool checkHasChanged(const std::string &outDir) override; | bool checkHasChanged(const std::string &outDir) override; | ||||
| toolchain::FileType doGetLinkType() override; | |||||
| void doBuild(const std::string &outDir) override; | void doBuild(const std::string &outDir) override; | ||||
| bool hasLinkCommand_ = false; | bool hasLinkCommand_ = false; |