aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-09-23 12:21:06 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:28:02 +0200
commita64df87aa0cb30d3bbc755fc97eb782388b35b77 (patch)
tree99742e299d3a873a7fc3400c744efcb21a6ef560 /src
parent28ebe56853d4ec2d08dcbd5559d3d62bce3295c6 (diff)
Add build depends
Diffstat (limited to 'src')
-rw-r--r--src/Ninja.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Ninja.cpp b/src/Ninja.cpp
index f74ab04..9b9e177 100644
--- a/src/Ninja.cpp
+++ b/src/Ninja.cpp
@@ -95,9 +95,9 @@ namespace ninja
}
}
- void NinjaRule::build(const std::string &in, const std::string &out, const std::vector<ninja::NinjaArgValue> &additionalArgs)
+ NinjaBuild* NinjaRule::build(const std::string &in, const std::string &out, const std::vector<ninja::NinjaArgValue> &additionalArgs, const std::vector<NinjaBuild*> &dependsOnBuilds)
{
- buildFile->build(this, in, out, additionalArgs);
+ return buildFile->build(this, in, out, additionalArgs, dependsOnBuilds);
}
void NinjaBuildFile::defineGlobalVariable(const std::string &name, const std::string &value)
@@ -125,9 +125,11 @@ namespace ninja
return rule;
}
- void NinjaBuildFile::build(const NinjaRule *rule, const std::string &in, const std::string &out, const std::vector<ninja::NinjaArgValue> &additionalArgs)
+ NinjaBuild* NinjaBuildFile::build(const NinjaRule *rule, const std::string &in, const std::string &out, const std::vector<ninja::NinjaArgValue> &additionalArgs, const std::vector<NinjaBuild*> &dependsOnBuilds)
{
- builds.push_back({ rule, in, out, additionalArgs });
+ NinjaBuild *build = new NinjaBuild { rule, in, out, additionalArgs, dependsOnBuilds };
+ builds.push_back(build);
+ return build;
}
std::string NinjaBuildFile::generate() const
@@ -159,15 +161,25 @@ namespace ninja
}
// TODO: enclose all names with quotes to escape whitespace?
- for(const NinjaBuild &build : builds)
+ for(const NinjaBuild *build : builds)
{
result += "build ";
- result += build.out;
+ result += build->out;
result += ": ";
- result += build.rule->name;
+ result += build->rule->name;
result += ' ';
- result += build.in;
- for(const NinjaArgValue &additionalArg : build.additionalArgs)
+ result += build->in;
+
+ if(!build->dependsOnBuilds.empty())
+ {
+ result += " ||";
+ for(const NinjaBuild *dependsOnBuild : build->dependsOnBuilds)
+ {
+ result += ' ' + dependsOnBuild->out;
+ }
+ }
+
+ for(const NinjaArgValue &additionalArg : build->additionalArgs)
{
result += "\n ";
result += additionalArg.arg.name;