1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 09:00:34 +00:00

rogueviz:: reads hidden dependencies

This commit is contained in:
Zeno Rogue 2022-07-12 11:11:21 +02:00
parent b3728b109f
commit e04a6bc49a
2 changed files with 29 additions and 1 deletions

View File

@ -148,11 +148,32 @@ void set_os(string o) {
} }
vector<string> modules; vector<string> modules;
vector<string> hidden_dependencies;
time_t get_file_time(const string s) { time_t get_file_time(const string s) {
struct stat attr; struct stat attr;
if(stat(s.c_str(), &attr)) return 0; if(stat(s.c_str(), &attr)) return 0;
return attr.st_mtime; time_t res = attr.st_mtime;
for(auto& hd: hidden_dependencies) if(s.substr(0, hd.size()) == hd) {
int pos = 0;
vector<int> slashes = {0};
int numslash = 0;
for(char c: s) { pos++; if(c == '/') slashes.push_back(pos), numslash++; }
ifstream ifs(s);
string s1;
while(getline(ifs, s1)) {
if(s1.substr(0, 10) == "#include \"") {
string t = s1.substr(10);
t = t.substr(0, t.find("\""));
int qdot = 0;
while(t.substr(0, 3) == "../" && qdot < numslash) qdot++, t = t.substr(3);
string u = s.substr(0, slashes[numslash - qdot]) + t;
res = max(res, get_file_time(u));
}
}
}
return res;
} }
int optimized = 0; int optimized = 0;
@ -296,6 +317,10 @@ int main(int argc, char **argv) {
t = t.substr(0, t.find(".cpp\"")); t = t.substr(0, t.find(".cpp\""));
modules.push_back("rogueviz/" + t); modules.push_back("rogueviz/" + t);
} }
if(s.substr(0, 24) == "// hidden dependencies: ") {
while(s.back() == 10 || s.back() == 13) s.pop_back();
hidden_dependencies.push_back(s.substr(24));
}
} }
} }
else { else {

View File

@ -74,5 +74,8 @@
#include "som/voronoi.cpp" #include "som/voronoi.cpp"
#include "som/measures.cpp" #include "som/measures.cpp"
// the following comments are read by mymake so that it knows that the files include other files there:
// hidden dependencies: rogueviz/nilrider/
//#endif //#endif