about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-26T14·39+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-11-26T14·39+0100
commit46a369ad9558939bc2c6ee588df483ca503bbb5a (patch)
tree7a3fc4d49d0a5fb29d1c6e139672d91f86e71f47 /src/libutil
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/libutil')
-rw-r--r--src/libutil/util.cc14
-rw-r--r--src/libutil/util.hh1
2 files changed, 14 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index e208701cea8a..1308eac31293 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -997,13 +997,14 @@ template<class C> C tokenizeString(const string & s, const string & separators)
         string::size_type end = s.find_first_of(separators, pos + 1);
         if (end == string::npos) end = s.size();
         string token(s, pos, end - pos);
-        result.push_back(token);
+        result.insert(result.end(), token);
         pos = s.find_first_not_of(separators, end);
     }
     return result;
 }
 
 template Strings tokenizeString(const string & s, const string & separators);
+template StringSet tokenizeString(const string & s, const string & separators);
 template vector<string> tokenizeString(const string & s, const string & separators);
 
 
@@ -1018,6 +1019,17 @@ string concatStringsSep(const string & sep, const Strings & ss)
 }
 
 
+string concatStringsSep(const string & sep, const StringSet & ss)
+{
+    string s;
+    foreach (StringSet::const_iterator, i, ss) {
+        if (s.size() != 0) s += sep;
+        s += *i;
+    }
+    return s;
+}
+
+
 string chomp(const string & s)
 {
     size_t i = s.find_last_not_of(" \n\r\t");
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 87b63f6e998a..746b2dd5859f 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -293,6 +293,7 @@ template<class C> C tokenizeString(const string & s, const string & separators =
 /* Concatenate the given strings with a separator between the
    elements. */
 string concatStringsSep(const string & sep, const Strings & ss);
+string concatStringsSep(const string & sep, const StringSet & ss);
 
 
 /* Remove trailing whitespace from a string. */