Martin Dørum 5 лет назад
Родитель
Сommit
8dfc567b30
7 измененных файлов: 35 добавлений и 14 удалений
  1. 5
    4
      src/CompileStep.cc
  2. 2
    2
      src/LinkStep.cc
  3. 2
    2
      src/build.cc
  4. 1
    1
      src/main.cc
  5. 1
    5
      src/parallel.cc
  6. 20
    0
      src/sys.cc
  7. 4
    0
      src/sys.h

+ 5
- 4
src/CompileStep.cc Просмотреть файл



BBVariables cachedVariables; BBVariables cachedVariables;
try { try {
std::ifstream f(bbPath);
std::ifstream f = sys::ifstream(bbPath);
BBParser parser(f, BBParser::FLAG_NONE); BBParser parser(f, BBParser::FLAG_NONE);
parser.parse(cachedVariables); parser.parse(cachedVariables);
} catch (BBParseError &err) { } catch (BBParseError &err) {
{ "command", command}, { "command", command},
}; };


std::ofstream f(bbPath(outDir));
sys::mkdirp(dirPath);

std::ofstream f = sys::ofstream(bbPath(outDir));
BBWriter writer(f); BBWriter writer(f);
writer.write(newCachedVars); writer.write(newCachedVars);


sys::mkdirp(dirPath);
sys::execute(command, nullptr, global::verbose >= 1); sys::execute(command, nullptr, global::verbose >= 1);
} }


return variables_; return variables_;
} }


std::ifstream f(path_);
std::ifstream f = sys::ifstream(path_);
BBParser parser(f, BBParser::FLAG_ONE_LINE); BBParser parser(f, BBParser::FLAG_ONE_LINE);


while (f.good()) { while (f.good()) {

+ 2
- 2
src/LinkStep.cc Просмотреть файл



BBVariables cachedVariables; BBVariables cachedVariables;
try { try {
std::ifstream f(bbPath);
std::ifstream f = sys::ifstream(bbPath);
BBParser parser(f, BBParser::FLAG_NONE); BBParser parser(f, BBParser::FLAG_NONE);
parser.parse(cachedVariables); parser.parse(cachedVariables);
} catch (BBParseError &err) { } catch (BBParseError &err) {
{ "command", command}, { "command", command},
}; };


std::ofstream f(bbPath(outDir));
std::ofstream f = sys::ofstream(bbPath(outDir));
BBWriter writer(f); BBWriter writer(f);
writer.write(newCachedVars); writer.write(newCachedVars);



+ 2
- 2
src/build.cc Просмотреть файл

subvars = variables; subvars = variables;
varsptr = &subvars; varsptr = &subvars;


std::ifstream stream("build.bb");
std::ifstream stream = sys::ifstream("build.bb");
BBParser parser(stream, BBParser::FLAG_NONE); BBParser parser(stream, BBParser::FLAG_NONE);
parser.parse(subvars); parser.parse(subvars);


std::unique_ptr<DepNode> buildDepTree(const std::string &outDir, BBVariables variables) { std::unique_ptr<DepNode> buildDepTree(const std::string &outDir, BBVariables variables) {
// Read config from file // Read config from file
if (sys::fileExists("build.bb")) { if (sys::fileExists("build.bb")) {
std::ifstream stream("build.bb");
std::ifstream stream = sys::ifstream("build.bb");
BBParser parser(stream, BBParser::FLAG_NONE); BBParser parser(stream, BBParser::FLAG_NONE);
parser.parse(variables); parser.parse(variables);
} }

+ 1
- 1
src/main.cc Просмотреть файл

sys::mkdirp(outDir); sys::mkdirp(outDir);


{ {
std::ofstream f(outDir + "/compile_commands.json");
std::ofstream f = sys::ofstream(outDir + "/compile_commands.json");
compdb::Writer writer(f); compdb::Writer writer(f);
root->writeCompDB(outDir, writer); root->writeCompDB(outDir, writer);
sys::symlink(outDir + "/compile_commands.json", "compile_commands.json"); sys::symlink(outDir + "/compile_commands.json", "compile_commands.json");

+ 1
- 5
src/parallel.cc Просмотреть файл

if (!w->running) if (!w->running)
break; break;


try {
w->func();
} catch (...) {
std::terminate();
}
w->func();


w->func = nullptr; w->func = nullptr;
std::unique_lock<std::mutex> workers_lock(workers_mut); std::unique_lock<std::mutex> workers_lock(workers_mut);

+ 20
- 0
src/sys.cc Просмотреть файл

return std::string(dir); return std::string(dir);
} }


std::ofstream ofstream(const std::string &path) {
std::ofstream f;
f.exceptions(std::ofstream::badbit);
f.open(path);
if (!f.good()) {
throw std::system_error(errno, std::generic_category(), path);
}
return f;
}

std::ifstream ifstream(const std::string &path) {
std::ifstream f;
f.exceptions(std::ifstream::badbit);
f.open(path);
if (!f.good()) {
throw std::system_error(errno, std::generic_category(), path);
}
return f;
}

} }

+ 4
- 0
src/sys.h Просмотреть файл



#include <string> #include <string>
#include <vector> #include <vector>
#include <fstream>


namespace sys { namespace sys {


void symlink(const std::string &from, const std::string &to); void symlink(const std::string &from, const std::string &to);
std::string dirname(const std::string &path); std::string dirname(const std::string &path);


std::ofstream ofstream(const std::string &path);
std::ifstream ifstream(const std::string &path);

} }

Загрузка…
Отмена
Сохранить