} | } | ||||
void CompileStep::doBuild(const std::string &outDir) { | void CompileStep::doBuild(const std::string &outDir) { | ||||
bool verboseCommand = global::verbose >= 1; | |||||
if (!verboseCommand) { | |||||
logger::log("Compile " + path_); | |||||
} | |||||
std::string objPath = toolchain::objectFilePath(path_, outDir); | std::string objPath = toolchain::objectFilePath(path_, outDir); | ||||
std::string dirPath = sys::dirname(objPath); | std::string dirPath = sys::dirname(objPath); | ||||
writer.write(newCachedVars); | writer.write(newCachedVars); | ||||
sys::ProcConf conf; | sys::ProcConf conf; | ||||
conf.print = verboseCommand; | |||||
conf.print = true; | |||||
switch (type_) { | |||||
case toolchain::FileType::C: | |||||
conf.prefix = "(CC)"; | |||||
break; | |||||
case toolchain::FileType::CXX: | |||||
conf.prefix = "(CXX)"; | |||||
break; | |||||
} | |||||
sys::execute(command, conf); | sys::execute(command, conf); | ||||
} | } | ||||
} | } | ||||
void LinkStep::doBuild(const std::string &outDir) { | void LinkStep::doBuild(const std::string &outDir) { | ||||
logger::log("Link " + path_); | |||||
std::vector<std::string> command = linkCommand(outDir); | std::vector<std::string> command = linkCommand(outDir); | ||||
std::string dirPath = sys::dirname(outDir + '/' + path_); | std::string dirPath = sys::dirname(outDir + '/' + path_); | ||||
sys::mkdirp(dirPath); | sys::mkdirp(dirPath); | ||||
sys::ProcConf conf; | sys::ProcConf conf; | ||||
conf.print = global::verbose >= 1; | |||||
conf.print = true; | |||||
conf.prefix = "(LD)"; | |||||
sys::execute(command, conf); | sys::execute(command, conf); | ||||
} | } | ||||
argv.push_back("--"); | argv.push_back("--"); | ||||
argv.push_back(path); | argv.push_back(path); | ||||
ProcConf conf; | ProcConf conf; | ||||
conf.print = global::verbose >= 2; | |||||
conf.print = global::verbose >= 1; | |||||
conf.prefix = "(MKDIRP)"; | |||||
execute(argv, conf); | execute(argv, conf); | ||||
} | } | ||||
argv.push_back("--"); | argv.push_back("--"); | ||||
argv.push_back(path); | argv.push_back(path); | ||||
ProcConf conf; | ProcConf conf; | ||||
conf.print = global::verbose >= 2; | |||||
conf.print = global::verbose >= 1; | |||||
conf.prefix = "(RMRF)"; | |||||
execute(argv, conf); | execute(argv, conf); | ||||
} | } | ||||
void execute(const std::vector<std::string> &args, const ProcConf &conf) { | void execute(const std::vector<std::string> &args, const ProcConf &conf) { | ||||
if (conf.print) { | |||||
if (conf.print || global::verbose >= 2) { | |||||
std::string str; | std::string str; | ||||
for (size_t i = 0; i < args.size(); ++i) { | for (size_t i = 0; i < args.size(); ++i) { | ||||
if (i != 0) { | if (i != 0) { | ||||
} | } | ||||
str += args[i]; | str += args[i]; | ||||
} | } | ||||
if (conf.prefix.size() > 0) { | |||||
str = conf.prefix + " " + str; | |||||
} | |||||
logger::log(str); | logger::log(str); | ||||
} | } | ||||
struct ProcConf { | struct ProcConf { | ||||
bool print = false; | bool print = false; | ||||
bool forwardSignals = false; | bool forwardSignals = false; | ||||
std::string prefix; | |||||
std::string *output = nullptr; | std::string *output = nullptr; | ||||
}; | }; | ||||
// Execute $(PKG_CONFIG) --cflags $(PKGS) | // Execute $(PKG_CONFIG) --cflags $(PKGS) | ||||
std::string output; | std::string output; | ||||
sys::ProcConf conf; | sys::ProcConf conf; | ||||
conf.print = global::verbose >= 2; | |||||
conf.print = global::verbose >= 1; | |||||
conf.prefix = "(PKGCONFIG)"; | |||||
conf.output = &output; | conf.output = &output; | ||||
sys::execute(argv, conf); | sys::execute(argv, conf); | ||||
parseWhitespaceSeparated(output, flags); | parseWhitespaceSeparated(output, flags); | ||||
// Execute $(PKG_CONFIG) --cflags $(PKGS) | // Execute $(PKG_CONFIG) --cflags $(PKGS) | ||||
std::string output; | std::string output; | ||||
sys::ProcConf conf; | sys::ProcConf conf; | ||||
conf.print = global::verbose >= 2; | |||||
conf.print = global::verbose >= 1; | |||||
conf.prefix = "(PKGCONFIG)"; | |||||
conf.output = &output; | conf.output = &output; | ||||
sys::execute(argv, conf); | sys::execute(argv, conf); | ||||
parseWhitespaceSeparated(output, flags); | parseWhitespaceSeparated(output, flags); | ||||
// Execute $(compiler) $(flags) -MM $< | // Execute $(compiler) $(flags) -MM $< | ||||
std::string output; | std::string output; | ||||
sys::ProcConf conf; | sys::ProcConf conf; | ||||
conf.print = global::verbose >= 2; | |||||
conf.print = global::verbose >= 1; | |||||
conf.output = &output; | conf.output = &output; | ||||
conf.prefix = "(DEP)"; | |||||
sys::execute(argv, conf); | sys::execute(argv, conf); | ||||
std::vector<std::string> deps; | std::vector<std::string> deps; |