2021-03-01 05:48:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util.hh"
|
|
|
|
#include "path.hh"
|
2021-03-02 03:50:41 +00:00
|
|
|
#include "path.hh"
|
2021-03-01 05:48:01 +00:00
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class Store;
|
|
|
|
|
|
|
|
struct BuildableOpaque {
|
|
|
|
StorePath path;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-03-01 05:48:01 +00:00
|
|
|
nlohmann::json toJSON(ref<Store> store) const;
|
2021-03-02 03:50:41 +00:00
|
|
|
std::string to_string(const Store & store) const;
|
|
|
|
static BuildableOpaque parse(const Store & store, std::string_view);
|
2021-03-01 05:48:01 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 13:15:25 +00:00
|
|
|
struct BuildableReqFromDrv {
|
2021-03-01 05:48:01 +00:00
|
|
|
StorePath drvPath;
|
2021-04-05 13:15:25 +00:00
|
|
|
std::set<std::string> outputs;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
|
|
|
std::string to_string(const Store & store) const;
|
2021-04-05 13:15:25 +00:00
|
|
|
static BuildableReqFromDrv parse(const Store & store, std::string_view);
|
2021-03-01 05:48:01 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 13:24:42 +00:00
|
|
|
using _BuildableReqRaw = std::variant<
|
2021-03-01 05:48:01 +00:00
|
|
|
BuildableOpaque,
|
2021-04-05 13:15:25 +00:00
|
|
|
BuildableReqFromDrv
|
2021-03-02 03:50:41 +00:00
|
|
|
>;
|
|
|
|
|
2021-04-05 13:24:42 +00:00
|
|
|
struct BuildableReq : _BuildableReqRaw {
|
|
|
|
using Raw = _BuildableReqRaw;
|
|
|
|
using Raw::Raw;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-04-05 13:24:42 +00:00
|
|
|
inline const Raw & raw() const {
|
|
|
|
return static_cast<const Raw &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string to_string(const Store & store) const;
|
|
|
|
static BuildableReq parse(const Store & store, std::string_view);
|
|
|
|
};
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-04-05 13:15:25 +00:00
|
|
|
struct BuildableFromDrv {
|
|
|
|
StorePath drvPath;
|
|
|
|
std::map<std::string, std::optional<StorePath>> outputs;
|
|
|
|
|
|
|
|
nlohmann::json toJSON(ref<Store> store) const;
|
|
|
|
static BuildableFromDrv parse(const Store & store, std::string_view);
|
|
|
|
};
|
|
|
|
|
|
|
|
using Buildable = std::variant<
|
|
|
|
BuildableOpaque,
|
|
|
|
BuildableFromDrv
|
|
|
|
>;
|
2021-03-01 05:48:01 +00:00
|
|
|
|
|
|
|
typedef std::vector<Buildable> Buildables;
|
|
|
|
|
|
|
|
nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store);
|
|
|
|
|
|
|
|
}
|