| @@ -96,22 +96,42 @@ int main(int argc, char **argv) { | |||
| sys::chdir(workDir); | |||
| } | |||
| // Read in variables from conf if it exists | |||
| BBVariables variables; | |||
| if (sys::fileExists(outDir + "/.config.bb")) { | |||
| std::ifstream f = sys::ifstream(outDir + "/.config.bb"); | |||
| BBParser parser(f, BBParser::FLAG_NONE); | |||
| parser.parse(variables); | |||
| } | |||
| // Read non-option arguments (variable definitions and args) | |||
| bool varsChanged = false; | |||
| std::vector<std::string> args; | |||
| BBVariables vars; | |||
| while (optind < argc) { | |||
| char *arg = argv[optind++]; | |||
| char *eq = strchr(arg, '='); | |||
| if (eq == nullptr) { | |||
| args.push_back(arg); | |||
| } else { | |||
| std::stringstream ss(eq + 1); | |||
| BBParser parser(ss, BBParser::FLAG_NONE); | |||
| parser.parseList(vars, vars[std::string(arg, eq - arg)]); | |||
| varsChanged = true; | |||
| std::stringstream val(eq + 1); | |||
| BBParser parser(val, BBParser::FLAG_NONE); | |||
| std::string key(arg, eq - arg); | |||
| std::vector<std::string> &list = variables[key]; | |||
| list.clear(); | |||
| parser.parseList(variables, list); | |||
| } | |||
| } | |||
| std::unique_ptr<DepNode> root = buildDepTree(outDir, vars); | |||
| // If our variables changed, write out the new ones | |||
| if (varsChanged) { | |||
| std::ofstream f = sys::ofstream(outDir + "/.config.bb"); | |||
| BBWriter w(f); | |||
| w.write(variables); | |||
| } | |||
| // Build dependency graph | |||
| std::unique_ptr<DepNode> root = buildDepTree(outDir, variables); | |||
| if (root == nullptr) { | |||
| logger::log("No source files."); | |||
| return 0; | |||
| @@ -119,6 +139,7 @@ int main(int argc, char **argv) { | |||
| sys::mkdirp(outDir); | |||
| // Build compile commands | |||
| { | |||
| std::ofstream f = sys::ofstream(outDir + "/compile_commands.json"); | |||
| compdb::Writer writer(f); | |||
| @@ -126,6 +147,7 @@ int main(int argc, char **argv) { | |||
| sys::symlink(outDir + "/compile_commands.json", "compile_commands.json"); | |||
| } | |||
| // Build the project | |||
| if (root->hasChanged(outDir)) { | |||
| root->build(outDir); | |||
| } else { | |||