diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2020-07-08 15:38:01 -0400 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2020-07-08 15:38:01 -0400 |
commit | af95a7c16b0fc0b033a7191f686fe98b2015162f (patch) | |
tree | 011186734ed386352aa3ae62e550a71a80e3ed3a /src/libstore | |
parent | 7d8d78f06a637ba6b75285d299b07b81279c422f (diff) |
Add name to BasicDerivation
We always have a name for BasicDerivation, since we have a derivation
store path that has a name.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/daemon.cc | 2 | ||||
-rw-r--r-- | src/libstore/derivations.cc | 16 | ||||
-rw-r--r-- | src/libstore/derivations.hh | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index ebc4d0285..4cf67064a 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -474,7 +474,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, case wopBuildDerivation: { auto drvPath = store->parseStorePath(readString(from)); BasicDerivation drv; - readDerivation(from, *store, drv); + readDerivation(from, *store, drv, std::string(drvPath.name())); BuildMode buildMode = (BuildMode) readInt(from); logger->startWork(); if (!trusted) diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 42551ef6b..bdc6f4f68 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -129,9 +129,11 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream } -static Derivation parseDerivation(const Store & store, const string & s) +static Derivation parseDerivation(const Store & store, const string & s, string name) { Derivation drv; + drv.name = name; + istringstream_nocopy str(s); expect(str, "Derive(["); @@ -175,10 +177,10 @@ static Derivation parseDerivation(const Store & store, const string & s) } -Derivation readDerivation(const Store & store, const Path & drvPath) +Derivation readDerivation(const Store & store, const Path & drvPath, std::string name) { try { - return parseDerivation(store, readFile(drvPath)); + return parseDerivation(store, readFile(drvPath), name); } catch (FormatError & e) { throw Error("error parsing derivation '%1%': %2%", drvPath, e.msg()); } @@ -196,7 +198,7 @@ Derivation Store::readDerivation(const StorePath & drvPath) { auto accessor = getFSAccessor(); try { - return parseDerivation(*this, accessor->readFile(printStorePath(drvPath))); + return parseDerivation(*this, accessor->readFile(printStorePath(drvPath)), std::string(drvPath.name())); } catch (FormatError & e) { throw Error("error parsing derivation '%s': %s", printStorePath(drvPath), e.msg()); } @@ -369,7 +371,7 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput if (h == drvHashes.end()) { assert(store.isValidPath(i.first)); h = drvHashes.insert_or_assign(i.first, hashDerivationModulo(store, - store.readDerivation(i.first), false)).first; + store.readDerivation(i.first), false)).first; } inputs2.insert_or_assign(h->second.to_string(Base16, false), i.second); } @@ -435,8 +437,10 @@ StringSet BasicDerivation::outputNames() const } -Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv) +Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, string name) { + drv.name = name; + drv.outputs.clear(); auto nr = readNum<size_t>(in); for (size_t n = 0; n < nr; n++) { diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh index 68c53c1ff..f9d328196 100644 --- a/src/libstore/derivations.hh +++ b/src/libstore/derivations.hh @@ -35,6 +35,7 @@ struct BasicDerivation Path builder; Strings args; StringPairs env; + string name; BasicDerivation() { } virtual ~BasicDerivation() { }; @@ -76,7 +77,7 @@ StorePath writeDerivation(ref<Store> store, const Derivation & drv, std::string_view name, RepairFlag repair = NoRepair); /* Read a derivation from a file. */ -Derivation readDerivation(const Store & store, const Path & drvPath); +Derivation readDerivation(const Store & store, const Path & drvPath, string name); // FIXME: remove bool isDerivation(const string & fileName); @@ -93,7 +94,7 @@ bool wantOutput(const string & output, const std::set<string> & wanted); struct Source; struct Sink; -Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv); +Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, string name); void writeDerivation(Sink & out, const Store & store, const BasicDerivation & drv); std::string hashPlaceholder(const std::string & outputName); |