about summary refs log tree commit diff
path: root/src/fix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-20T14·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-20T14·11+0000
commit956801fcc2ac75fd4041f61619451d2935fa2598 (patch)
tree7eed97a30df7dc61bbc065a4921ee143d29f7291 /src/fix.cc
parent624c48260f1b4eec86daa0da5f33d4cbb963a361 (diff)
* Use maps and sets in the FState data type. This ensures normalisation of
  slices and derivations w.r.t. order of paths, slice elements, etc.

Diffstat (limited to 'src/fix.cc')
-rw-r--r--src/fix.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fix.cc b/src/fix.cc
index 83e25d142a19..38c53c6d79a7 100644
--- a/src/fix.cc
+++ b/src/fix.cc
@@ -137,14 +137,16 @@ static Strings fstatePathsCached(EvalState & state, const FSId & id)
 static Hash hashPackage(EvalState & state, FState fs)
 {
     if (fs.type == FState::fsDerive) {
-        for (FSIds::iterator i = fs.derive.inputs.begin();
+	FSIdSet inputs2;
+        for (FSIdSet::iterator i = fs.derive.inputs.begin();
              i != fs.derive.inputs.end(); i++)
         {
             PkgHashes::iterator j = state.pkgHashes.find(*i);
             if (j == state.pkgHashes.end())
                 throw Error(format("unknown package id %1%") % (string) *i);
-            *i = j->second;
+            inputs2.insert(j->second);
         }
+	fs.derive.inputs = inputs2;
     }
     return hashTerm(unparseFState(fs));
 }
@@ -159,7 +161,7 @@ static string processBinding(EvalState & state, Expr e, FState & fs)
         Strings paths = fstatePathsCached(state, id);
         if (paths.size() != 1) abort();
         string path = *(paths.begin());
-        fs.derive.inputs.push_back(id);
+        fs.derive.inputs.insert(id);
         return path;
     }
     
@@ -264,12 +266,11 @@ static Expr evalExpr2(EvalState & state, Expr e)
         addToStore(srcPath, dstPath, id, true);
 
         SliceElem elem;
-        elem.path = dstPath;
         elem.id = id;
         FState fs;
         fs.type = FState::fsSlice;
-        fs.slice.roots.push_back(dstPath);
-        fs.slice.elems.push_back(elem);
+        fs.slice.roots.insert(dstPath);
+        fs.slice.elems[dstPath] = elem;
 
         Hash pkgHash = hashPackage(state, fs);
         FSId pkgId = writeTerm(unparseFState(fs), "");
@@ -324,7 +325,7 @@ static Expr evalExpr2(EvalState & state, Expr e)
 
             else {
                 string s = processBinding(state, value, fs);
-                fs.derive.env.push_back(StringPair(key, s));
+                fs.derive.env[key] = s;
 
                 if (key == "build") fs.derive.builder = s;
                 if (key == "name") name = s;
@@ -349,8 +350,8 @@ static Expr evalExpr2(EvalState & state, Expr e)
         if (!outIdGiven) outId = hashPackage(state, fs);
         string outPath = 
             canonPath(nixStore + "/" + ((string) outId).c_str() + "-" + name);
-        fs.derive.env.push_back(StringPair("out", outPath));
-        fs.derive.outputs.push_back(DeriveOutput(outPath, outId));
+        fs.derive.env["out"] = outPath;
+        fs.derive.outputs[outPath] = outId;
 
         /* Write the resulting term into the Nix store directory. */
         Hash pkgHash = outIdGiven