mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01:00
Separate headers from source files
The short answer for why we need to do this is so we can consistently do `#include "nix/..."`. Without this change, there are ways to still make that work, but they are hacky, and they have downsides such as making it harder to make sure headers from the wrong Nix library (e..g. `libnixexpr` headers in `libnixutil`) aren't being used. The C API alraedy used `nix_api_*`, so its headers are *not* put in subdirectories accordingly. Progress on #7876 We resisted doing this for a while because it would be annoying to not have the header source file pairs close by / easy to change file path/name from one to the other. But I am ameliorating that with symlinks in the next commit.
This commit is contained in:
parent
326548bae5
commit
f3e1c47f47
664 changed files with 2974 additions and 2913 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#include "util.hh"
|
||||
#include "value/context.hh"
|
||||
#include "nix/util.hh"
|
||||
#include "nix/value/context.hh"
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "comparator.hh"
|
||||
#include "derived-path.hh"
|
||||
#include "variant-wrapper.hh"
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class BadNixStringContextElem : public Error
|
||||
{
|
||||
public:
|
||||
std::string_view raw;
|
||||
|
||||
template<typename... Args>
|
||||
BadNixStringContextElem(std::string_view raw_, const Args & ... args)
|
||||
: Error("")
|
||||
{
|
||||
raw = raw_;
|
||||
auto hf = HintFmt(args...);
|
||||
err.msg = HintFmt("Bad String Context element: %1%: %2%", Uncolored(hf.str()), raw);
|
||||
}
|
||||
};
|
||||
|
||||
struct NixStringContextElem {
|
||||
/**
|
||||
* Plain opaque path to some store object.
|
||||
*
|
||||
* Encoded as just the path: `<path>`.
|
||||
*/
|
||||
using Opaque = SingleDerivedPath::Opaque;
|
||||
|
||||
/**
|
||||
* Path to a derivation and its entire build closure.
|
||||
*
|
||||
* The path doesn't just refer to derivation itself and its closure, but
|
||||
* also all outputs of all derivations in that closure (including the
|
||||
* root derivation).
|
||||
*
|
||||
* Encoded in the form `=<drvPath>`.
|
||||
*/
|
||||
struct DrvDeep {
|
||||
StorePath drvPath;
|
||||
|
||||
GENERATE_CMP(DrvDeep, me->drvPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Derivation output.
|
||||
*
|
||||
* Encoded in the form `!<output>!<drvPath>`.
|
||||
*/
|
||||
using Built = SingleDerivedPath::Built;
|
||||
|
||||
using Raw = std::variant<
|
||||
Opaque,
|
||||
DrvDeep,
|
||||
Built
|
||||
>;
|
||||
|
||||
Raw raw;
|
||||
|
||||
GENERATE_CMP(NixStringContextElem, me->raw);
|
||||
|
||||
MAKE_WRAPPER_CONSTRUCTOR(NixStringContextElem);
|
||||
|
||||
/**
|
||||
* Decode a context string, one of:
|
||||
* - `<path>`
|
||||
* - `=<path>`
|
||||
* - `!<name>!<path>`
|
||||
*
|
||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||
*/
|
||||
static NixStringContextElem parse(
|
||||
std::string_view s,
|
||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
typedef std::set<NixStringContextElem> NixStringContext;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue