Преглед изворни кода

actually store flags/deps/etc

feature/dependency-graph
Martin Dørum пре 3 година
родитељ
комит
0cf62471aa
8 измењених фајлова са 87 додато и 7 уклоњено
  1. 45
    0
      src/BBParser.cc
  2. 19
    0
      src/BBParser.h
  3. 4
    2
      src/CompileStep.cc
  4. 1
    1
      src/CompileStep.h
  5. 1
    1
      src/DepNode.cc
  6. 14
    2
      src/LinkStep.cc
  7. 1
    1
      src/LinkStep.h
  8. 2
    0
      src/build.cc

+ 45
- 0
src/BBParser.cc Прегледај датотеку



doAssignment(); doAssignment();
} }

void BBWriter::put(char ch) {
ch_ += 1;
stream_ << ch;
}

void BBWriter::put(const std::string &str) {
ch_ += str.size();
stream_ << str;
}

void BBWriter::newline() {
ch_ = 1;
line_ += 1;
stream_ << '\n';
}

void BBWriter::escape(const std::string &str) {
put('"');
for (char ch: str) {
if (ch == '$' || ch == '"' || ch == '\\') {
put('\\');
}
put(ch);
}
put('"');
}

void BBWriter::write(const BBVariables &vars) {
for (const auto &pair: vars) {
put(pair.first);
put(" :=");
for (auto &val: pair.second) {
if (ch_ >= 80) {
newline();
put('\t');
} else {
put(' ');
}

escape(val);
}
newline();
}
}

+ 19
- 0
src/BBParser.h Прегледај датотеку

EQUALS_PLUS, EQUALS_PLUS,
NONE, NONE,
}; };

[[noreturn]] void error(std::string); [[noreturn]] void error(std::string);


Operator readOperator(); Operator readOperator();
int ch_; int ch_;
std::istream &stream_; std::istream &stream_;
}; };

class BBWriter {
public:
BBWriter(std::ostream &stream, int line = 1, int ch = 1):
line_(line), ch_(ch), stream_(stream) {}

void write(const BBVariables &vars);

private:
void put(char ch);
void put(const std::string &str);
void newline();
void escape(const std::string &str);

int line_;
int ch_;
std::ostream &stream_;
};

+ 4
- 2
src/CompileStep.cc Прегледај датотеку

return true; return true;
} }


std::string bbPath = this->bbPath();
std::string bbPath = this->bbPath(outDir);
if (!sys::fileExists(bbPath)) { if (!sys::fileExists(bbPath)) {
return true; return true;
} }
{ "command", command}, { "command", command},
}; };


// TODO: Write newCachedVars to bbPath()
std::ofstream f(bbPath(outDir));
BBWriter writer(f);
writer.write(newCachedVars);


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

+ 1
- 1
src/CompileStep.h Прегледај датотеку

std::vector<std::string> compileCommand_; std::vector<std::string> compileCommand_;
std::vector<std::string> &compileCommand(const std::string &outDir); std::vector<std::string> &compileCommand(const std::string &outDir);


std::string bbPath() { return path_ + ".bb"; }
std::string bbPath(const std::string &outDir) { return outDir + '/' + path_ + ".bb"; }
}; };

+ 1
- 1
src/DepNode.cc Прегледај датотеку

std::mutex mut; std::mutex mut;
std::condition_variable cond; std::condition_variable cond;


std::unique_lock<std::mutex> lock(mut);
std::unique_lock<std::mutex> lock(mut, std::defer_lock);
while (it != deps_.end()) { while (it != deps_.end()) {
lock.lock(); lock.lock();
if (changed) { if (changed) {

+ 14
- 2
src/LinkStep.cc Прегледај датотеку

return true; return true;
} }


std::string bbPath = this->bbPath();
std::string bbPath = this->bbPath(outDir);
if (!sys::fileExists(bbPath)) { if (!sys::fileExists(bbPath)) {
return true; return true;
} }


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

BBVariables newCachedVars = {
{ "command", command},
};

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

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


std::vector<std::string> &LinkStep::linkCommand(const std::string &outDir) { std::vector<std::string> &LinkStep::linkCommand(const std::string &outDir) {

+ 1
- 1
src/LinkStep.h Прегледај датотеку

std::vector<std::string> linkCommand_; std::vector<std::string> linkCommand_;
std::vector<std::string> &linkCommand(const std::string &outDir); std::vector<std::string> &linkCommand(const std::string &outDir);


std::string bbPath() { return path_ + ".bb"; }
std::string bbPath(const std::string &outDir) { return outDir + '/' + path_ + ".bb"; }
}; };

+ 2
- 0
src/build.cc Прегледај датотеку



#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include <string.h> #include <string.h>


#include "sys.h" #include "sys.h"
sys::readDir(path, subpaths); sys::readDir(path, subpaths);
} }


std::sort(subpaths.begin(), subpaths.end());
for (auto &subpath: subpaths) { for (auto &subpath: subpaths) {
findDeps(path, subpath, *varsptr, deps); findDeps(path, subpath, *varsptr, deps);
} }

Loading…
Откажи
Сачувај