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-03-02 03:50:41 +00:00
|
|
|
template<typename Outputs>
|
|
|
|
struct BuildableForFromDrv {
|
2021-03-01 05:48:01 +00:00
|
|
|
StorePath drvPath;
|
2021-03-02 03:50:41 +00:00
|
|
|
Outputs outputs;
|
|
|
|
|
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 BuildableForFromDrv<Outputs> parse(const Store & store, std::string_view);
|
2021-03-01 05:48:01 +00:00
|
|
|
};
|
|
|
|
|
2021-03-02 03:50:41 +00:00
|
|
|
template <typename Outputs>
|
|
|
|
using BuildableFor = std::variant<
|
2021-03-01 05:48:01 +00:00
|
|
|
BuildableOpaque,
|
2021-03-02 03:50:41 +00:00
|
|
|
BuildableForFromDrv<Outputs>
|
|
|
|
>;
|
|
|
|
|
|
|
|
typedef BuildableForFromDrv<std::set<std::string>> BuildableReqFromDrv;
|
|
|
|
typedef BuildableFor<std::set<std::string>> BuildableReq;
|
|
|
|
|
|
|
|
std::string to_string(const Store & store, const BuildableReq &);
|
|
|
|
|
|
|
|
BuildableReq parseBuildableReq(const Store & store, std::string_view);
|
|
|
|
|
|
|
|
typedef BuildableForFromDrv<std::map<std::string, std::optional<StorePath>>> BuildableFromDrv;
|
|
|
|
typedef BuildableFor<std::map<std::string, std::optional<StorePath>>> Buildable;
|
2021-03-01 05:48:01 +00:00
|
|
|
|
|
|
|
typedef std::vector<Buildable> Buildables;
|
|
|
|
|
|
|
|
nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store);
|
|
|
|
|
|
|
|
}
|