aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-26 15:39:10 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-26 15:39:10 +0100
commit46a369ad9558939bc2c6ee588df483ca503bbb5a (patch)
tree7a3fc4d49d0a5fb29d1c6e139672d91f86e71f47 /src/libstore/derivations.cc
parenta3d6585c5a1006d4f9ebd2163d06f86ab71a4a3e (diff)
Make "nix-build -A <derivation>.<output>" do the right thing
For example, given a derivation with outputs "out", "man" and "bin": $ nix-build -A pkg produces ./result pointing to the "out" output; $ nix-build -A pkg.man produces ./result-man pointing to the "man" output; $ nix-build -A pkg.all produces ./result, ./result-man and ./result-bin; $ nix-build -A pkg.all -A pkg2 produces ./result, ./result-man, ./result-bin and ./result-2.
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r--src/libstore/derivations.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index e0a4f43c0..1551ae28a 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -252,4 +252,21 @@ Hash hashDerivationModulo(StoreAPI & store, Derivation drv)
}
+DrvPathWithOutputs parseDrvPathWithOutputs(const string & s)
+{
+ size_t n = s.find("!");
+ return n == s.npos
+ ? DrvPathWithOutputs(s, std::set<string>())
+ : DrvPathWithOutputs(string(s, 0, n), tokenizeString<std::set<string> >(string(s, n + 1), ","));
+}
+
+
+Path makeDrvPathWithOutputs(const Path & drvPath, std::set<string> outputs)
+{
+ return outputs.empty()
+ ? drvPath
+ : drvPath + "!" + concatStringsSep(",", outputs);
+}
+
+
}