Browse Source

printing changes

feature/new-parser
Martin Dørum 3 years ago
parent
commit
a4165de6fc
5 changed files with 29 additions and 13 deletions
  1. 12
    5
      lib/CompileStep.cc
  2. 2
    2
      lib/LinkStep.cc
  3. 8
    3
      lib/sys.cc
  4. 1
    0
      lib/sys.h
  5. 6
    3
      lib/toolchain.cc

+ 12
- 5
lib/CompileStep.cc View File

@@ -79,10 +79,6 @@ bool CompileStep::checkHasChanged(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 dirPath = sys::dirname(objPath);
@@ -100,7 +96,18 @@ void CompileStep::doBuild(const std::string &outDir) {
writer.write(newCachedVars);

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);
}


+ 2
- 2
lib/LinkStep.cc View File

@@ -43,7 +43,6 @@ bool LinkStep::checkHasChanged(const std::string &outDir) {
}

void LinkStep::doBuild(const std::string &outDir) {
logger::log("Link " + path_);
std::vector<std::string> command = linkCommand(outDir);
std::string dirPath = sys::dirname(outDir + '/' + path_);

@@ -57,7 +56,8 @@ void LinkStep::doBuild(const std::string &outDir) {

sys::mkdirp(dirPath);
sys::ProcConf conf;
conf.print = global::verbose >= 1;
conf.print = true;
conf.prefix = "(LD)";
sys::execute(command, conf);
}


+ 8
- 3
lib/sys.cc View File

@@ -99,7 +99,8 @@ void mkdirp(const std::string &path) {
argv.push_back("--");
argv.push_back(path);
ProcConf conf;
conf.print = global::verbose >= 2;
conf.print = global::verbose >= 1;
conf.prefix = "(MKDIRP)";
execute(argv, conf);
}

@@ -112,12 +113,13 @@ void rmrf(const std::string &path) {
argv.push_back("--");
argv.push_back(path);
ProcConf conf;
conf.print = global::verbose >= 2;
conf.print = global::verbose >= 1;
conf.prefix = "(RMRF)";
execute(argv, conf);
}

void execute(const std::vector<std::string> &args, const ProcConf &conf) {
if (conf.print) {
if (conf.print || global::verbose >= 2) {
std::string str;
for (size_t i = 0; i < args.size(); ++i) {
if (i != 0) {
@@ -125,6 +127,9 @@ void execute(const std::vector<std::string> &args, const ProcConf &conf) {
}
str += args[i];
}
if (conf.prefix.size() > 0) {
str = conf.prefix + " " + str;
}
logger::log(str);
}


+ 1
- 0
lib/sys.h View File

@@ -20,6 +20,7 @@ struct FileInfo {
struct ProcConf {
bool print = false;
bool forwardSignals = false;
std::string prefix;
std::string *output = nullptr;
};


+ 6
- 3
lib/toolchain.cc View File

@@ -142,7 +142,8 @@ void getFlags(const BXVariables &vars, FileType type, std::vector<std::string> &
// Execute $(PKG_CONFIG) --cflags $(PKGS)
std::string output;
sys::ProcConf conf;
conf.print = global::verbose >= 2;
conf.print = global::verbose >= 1;
conf.prefix = "(PKGCONFIG)";
conf.output = &output;
sys::execute(argv, conf);
parseWhitespaceSeparated(output, flags);
@@ -205,7 +206,8 @@ void getLDLibs(const BXVariables &vars, std::vector<std::string> &flags) {
// Execute $(PKG_CONFIG) --cflags $(PKGS)
std::string output;
sys::ProcConf conf;
conf.print = global::verbose >= 2;
conf.print = global::verbose >= 1;
conf.prefix = "(PKGCONFIG)";
conf.output = &output;
sys::execute(argv, conf);
parseWhitespaceSeparated(output, flags);
@@ -256,8 +258,9 @@ std::vector<std::string> getDependencies(
// Execute $(compiler) $(flags) -MM $<
std::string output;
sys::ProcConf conf;
conf.print = global::verbose >= 2;
conf.print = global::verbose >= 1;
conf.output = &output;
conf.prefix = "(DEP)";
sys::execute(argv, conf);

std::vector<std::string> deps;

Loading…
Cancel
Save