mirror of
https://github.com/NixOS/nix
synced 2025-06-27 21:01:16 +02:00
Cleanup config headers
There are two big changes: 1. Public and private config is now separated. Configuration variables that are only used internally do not go in a header which is installed. (Additionally, libutil has a unix-specific private config header, which should only be used in unix-specific code. This keeps things a bit more organized, in a purely private implementation-internal way.) 2. Secondly, there is no more `-include`. There are very few config items that need to be publically exposed, so now it is feasible to just make the headers that need them just including the (public) configuration header. And there are also a few more small cleanups on top of those: - The configuration files have better names. - The few CPP variables that remain exposed in the public headers are now also renamed to always start with `NIX_`. This ensures they should not conflict with variables defined elsewhere. - We now always use `#if` and not `#ifdef`/`#ifndef` for our configuration variables, which helps avoid bugs by requiring that variables must be defined in all cases.
This commit is contained in:
parent
5a8dedc45c
commit
c204e307ac
59 changed files with 333 additions and 385 deletions
|
@ -44,27 +44,18 @@ if readline_flavor == 'editline'
|
||||||
elif readline_flavor == 'readline'
|
elif readline_flavor == 'readline'
|
||||||
readline = dependency('readline')
|
readline = dependency('readline')
|
||||||
deps_private += readline
|
deps_private += readline
|
||||||
configdata.set(
|
|
||||||
'USE_READLINE',
|
|
||||||
1,
|
|
||||||
description: 'Use readline instead of editline',
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
error('illegal editline flavor', readline_flavor)
|
error('illegal editline flavor', readline_flavor)
|
||||||
endif
|
endif
|
||||||
|
configdata.set(
|
||||||
config_h = configure_file(
|
'USE_READLINE',
|
||||||
configuration : configdata,
|
(readline_flavor == 'readline').to_int(),
|
||||||
output : 'cmd-config-private.hh',
|
description: 'Use readline instead of editline',
|
||||||
)
|
)
|
||||||
|
|
||||||
add_project_arguments(
|
config_priv_h = configure_file(
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configuration : configdata,
|
||||||
# It would be nice for our headers to be idempotent instead.
|
output : 'cmd-config-private.hh',
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -96,7 +87,7 @@ subdir('nix-meson-build-support/windows-version')
|
||||||
this_library = library(
|
this_library = library(
|
||||||
'nixcmd',
|
'nixcmd',
|
||||||
sources,
|
sources,
|
||||||
config_h,
|
config_priv_h,
|
||||||
dependencies : deps_public + deps_private + deps_other,
|
dependencies : deps_public + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
link_args: linker_export_flags,
|
link_args: linker_export_flags,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#ifdef USE_READLINE
|
#if USE_READLINE
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#else
|
#else
|
||||||
|
@ -37,7 +37,7 @@ void sigintHandler(int signo)
|
||||||
|
|
||||||
static detail::ReplCompleterMixin * curRepl; // ugly
|
static detail::ReplCompleterMixin * curRepl; // ugly
|
||||||
|
|
||||||
#ifndef USE_READLINE
|
#if !USE_READLINE
|
||||||
static char * completionCallback(char * s, int * match)
|
static char * completionCallback(char * s, int * match)
|
||||||
{
|
{
|
||||||
auto possible = curRepl->completePrefix(s);
|
auto possible = curRepl->completePrefix(s);
|
||||||
|
@ -115,14 +115,14 @@ ReadlineLikeInteracter::Guard ReadlineLikeInteracter::init(detail::ReplCompleter
|
||||||
} catch (SystemError & e) {
|
} catch (SystemError & e) {
|
||||||
logWarning(e.info());
|
logWarning(e.info());
|
||||||
}
|
}
|
||||||
#ifndef USE_READLINE
|
#if !USE_READLINE
|
||||||
el_hist_size = 1000;
|
el_hist_size = 1000;
|
||||||
#endif
|
#endif
|
||||||
read_history(historyFile.c_str());
|
read_history(historyFile.c_str());
|
||||||
auto oldRepl = curRepl;
|
auto oldRepl = curRepl;
|
||||||
curRepl = repl;
|
curRepl = repl;
|
||||||
Guard restoreRepl([oldRepl] { curRepl = oldRepl; });
|
Guard restoreRepl([oldRepl] { curRepl = oldRepl; });
|
||||||
#ifndef USE_READLINE
|
#if !USE_READLINE
|
||||||
rl_set_complete_func(completionCallback);
|
rl_set_complete_func(completionCallback);
|
||||||
rl_set_list_possib_func(listPossibleCallback);
|
rl_set_list_possib_func(listPossibleCallback);
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,7 +185,7 @@ bool ReadlineLikeInteracter::getLine(std::string & input, ReplPromptType promptT
|
||||||
// quite useful for reading the test output, so we add it here.
|
// quite useful for reading the test output, so we add it here.
|
||||||
if (auto e = getEnv("_NIX_TEST_REPL_ECHO"); s && e && *e == "1")
|
if (auto e = getEnv("_NIX_TEST_REPL_ECHO"); s && e && *e == "1")
|
||||||
{
|
{
|
||||||
#ifndef USE_READLINE
|
#if !USE_READLINE
|
||||||
// This is probably not right for multi-line input, but we don't use that
|
// This is probably not right for multi-line input, but we don't use that
|
||||||
// in the characterisation tests, so it's fine.
|
// in the characterisation tests, so it's fine.
|
||||||
std::cout << promptForType(promptType) << s << std::endl;
|
std::cout << promptForType(promptType) << s << std::endl;
|
||||||
|
|
|
@ -25,18 +25,6 @@ deps_public_maybe_subproject = [
|
||||||
]
|
]
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
|
|
||||||
# From C++ libraries, only for internals
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "nix_api_util.h"
|
#include "nix_api_util.h"
|
||||||
#include "nix_api_util_internal.h"
|
#include "nix_api_util_internal.h"
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
# include <mutex>
|
# include <mutex>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ void nix_state_free(EvalState * state)
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
const void *,
|
const void *,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
|
@ -285,7 +285,7 @@ nix_err nix_value_decref(nix_c_context * context, nix_value *x)
|
||||||
|
|
||||||
void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd))
|
void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd))
|
||||||
{
|
{
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
GC_REGISTER_FINALIZER(obj, finalizer, cd, 0, 0);
|
GC_REGISTER_FINALIZER(obj, finalizer, cd, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ ExternalValue * nix_create_external_value(nix_c_context * context, NixCExternalV
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto ret = new
|
auto ret = new
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
(GC)
|
(GC)
|
||||||
#endif
|
#endif
|
||||||
NixCExternalValue(*desc, v);
|
NixCExternalValue(*desc, v);
|
||||||
|
|
|
@ -125,7 +125,7 @@ PrimOp * nix_alloc_primop(
|
||||||
try {
|
try {
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
auto p = new
|
auto p = new
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
(GC)
|
(GC)
|
||||||
#endif
|
#endif
|
||||||
nix::PrimOp{
|
nix::PrimOp{
|
||||||
|
@ -497,7 +497,7 @@ ListBuilder * nix_make_list_builder(nix_c_context * context, EvalState * state,
|
||||||
try {
|
try {
|
||||||
auto builder = state->state.buildList(capacity);
|
auto builder = state->state.buildList(capacity);
|
||||||
return new
|
return new
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
(NoGC)
|
(NoGC)
|
||||||
#endif
|
#endif
|
||||||
ListBuilder{std::move(builder)};
|
ListBuilder{std::move(builder)};
|
||||||
|
@ -519,7 +519,7 @@ nix_list_builder_insert(nix_c_context * context, ListBuilder * list_builder, uns
|
||||||
|
|
||||||
void nix_list_builder_free(ListBuilder * list_builder)
|
void nix_list_builder_free(ListBuilder * list_builder)
|
||||||
{
|
{
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
GC_FREE(list_builder);
|
GC_FREE(list_builder);
|
||||||
#else
|
#else
|
||||||
delete list_builder;
|
delete list_builder;
|
||||||
|
@ -578,7 +578,7 @@ BindingsBuilder * nix_make_bindings_builder(nix_c_context * context, EvalState *
|
||||||
try {
|
try {
|
||||||
auto bb = state->state.buildBindings(capacity);
|
auto bb = state->state.buildBindings(capacity);
|
||||||
return new
|
return new
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
(NoGC)
|
(NoGC)
|
||||||
#endif
|
#endif
|
||||||
BindingsBuilder{std::move(bb)};
|
BindingsBuilder{std::move(bb)};
|
||||||
|
@ -600,7 +600,7 @@ nix_err nix_bindings_builder_insert(nix_c_context * context, BindingsBuilder * b
|
||||||
|
|
||||||
void nix_bindings_builder_free(BindingsBuilder * bb)
|
void nix_bindings_builder_free(BindingsBuilder * bb)
|
||||||
{
|
{
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
GC_FREE((nix::BindingsBuilder *) bb);
|
GC_FREE((nix::BindingsBuilder *) bb);
|
||||||
#else
|
#else
|
||||||
delete (nix::BindingsBuilder *) bb;
|
delete (nix::BindingsBuilder *) bb;
|
||||||
|
|
|
@ -29,15 +29,6 @@ subdir('nix-meson-build-support/subprojects')
|
||||||
rapidcheck = dependency('rapidcheck')
|
rapidcheck = dependency('rapidcheck')
|
||||||
deps_public += rapidcheck
|
deps_public += rapidcheck
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -35,13 +35,12 @@ deps_private += gtest
|
||||||
gtest = dependency('gmock')
|
gtest = dependency('gmock')
|
||||||
deps_private += gtest
|
deps_private += gtest
|
||||||
|
|
||||||
add_project_arguments(
|
configdata = configuration_data()
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
config_priv_h = configure_file(
|
||||||
'-include', 'nix/config-store.hh',
|
configuration : configdata,
|
||||||
'-include', 'nix/config-expr.hh',
|
output : 'expr-tests-config.hh',
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -69,6 +68,7 @@ include_dirs = [include_directories('.')]
|
||||||
this_exe = executable(
|
this_exe = executable(
|
||||||
meson.project_name(),
|
meson.project_name(),
|
||||||
sources,
|
sources,
|
||||||
|
config_priv_h,
|
||||||
dependencies : deps_private_subproject + deps_private + deps_other,
|
dependencies : deps_private_subproject + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "expr-tests-config.hh"
|
||||||
|
|
||||||
namespace nixC {
|
namespace nixC {
|
||||||
|
|
||||||
TEST_F(nix_api_store_test, nix_eval_state_lookup_path)
|
TEST_F(nix_api_store_test, nix_eval_state_lookup_path)
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
#include "nix/serialise.hh"
|
#include "nix/serialise.hh"
|
||||||
#include "nix/eval-gc.hh"
|
#include "nix/eval-gc.hh"
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#include "expr-config-private.hh"
|
||||||
|
|
||||||
|
#if NIX_USE_BOEHMGC
|
||||||
|
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# if __FreeBSD__
|
# if __FreeBSD__
|
||||||
|
@ -24,7 +26,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
/* Called when the Boehm GC runs out of memory. */
|
/* Called when the Boehm GC runs out of memory. */
|
||||||
static void * oomHandler(size_t requested)
|
static void * oomHandler(size_t requested)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +96,7 @@ void initGC()
|
||||||
if (gcInitialised)
|
if (gcInitialised)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
initGCReal();
|
initGCReal();
|
||||||
|
|
||||||
gcCyclesAfterInit = GC_get_gc_no();
|
gcCyclesAfterInit = GC_get_gc_no();
|
||||||
|
|
|
@ -295,7 +295,7 @@ EvalState::EvalState(
|
||||||
, debugStop(false)
|
, debugStop(false)
|
||||||
, trylevel(0)
|
, trylevel(0)
|
||||||
, regexCache(makeRegexCache())
|
, regexCache(makeRegexCache())
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
, valueAllocCache(std::allocate_shared<void *>(traceable_allocator<void *>(), nullptr))
|
, valueAllocCache(std::allocate_shared<void *>(traceable_allocator<void *>(), nullptr))
|
||||||
, env1AllocCache(std::allocate_shared<void *>(traceable_allocator<void *>(), nullptr))
|
, env1AllocCache(std::allocate_shared<void *>(traceable_allocator<void *>(), nullptr))
|
||||||
, baseEnvP(std::allocate_shared<Env *>(traceable_allocator<Env *>(), &allocEnv(BASE_ENV_SIZE)))
|
, baseEnvP(std::allocate_shared<Env *>(traceable_allocator<Env *>(), &allocEnv(BASE_ENV_SIZE)))
|
||||||
|
@ -2812,7 +2812,7 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EvalState::fullGC() {
|
bool EvalState::fullGC() {
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
GC_gcollect();
|
GC_gcollect();
|
||||||
// Check that it ran. We might replace this with a version that uses more
|
// Check that it ran. We might replace this with a version that uses more
|
||||||
// of the boehm API to get this reliably, at a maintenance cost.
|
// of the boehm API to get this reliably, at a maintenance cost.
|
||||||
|
@ -2831,7 +2831,7 @@ void EvalState::maybePrintStats()
|
||||||
|
|
||||||
if (showStats) {
|
if (showStats) {
|
||||||
// Make the final heap size more deterministic.
|
// Make the final heap size more deterministic.
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
if (!fullGC()) {
|
if (!fullGC()) {
|
||||||
warn("failed to perform a full GC before reporting stats");
|
warn("failed to perform a full GC before reporting stats");
|
||||||
}
|
}
|
||||||
|
@ -2853,7 +2853,7 @@ void EvalState::printStatistics()
|
||||||
uint64_t bValues = nrValues * sizeof(Value);
|
uint64_t bValues = nrValues * sizeof(Value);
|
||||||
uint64_t bAttrsets = nrAttrsets * sizeof(Bindings) + nrAttrsInAttrsets * sizeof(Attr);
|
uint64_t bAttrsets = nrAttrsets * sizeof(Bindings) + nrAttrsInAttrsets * sizeof(Attr);
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
GC_word heapSize, totalBytes;
|
GC_word heapSize, totalBytes;
|
||||||
GC_get_heap_usage_safe(&heapSize, 0, 0, 0, &totalBytes);
|
GC_get_heap_usage_safe(&heapSize, 0, 0, 0, &totalBytes);
|
||||||
double gcFullOnlyTime = ({
|
double gcFullOnlyTime = ({
|
||||||
|
@ -2875,7 +2875,7 @@ void EvalState::printStatistics()
|
||||||
#ifndef _WIN32 // TODO implement
|
#ifndef _WIN32 // TODO implement
|
||||||
{"cpu", cpuTime},
|
{"cpu", cpuTime},
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
{GC_is_incremental_mode() ? "gcNonIncremental" : "gc", gcFullOnlyTime},
|
{GC_is_incremental_mode() ? "gcNonIncremental" : "gc", gcFullOnlyTime},
|
||||||
#ifndef _WIN32 // TODO implement
|
#ifndef _WIN32 // TODO implement
|
||||||
{GC_is_incremental_mode() ? "gcNonIncrementalFraction" : "gcFraction", gcFullOnlyTime / cpuTime},
|
{GC_is_incremental_mode() ? "gcNonIncrementalFraction" : "gcFraction", gcFullOnlyTime / cpuTime},
|
||||||
|
@ -2919,7 +2919,7 @@ void EvalState::printStatistics()
|
||||||
topObj["nrLookups"] = nrLookups;
|
topObj["nrLookups"] = nrLookups;
|
||||||
topObj["nrPrimOpCalls"] = nrPrimOpCalls;
|
topObj["nrPrimOpCalls"] = nrPrimOpCalls;
|
||||||
topObj["nrFunctionCalls"] = nrFunctionCalls;
|
topObj["nrFunctionCalls"] = nrFunctionCalls;
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
topObj["gc"] = {
|
topObj["gc"] = {
|
||||||
{"heapSize", heapSize},
|
{"heapSize", heapSize},
|
||||||
{"totalBytes", totalBytes},
|
{"totalBytes", totalBytes},
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
// For `NIX_USE_BOEHMGC`, and if that's set, `GC_THREADS`
|
||||||
|
#include "nix/expr-config.hh"
|
||||||
|
|
||||||
|
#if NIX_USE_BOEHMGC
|
||||||
|
|
||||||
# define GC_INCLUDE_NEW
|
# define GC_INCLUDE_NEW
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ void initGC();
|
||||||
*/
|
*/
|
||||||
void assertGCInitialized();
|
void assertGCInitialized();
|
||||||
|
|
||||||
#ifdef HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
/**
|
/**
|
||||||
* The number of GC cycles since initGC().
|
* The number of GC cycles since initGC().
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include "nix/eval-error.hh"
|
#include "nix/eval-error.hh"
|
||||||
#include "nix/eval-settings.hh"
|
#include "nix/eval-settings.hh"
|
||||||
|
|
||||||
|
// For `NIX_USE_BOEHMGC`, and if that's set, `GC_THREADS`
|
||||||
|
#include "nix/expr-config.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +18,7 @@ namespace nix {
|
||||||
inline void * allocBytes(size_t n)
|
inline void * allocBytes(size_t n)
|
||||||
{
|
{
|
||||||
void * p;
|
void * p;
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
p = GC_MALLOC(n);
|
p = GC_MALLOC(n);
|
||||||
#else
|
#else
|
||||||
p = calloc(n, 1);
|
p = calloc(n, 1);
|
||||||
|
@ -28,7 +31,7 @@ inline void * allocBytes(size_t n)
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
Value * EvalState::allocValue()
|
Value * EvalState::allocValue()
|
||||||
{
|
{
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
/* We use the boehm batch allocator to speed up allocations of Values (of which there are many).
|
/* We use the boehm batch allocator to speed up allocations of Values (of which there are many).
|
||||||
GC_malloc_many returns a linked list of objects of the given size, where the first word
|
GC_malloc_many returns a linked list of objects of the given size, where the first word
|
||||||
of each object is also the pointer to the next object in the list. This also means that we
|
of each object is also the pointer to the next object in the list. This also means that we
|
||||||
|
@ -60,7 +63,7 @@ Env & EvalState::allocEnv(size_t size)
|
||||||
|
|
||||||
Env * env;
|
Env * env;
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
/* see allocValue for explanations. */
|
/* see allocValue for explanations. */
|
||||||
if (!*env1AllocCache) {
|
if (!*env1AllocCache) {
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
#include "nix/repl-exit-status.hh"
|
#include "nix/repl-exit-status.hh"
|
||||||
#include "nix/ref.hh"
|
#include "nix/ref.hh"
|
||||||
|
|
||||||
|
// For `NIX_USE_BOEHMGC`, and if that's set, `GC_THREADS`
|
||||||
|
#include "nix/expr-config.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -369,7 +372,7 @@ private:
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<RegexCache> regexCache;
|
std::shared_ptr<RegexCache> regexCache;
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
/**
|
/**
|
||||||
* Allocation cache for GC'd Value objects.
|
* Allocation cache for GC'd Value objects.
|
||||||
*/
|
*/
|
||||||
|
@ -596,7 +599,7 @@ public:
|
||||||
*/
|
*/
|
||||||
SingleDerivedPath coerceToSingleDerivedPath(const PosIdx pos, Value & v, std::string_view errorCtx);
|
SingleDerivedPath coerceToSingleDerivedPath(const PosIdx pos, Value & v, std::string_view errorCtx);
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
/** A GC root for the baseEnv reference. */
|
/** A GC root for the baseEnv reference. */
|
||||||
std::shared_ptr<Env *> baseEnvP;
|
std::shared_ptr<Env *> baseEnvP;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
include_dirs = [include_directories('..')]
|
include_dirs = [include_directories('..')]
|
||||||
|
|
||||||
config_h = configure_file(
|
config_pub_h = configure_file(
|
||||||
configuration : configdata,
|
configuration : configdata_pub,
|
||||||
output : 'config-expr.hh',
|
output : 'expr-config.hh',
|
||||||
)
|
)
|
||||||
|
|
||||||
headers = [config_h] + files(
|
headers = [config_pub_h] + files(
|
||||||
'attr-path.hh',
|
'attr-path.hh',
|
||||||
'attr-set.hh',
|
'attr-set.hh',
|
||||||
'eval-cache.hh',
|
'eval-cache.hh',
|
||||||
|
|
|
@ -14,7 +14,8 @@ cxx = meson.get_compiler('cpp')
|
||||||
|
|
||||||
subdir('nix-meson-build-support/deps-lists')
|
subdir('nix-meson-build-support/deps-lists')
|
||||||
|
|
||||||
configdata = configuration_data()
|
configdata_pub = configuration_data()
|
||||||
|
configdata_priv = configuration_data()
|
||||||
|
|
||||||
deps_private_maybe_subproject = [
|
deps_private_maybe_subproject = [
|
||||||
]
|
]
|
||||||
|
@ -26,6 +27,16 @@ deps_public_maybe_subproject = [
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
subdir('nix-meson-build-support/big-objs')
|
subdir('nix-meson-build-support/big-objs')
|
||||||
|
|
||||||
|
# Check for each of these functions, and create a define like `#define HAVE_LCHOWN 1`.
|
||||||
|
check_funcs = [
|
||||||
|
'sysconf',
|
||||||
|
]
|
||||||
|
foreach funcspec : check_funcs
|
||||||
|
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
||||||
|
define_value = cxx.has_function(funcspec).to_int()
|
||||||
|
configdata_priv.set(define_name, define_value)
|
||||||
|
endforeach
|
||||||
|
|
||||||
boost = dependency(
|
boost = dependency(
|
||||||
'boost',
|
'boost',
|
||||||
modules : ['container', 'context'],
|
modules : ['container', 'context'],
|
||||||
|
@ -47,11 +58,13 @@ if bdw_gc.found()
|
||||||
]
|
]
|
||||||
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
||||||
define_value = cxx.has_function(funcspec).to_int()
|
define_value = cxx.has_function(funcspec).to_int()
|
||||||
configdata.set(define_name, define_value)
|
configdata_priv.set(define_name, define_value)
|
||||||
endforeach
|
endforeach
|
||||||
configdata.set('GC_THREADS', 1)
|
# Affects ABI, because it changes what bdw_gc itself does!
|
||||||
|
configdata_pub.set('GC_THREADS', 1)
|
||||||
endif
|
endif
|
||||||
configdata.set('HAVE_BOEHMGC', bdw_gc.found().to_int())
|
# Used in public header. Affects ABI!
|
||||||
|
configdata_pub.set('NIX_USE_BOEHMGC', bdw_gc.found().to_int())
|
||||||
|
|
||||||
toml11 = dependency(
|
toml11 = dependency(
|
||||||
'toml11',
|
'toml11',
|
||||||
|
@ -61,14 +74,9 @@ toml11 = dependency(
|
||||||
)
|
)
|
||||||
deps_other += toml11
|
deps_other += toml11
|
||||||
|
|
||||||
add_project_arguments(
|
config_priv_h = configure_file(
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configuration : configdata_priv,
|
||||||
# It would be nice for our headers to be idempotent instead.
|
output : 'expr-config-private.hh',
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
# '-include', 'nix_api_fetchers_config.h',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -158,6 +166,7 @@ subdir('nix-meson-build-support/windows-version')
|
||||||
this_library = library(
|
this_library = library(
|
||||||
'nixexpr',
|
'nixexpr',
|
||||||
sources,
|
sources,
|
||||||
|
config_priv_h,
|
||||||
parser_tab,
|
parser_tab,
|
||||||
lexer_tab,
|
lexer_tab,
|
||||||
generated_headers,
|
generated_headers,
|
||||||
|
|
|
@ -34,15 +34,6 @@ deps_private += gtest
|
||||||
libgit2 = dependency('libgit2')
|
libgit2 = dependency('libgit2')
|
||||||
deps_private += libgit2
|
deps_private += libgit2
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
# '-include', 'nix_api_fetchers_config.h',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -30,15 +30,6 @@ deps_public += nlohmann_json
|
||||||
libgit2 = dependency('libgit2')
|
libgit2 = dependency('libgit2')
|
||||||
deps_private += libgit2
|
deps_private += libgit2
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
# '-include', 'nix_api_fetchers_config.h',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -27,20 +27,6 @@ deps_public_maybe_subproject = [
|
||||||
]
|
]
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
|
|
||||||
# From C++ libraries, only for internals
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
# not generated (yet?)
|
|
||||||
# '-include', 'nix/config-flake.hh',
|
|
||||||
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -32,15 +32,6 @@ deps_private += rapidcheck
|
||||||
gtest = dependency('gtest', main : true)
|
gtest = dependency('gtest', main : true)
|
||||||
deps_private += gtest
|
deps_private += gtest
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -27,16 +27,6 @@ subdir('nix-meson-build-support/subprojects')
|
||||||
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
|
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
|
||||||
deps_public += nlohmann_json
|
deps_public += nlohmann_json
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
# '-include', 'nix_api_fetchers_config.h',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
subdir('nix-meson-build-support/generate-header')
|
subdir('nix-meson-build-support/generate-header')
|
||||||
|
|
|
@ -25,17 +25,6 @@ deps_public_maybe_subproject = [
|
||||||
]
|
]
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
|
|
||||||
# From C++ libraries, only for internals
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
include_dirs = [include_directories('..')]
|
include_dirs = [include_directories('..')]
|
||||||
|
|
||||||
config_h = configure_file(
|
headers = files(
|
||||||
configuration : configdata,
|
|
||||||
output : 'config-main.hh',
|
|
||||||
)
|
|
||||||
|
|
||||||
headers = [config_h] + files(
|
|
||||||
'common-args.hh',
|
'common-args.hh',
|
||||||
'loggers.hh',
|
'loggers.hh',
|
||||||
'plugin.hh',
|
'plugin.hh',
|
||||||
|
|
|
@ -42,13 +42,9 @@ configdata.set(
|
||||||
description: 'Optionally used for buffering on standard error'
|
description: 'Optionally used for buffering on standard error'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_project_arguments(
|
config_priv_h = configure_file(
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configuration : configdata,
|
||||||
# It would be nice for our headers to be idempotent instead.
|
output : 'main-config-private.hh',
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-main.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -75,7 +71,7 @@ subdir('nix-meson-build-support/windows-version')
|
||||||
this_library = library(
|
this_library = library(
|
||||||
'nixmain',
|
'nixmain',
|
||||||
sources,
|
sources,
|
||||||
config_h,
|
config_priv_h,
|
||||||
dependencies : deps_public + deps_private + deps_other,
|
dependencies : deps_public + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
link_args: linker_export_flags,
|
link_args: linker_export_flags,
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "nix/exit.hh"
|
#include "nix/exit.hh"
|
||||||
#include "nix/strings.hh"
|
#include "nix/strings.hh"
|
||||||
|
|
||||||
|
#include "main-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
char * * savedArgv;
|
char * * savedArgv;
|
||||||
|
@ -297,7 +299,7 @@ void printVersion(const std::string & programName)
|
||||||
std::cout << fmt("%1% (Nix) %2%", programName, nixVersion) << std::endl;
|
std::cout << fmt("%1% (Nix) %2%", programName, nixVersion) << std::endl;
|
||||||
if (verbosity > lvlInfo) {
|
if (verbosity > lvlInfo) {
|
||||||
Strings cfg;
|
Strings cfg;
|
||||||
#if HAVE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
cfg.push_back("gc");
|
cfg.push_back("gc");
|
||||||
#endif
|
#endif
|
||||||
cfg.push_back("signed-caches");
|
cfg.push_back("signed-caches");
|
||||||
|
|
|
@ -23,17 +23,6 @@ deps_public_maybe_subproject = [
|
||||||
]
|
]
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
|
|
||||||
# From C++ libraries, only for internals
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -27,14 +27,6 @@ subdir('nix-meson-build-support/subprojects')
|
||||||
rapidcheck = dependency('rapidcheck')
|
rapidcheck = dependency('rapidcheck')
|
||||||
deps_public += rapidcheck
|
deps_public += rapidcheck
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -37,17 +37,17 @@ deps_private += rapidcheck
|
||||||
gtest = dependency('gtest', main : true)
|
gtest = dependency('gtest', main : true)
|
||||||
deps_private += gtest
|
deps_private += gtest
|
||||||
|
|
||||||
|
configdata = configuration_data()
|
||||||
|
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
|
||||||
|
config_priv_h = configure_file(
|
||||||
|
configuration : configdata,
|
||||||
|
output : 'store-tests-config.hh',
|
||||||
|
)
|
||||||
|
|
||||||
gtest = dependency('gmock')
|
gtest = dependency('gmock')
|
||||||
deps_private += gtest
|
deps_private += gtest
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
@ -84,6 +84,7 @@ include_dirs = [include_directories('.')]
|
||||||
this_exe = executable(
|
this_exe = executable(
|
||||||
meson.project_name(),
|
meson.project_name(),
|
||||||
sources,
|
sources,
|
||||||
|
config_priv_h,
|
||||||
dependencies : deps_private_subproject + deps_private + deps_other,
|
dependencies : deps_private_subproject + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "nix/tests/nix_api_store.hh"
|
#include "nix/tests/nix_api_store.hh"
|
||||||
#include "nix/tests/string_callback.hh"
|
#include "nix/tests/string_callback.hh"
|
||||||
|
|
||||||
|
#include "store-tests-config.hh"
|
||||||
|
|
||||||
namespace nixC {
|
namespace nixC {
|
||||||
|
|
||||||
std::string PATH_SUFFIX = "/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-name";
|
std::string PATH_SUFFIX = "/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-name";
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "nix/signals.hh"
|
#include "nix/signals.hh"
|
||||||
#include "nix/posix-fs-canonicalise.hh"
|
#include "nix/posix-fs-canonicalise.hh"
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
#if !defined(__linux__)
|
#if !defined(__linux__)
|
||||||
// For shelling out to lsof
|
// For shelling out to lsof
|
||||||
# include "nix/processes.hh"
|
# include "nix/processes.hh"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "nix/abstract-setting-to-json.hh"
|
#include "nix/abstract-setting-to-json.hh"
|
||||||
#include "nix/compute-levels.hh"
|
#include "nix/compute-levels.hh"
|
||||||
#include "nix/signals.hh"
|
#include "nix/signals.hh"
|
||||||
|
#include "nix/strings.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -35,7 +36,8 @@
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "nix/strings.hh"
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -202,7 +204,7 @@ StringSet Settings::getDefaultExtraPlatforms()
|
||||||
{
|
{
|
||||||
StringSet extraPlatforms;
|
StringSet extraPlatforms;
|
||||||
|
|
||||||
if (std::string{SYSTEM} == "x86_64-linux" && !isWSL1())
|
if (std::string{NIX_LOCAL_SYSTEM} == "x86_64-linux" && !isWSL1())
|
||||||
extraPlatforms.insert("i686-linux");
|
extraPlatforms.insert("i686-linux");
|
||||||
|
|
||||||
#if __linux__
|
#if __linux__
|
||||||
|
@ -214,7 +216,7 @@ StringSet Settings::getDefaultExtraPlatforms()
|
||||||
// machines. Note that we can’t force processes from executing
|
// machines. Note that we can’t force processes from executing
|
||||||
// x86_64 in aarch64 environments or vice versa since they can
|
// x86_64 in aarch64 environments or vice versa since they can
|
||||||
// always exec with their own binary preferences.
|
// always exec with their own binary preferences.
|
||||||
if (std::string{SYSTEM} == "aarch64-darwin" &&
|
if (std::string{NIX_LOCAL_SYSTEM} == "aarch64-darwin" &&
|
||||||
runProgram(RunOptions {.program = "arch", .args = {"-arch", "x86_64", "/usr/bin/true"}, .mergeStderrToStdout = true}).first == 0)
|
runProgram(RunOptions {.program = "arch", .args = {"-arch", "x86_64", "/usr/bin/true"}, .mergeStderrToStdout = true}).first == 0)
|
||||||
extraPlatforms.insert("x86_64-darwin");
|
extraPlatforms.insert("x86_64-darwin");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "nix/types.hh"
|
#include "nix/types.hh"
|
||||||
#include "nix/config.hh"
|
#include "nix/config.hh"
|
||||||
#include "nix/environment-variables.hh"
|
#include "nix/environment-variables.hh"
|
||||||
#include "nix/experimental-features.hh"
|
#include "nix/experimental-features.hh"
|
||||||
#include "nix/users.hh"
|
#include "nix/users.hh"
|
||||||
|
|
||||||
#include <map>
|
#include "nix/store-config.hh"
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -181,7 +183,7 @@ public:
|
||||||
bool readOnlyMode = false;
|
bool readOnlyMode = false;
|
||||||
|
|
||||||
Setting<std::string> thisSystem{
|
Setting<std::string> thisSystem{
|
||||||
this, SYSTEM, "system",
|
this, NIX_LOCAL_SYSTEM, "system",
|
||||||
R"(
|
R"(
|
||||||
The system type of the current Nix installation.
|
The system type of the current Nix installation.
|
||||||
Nix will only build a given [store derivation](@docroot@/glossary.md#gloss-store-derivation) locally when its `system` attribute equals any of the values specified here or in [`extra-platforms`](#conf-extra-platforms).
|
Nix will only build a given [store derivation](@docroot@/glossary.md#gloss-store-derivation) locally when its `system` attribute equals any of the values specified here or in [`extra-platforms`](#conf-extra-platforms).
|
||||||
|
@ -1089,7 +1091,7 @@ public:
|
||||||
)"};
|
)"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_ACL_SUPPORT
|
#if NIX_SUPPORT_ACL
|
||||||
Setting<StringSet> ignoredAcls{
|
Setting<StringSet> ignoredAcls{
|
||||||
this, {"security.selinux", "system.nfs4_acl", "security.csm"}, "ignored-acls",
|
this, {"security.selinux", "system.nfs4_acl", "security.csm"}, "ignored-acls",
|
||||||
R"(
|
R"(
|
||||||
|
|
|
@ -4,12 +4,12 @@ include_dirs = [
|
||||||
include_directories('..'),
|
include_directories('..'),
|
||||||
]
|
]
|
||||||
|
|
||||||
config_h = configure_file(
|
config_pub_h = configure_file(
|
||||||
configuration : configdata,
|
configuration : configdata_pub,
|
||||||
output : 'config-store.hh',
|
output : 'store-config.hh',
|
||||||
)
|
)
|
||||||
|
|
||||||
headers = [config_h] + files(
|
headers = [config_pub_h] + files(
|
||||||
'binary-cache-store.hh',
|
'binary-cache-store.hh',
|
||||||
'build-result.hh',
|
'build-result.hh',
|
||||||
'build/derivation-goal.hh',
|
'build/derivation-goal.hh',
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the syscall number for `fchmodat2`.
|
* Determine the syscall number for `fchmodat2`.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@ void setPersonality(std::string_view system)
|
||||||
struct utsname utsbuf;
|
struct utsname utsbuf;
|
||||||
uname(&utsbuf);
|
uname(&utsbuf);
|
||||||
if ((system == "i686-linux"
|
if ((system == "i686-linux"
|
||||||
&& (std::string_view(SYSTEM) == "x86_64-linux"
|
&& (std::string_view(NIX_LOCAL_SYSTEM) == "x86_64-linux"
|
||||||
|| (!strcmp(utsbuf.sysname, "Linux") && !strcmp(utsbuf.machine, "x86_64"))))
|
|| (!strcmp(utsbuf.sysname, "Linux") && !strcmp(utsbuf.machine, "x86_64"))))
|
||||||
|| system == "armv7l-linux"
|
|| system == "armv7l-linux"
|
||||||
|| system == "armv6l-linux"
|
|| system == "armv6l-linux"
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
|
|
||||||
#include "nix/strings.hh"
|
#include "nix/strings.hh"
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,20 @@ cxx = meson.get_compiler('cpp')
|
||||||
|
|
||||||
subdir('nix-meson-build-support/deps-lists')
|
subdir('nix-meson-build-support/deps-lists')
|
||||||
|
|
||||||
configdata = configuration_data()
|
configdata_pub = configuration_data()
|
||||||
|
configdata_priv = configuration_data()
|
||||||
|
|
||||||
# TODO rename, because it will conflict with downstream projects
|
# TODO rename, because it will conflict with downstream projects
|
||||||
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
configdata_priv.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
|
||||||
configdata.set_quoted('SYSTEM', host_machine.cpu_family() + '-' + host_machine.system())
|
# Used in public header.
|
||||||
|
configdata_pub.set_quoted(
|
||||||
|
'NIX_LOCAL_SYSTEM',
|
||||||
|
host_machine.cpu_family() + '-' + host_machine.system(),
|
||||||
|
description :
|
||||||
|
'This is the system name Nix expects for local running instance of Nix.\n\n'
|
||||||
|
+ 'See the "system" setting for additional details',
|
||||||
|
)
|
||||||
|
|
||||||
deps_private_maybe_subproject = [
|
deps_private_maybe_subproject = [
|
||||||
]
|
]
|
||||||
|
@ -47,28 +55,30 @@ run_command('rm', '-f',
|
||||||
check : true,
|
check : true,
|
||||||
)
|
)
|
||||||
summary('can hardlink to symlink', can_link_symlink, bool_yn : true)
|
summary('can hardlink to symlink', can_link_symlink, bool_yn : true)
|
||||||
configdata.set('CAN_LINK_SYMLINK', can_link_symlink.to_int())
|
configdata_priv.set('CAN_LINK_SYMLINK', can_link_symlink.to_int())
|
||||||
|
|
||||||
# Check for each of these functions, and create a define like `#define HAVE_LCHOWN 1`.
|
# Check for each of these functions, and create a define like `#define HAVE_LCHOWN 1`.
|
||||||
#
|
|
||||||
# Only need to do functions that deps (like `libnixutil`) didn't already
|
|
||||||
# check for.
|
|
||||||
check_funcs = [
|
check_funcs = [
|
||||||
# Optionally used for canonicalising files from the build
|
# Optionally used for canonicalising files from the build
|
||||||
'lchown',
|
'lchown',
|
||||||
|
'posix_fallocate',
|
||||||
'statvfs',
|
'statvfs',
|
||||||
]
|
]
|
||||||
foreach funcspec : check_funcs
|
foreach funcspec : check_funcs
|
||||||
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
||||||
define_value = cxx.has_function(funcspec).to_int()
|
define_value = cxx.has_function(funcspec).to_int()
|
||||||
configdata.set(define_name, define_value)
|
configdata_priv.set(define_name, define_value)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
has_acl_support = cxx.has_header('sys/xattr.h') \
|
has_acl_support = cxx.has_header('sys/xattr.h') \
|
||||||
and cxx.has_function('llistxattr') \
|
and cxx.has_function('llistxattr') \
|
||||||
and cxx.has_function('lremovexattr')
|
and cxx.has_function('lremovexattr')
|
||||||
# TODO: used in header - make proper public header and make sure it's included. Affects ABI!
|
# Used in public header. Affects ABI!
|
||||||
configdata.set('HAVE_ACL_SUPPORT', has_acl_support.to_int())
|
configdata_pub.set(
|
||||||
|
'NIX_SUPPORT_ACL',
|
||||||
|
has_acl_support.to_int(),
|
||||||
|
description : 'FIXME: It\'s a bit peculiar that this needs to be exposed. The reason is that that it effects whether the settings struct in a header has a particular field. This is also odd, because it means when there is no ACL support one will just get an "unknown setting" warning from their configuration.',
|
||||||
|
)
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
if host_machine.system() == 'darwin'
|
||||||
sandbox = cxx.find_library('sandbox')
|
sandbox = cxx.find_library('sandbox')
|
||||||
|
@ -104,7 +114,7 @@ seccomp = dependency('libseccomp', 'seccomp', required : seccomp_required, versi
|
||||||
if is_linux and not seccomp.found()
|
if is_linux and not seccomp.found()
|
||||||
warning('Sandbox security is reduced because libseccomp has not been found! Please provide libseccomp if it supports your CPU architecture.')
|
warning('Sandbox security is reduced because libseccomp has not been found! Please provide libseccomp if it supports your CPU architecture.')
|
||||||
endif
|
endif
|
||||||
configdata.set('HAVE_SECCOMP', seccomp.found().to_int())
|
configdata_priv.set('HAVE_SECCOMP', seccomp.found().to_int())
|
||||||
deps_private += seccomp
|
deps_private += seccomp
|
||||||
|
|
||||||
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
|
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
|
||||||
|
@ -116,7 +126,7 @@ deps_private += sqlite
|
||||||
# AWS C++ SDK has bad pkg-config. See
|
# AWS C++ SDK has bad pkg-config. See
|
||||||
# https://github.com/aws/aws-sdk-cpp/issues/2673 for details.
|
# https://github.com/aws/aws-sdk-cpp/issues/2673 for details.
|
||||||
aws_s3 = dependency('aws-cpp-sdk-s3', required : false)
|
aws_s3 = dependency('aws-cpp-sdk-s3', required : false)
|
||||||
configdata.set('ENABLE_S3', aws_s3.found().to_int())
|
configdata_priv.set('ENABLE_S3', aws_s3.found().to_int())
|
||||||
if aws_s3.found()
|
if aws_s3.found()
|
||||||
aws_s3 = declare_dependency(
|
aws_s3 = declare_dependency(
|
||||||
include_directories: include_directories(aws_s3.get_variable('includedir')),
|
include_directories: include_directories(aws_s3.get_variable('includedir')),
|
||||||
|
@ -148,7 +158,7 @@ if get_option('embedded-sandbox-shell')
|
||||||
# The path to busybox is passed as a -D flag when compiling this_library.
|
# The path to busybox is passed as a -D flag when compiling this_library.
|
||||||
# This solution is inherited from the old make buildsystem
|
# This solution is inherited from the old make buildsystem
|
||||||
# TODO: do this differently?
|
# TODO: do this differently?
|
||||||
configdata.set('HAVE_EMBEDDED_SANDBOX_SHELL', 1)
|
configdata_priv.set('HAVE_EMBEDDED_SANDBOX_SHELL', 1)
|
||||||
hexdump = find_program('hexdump', native : true)
|
hexdump = find_program('hexdump', native : true)
|
||||||
embedded_sandbox_shell_gen = custom_target(
|
embedded_sandbox_shell_gen = custom_target(
|
||||||
'embedded-sandbox-shell.gen.hh',
|
'embedded-sandbox-shell.gen.hh',
|
||||||
|
@ -166,12 +176,9 @@ if get_option('embedded-sandbox-shell')
|
||||||
generated_headers += embedded_sandbox_shell_gen
|
generated_headers += embedded_sandbox_shell_gen
|
||||||
endif
|
endif
|
||||||
|
|
||||||
add_project_arguments(
|
config_priv_h = configure_file(
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configuration : configdata_priv,
|
||||||
# It would be nice for our headers to be idempotent instead.
|
output : 'store-config-private.hh',
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -347,6 +354,7 @@ this_library = library(
|
||||||
'nixstore',
|
'nixstore',
|
||||||
generated_headers,
|
generated_headers,
|
||||||
sources,
|
sources,
|
||||||
|
config_priv_h,
|
||||||
dependencies : deps_public + deps_private + deps_other,
|
dependencies : deps_public + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
cpp_args : cpp_args,
|
cpp_args : cpp_args,
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
#if HAVE_ACL_SUPPORT
|
|
||||||
# include <sys/xattr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nix/posix-fs-canonicalise.hh"
|
#include "nix/posix-fs-canonicalise.hh"
|
||||||
#include "nix/file-system.hh"
|
#include "nix/file-system.hh"
|
||||||
#include "nix/signals.hh"
|
#include "nix/signals.hh"
|
||||||
#include "nix/util.hh"
|
#include "nix/util.hh"
|
||||||
#include "nix/globals.hh"
|
#include "nix/globals.hh"
|
||||||
#include "nix/store-api.hh"
|
#include "nix/store-api.hh"
|
||||||
|
#include "nix/store-config.hh"
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
|
#if NIX_SUPPORT_ACL
|
||||||
|
# include <sys/xattr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ static void canonicalisePathMetaData_(
|
||||||
if (!(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode)))
|
if (!(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode)))
|
||||||
throw Error("file '%1%' has an unsupported type", path);
|
throw Error("file '%1%' has an unsupported type", path);
|
||||||
|
|
||||||
#if HAVE_ACL_SUPPORT
|
#if NIX_SUPPORT_ACL
|
||||||
/* Remove extended attributes / ACLs. */
|
/* Remove extended attributes / ACLs. */
|
||||||
ssize_t eaSize = llistxattr(path.c_str(), nullptr, 0);
|
ssize_t eaSize = llistxattr(path.c_str(), nullptr, 0);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "nix/posix-fs-canonicalise.hh"
|
#include "nix/posix-fs-canonicalise.hh"
|
||||||
#include "nix/posix-source-accessor.hh"
|
#include "nix/posix-source-accessor.hh"
|
||||||
#include "nix/restricted-store.hh"
|
#include "nix/restricted-store.hh"
|
||||||
|
#include "nix/store-config.hh"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -34,6 +35,8 @@
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
#if HAVE_STATVFS
|
#if HAVE_STATVFS
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1785,7 +1788,7 @@ void setupSeccomp()
|
||||||
seccomp_release(ctx);
|
seccomp_release(ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
constexpr std::string_view nativeSystem = SYSTEM;
|
constexpr std::string_view nativeSystem = NIX_LOCAL_SYSTEM;
|
||||||
|
|
||||||
if (nativeSystem == "x86_64-linux" &&
|
if (nativeSystem == "x86_64-linux" &&
|
||||||
seccomp_arch_add(ctx, SCMP_ARCH_X86) != 0)
|
seccomp_arch_add(ctx, SCMP_ARCH_X86) != 0)
|
||||||
|
|
|
@ -25,21 +25,11 @@ subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
|
||||||
config_h = configure_file(
|
config_priv_h = configure_file(
|
||||||
configuration : configdata,
|
configuration : configdata,
|
||||||
output : 'nix_api_util_config.h',
|
output : 'nix_api_util_config.h',
|
||||||
)
|
)
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
|
|
||||||
# From C++ libraries, only for internals
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
@ -61,7 +51,7 @@ subdir('nix-meson-build-support/windows-version')
|
||||||
this_library = library(
|
this_library = library(
|
||||||
'nixutilc',
|
'nixutilc',
|
||||||
sources,
|
sources,
|
||||||
config_h,
|
config_priv_h,
|
||||||
dependencies : deps_public + deps_private + deps_other,
|
dependencies : deps_public + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
link_args: linker_export_flags,
|
link_args: linker_export_flags,
|
||||||
|
|
|
@ -25,13 +25,6 @@ subdir('nix-meson-build-support/subprojects')
|
||||||
rapidcheck = dependency('rapidcheck')
|
rapidcheck = dependency('rapidcheck')
|
||||||
deps_public += rapidcheck
|
deps_public += rapidcheck
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
|
|
|
@ -35,14 +35,9 @@ deps_private += gtest
|
||||||
configdata = configuration_data()
|
configdata = configuration_data()
|
||||||
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
|
||||||
config_h = configure_file(
|
config_priv_h = configure_file(
|
||||||
configuration : configdata,
|
configuration : configdata,
|
||||||
output : 'config-util-tests.hh',
|
output : 'util-tests-config.hh',
|
||||||
)
|
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
'-include', 'config-util-tests.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
@ -84,7 +79,7 @@ include_dirs = [include_directories('.')]
|
||||||
this_exe = executable(
|
this_exe = executable(
|
||||||
meson.project_name(),
|
meson.project_name(),
|
||||||
sources,
|
sources,
|
||||||
config_h,
|
config_priv_h,
|
||||||
dependencies : deps_private_subproject + deps_private + deps_other,
|
dependencies : deps_private_subproject + deps_private + deps_other,
|
||||||
include_directories : include_dirs,
|
include_directories : include_dirs,
|
||||||
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
# TODO: -lrapidcheck, see ../libutil-support/build.meson
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "util-tests-config.hh"
|
||||||
|
|
||||||
namespace nixC {
|
namespace nixC {
|
||||||
|
|
||||||
TEST_F(nix_api_util_context, nix_context_error)
|
TEST_F(nix_api_util_context, nix_context_error)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "nix/types.hh"
|
#include "nix/types.hh"
|
||||||
|
|
||||||
|
#include "util-config-private.hh"
|
||||||
|
|
||||||
#if HAVE_LIBCPUID
|
#if HAVE_LIBCPUID
|
||||||
#include <libcpuid/libcpuid.h>
|
# include <libcpuid/libcpuid.h>
|
||||||
#include <map>
|
# include <map>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#include "nix/strings-inline.hh"
|
#include "nix/strings-inline.hh"
|
||||||
|
|
||||||
|
#include "util-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
namespace fs { using namespace std::filesystem; }
|
namespace fs { using namespace std::filesystem; }
|
||||||
|
@ -632,62 +634,6 @@ void replaceSymlink(const fs::path & target, const fs::path & link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWriteTime(
|
|
||||||
const fs::path & path,
|
|
||||||
time_t accessedTime,
|
|
||||||
time_t modificationTime,
|
|
||||||
std::optional<bool> optIsSymlink)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
// FIXME use `fs::last_write_time`.
|
|
||||||
//
|
|
||||||
// Would be nice to use std::filesystem unconditionally, but
|
|
||||||
// doesn't support access time just modification time.
|
|
||||||
//
|
|
||||||
// System clock vs File clock issues also make that annoying.
|
|
||||||
warn("Changing file times is not yet implemented on Windows, path is %s", path);
|
|
||||||
#elif HAVE_UTIMENSAT && HAVE_DECL_AT_SYMLINK_NOFOLLOW
|
|
||||||
struct timespec times[2] = {
|
|
||||||
{
|
|
||||||
.tv_sec = accessedTime,
|
|
||||||
.tv_nsec = 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.tv_sec = modificationTime,
|
|
||||||
.tv_nsec = 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
if (utimensat(AT_FDCWD, path.c_str(), times, AT_SYMLINK_NOFOLLOW) == -1)
|
|
||||||
throw SysError("changing modification time of %s (using `utimensat`)", path);
|
|
||||||
#else
|
|
||||||
struct timeval times[2] = {
|
|
||||||
{
|
|
||||||
.tv_sec = accessedTime,
|
|
||||||
.tv_usec = 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.tv_sec = modificationTime,
|
|
||||||
.tv_usec = 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
#if HAVE_LUTIMES
|
|
||||||
if (lutimes(path.c_str(), times) == -1)
|
|
||||||
throw SysError("changing modification time of %s", path);
|
|
||||||
#else
|
|
||||||
bool isSymlink = optIsSymlink
|
|
||||||
? *optIsSymlink
|
|
||||||
: fs::is_symlink(path);
|
|
||||||
|
|
||||||
if (!isSymlink) {
|
|
||||||
if (utimes(path.c_str(), times) == -1)
|
|
||||||
throw SysError("changing modification time of %s (not a symlink)", path);
|
|
||||||
} else {
|
|
||||||
throw Error("Cannot change modification time of symlink %s", path);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void setWriteTime(const fs::path & path, const struct stat & st)
|
void setWriteTime(const fs::path & path, const struct stat & st)
|
||||||
{
|
{
|
||||||
setWriteTime(path, st.st_atime, st.st_mtime, S_ISLNK(st.st_mode));
|
setWriteTime(path, st.st_atime, st.st_mtime, S_ISLNK(st.st_mode));
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
# include "nix/windows-error.hh"
|
# include "nix/windows-error.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "util-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
void copyRecursive(
|
void copyRecursive(
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
include_dirs = [include_directories('..')]
|
include_dirs = [include_directories('..')]
|
||||||
|
|
||||||
config_h = configure_file(
|
headers = files(
|
||||||
configuration : configdata,
|
|
||||||
output : 'config-util.hh',
|
|
||||||
)
|
|
||||||
|
|
||||||
headers = [config_h] + files(
|
|
||||||
'abstract-setting-to-json.hh',
|
'abstract-setting-to-json.hh',
|
||||||
'ansicolor.hh',
|
'ansicolor.hh',
|
||||||
'archive.hh',
|
'archive.hh',
|
||||||
|
|
|
@ -23,36 +23,20 @@ deps_public_maybe_subproject = [
|
||||||
subdir('nix-meson-build-support/subprojects')
|
subdir('nix-meson-build-support/subprojects')
|
||||||
|
|
||||||
# Check for each of these functions, and create a define like `#define
|
# Check for each of these functions, and create a define like `#define
|
||||||
# HAVE_LUTIMES 1`. The `#define` is unconditional, 0 for not found and 1
|
# HAVE_POSIX_FALLOCATE 1`. The `#define` is unconditional, 0 for not
|
||||||
# for found. One therefore uses it with `#if` not `#ifdef`.
|
# found and 1 for found. One therefore uses it with `#if` not `#ifdef`.
|
||||||
check_funcs = [
|
check_funcs = [
|
||||||
'close_range',
|
[
|
||||||
# Optionally used for changing the mtime of symlinks.
|
'posix_fallocate',
|
||||||
'lutimes',
|
'Optionally used to preallocate files to be large enough before writing to them.',
|
||||||
# Optionally used for creating pipes on Unix
|
],
|
||||||
'pipe2',
|
|
||||||
# Optionally used to preallocate files to be large enough before
|
|
||||||
# writing to them.
|
|
||||||
# WARNING: define also used in libstore
|
|
||||||
'posix_fallocate',
|
|
||||||
# Optionally used to get more information about processes failing due
|
|
||||||
# to a signal on Unix.
|
|
||||||
'strsignal',
|
|
||||||
# Optionally used to try to close more file descriptors (e.g. before
|
|
||||||
# forking) on Unix.
|
|
||||||
# WARNING: also used in libexpr
|
|
||||||
'sysconf',
|
|
||||||
# Optionally used for changing the mtime of files and symlinks.
|
|
||||||
'utimensat',
|
|
||||||
]
|
]
|
||||||
foreach funcspec : check_funcs
|
foreach funcspec : check_funcs
|
||||||
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
define_name = 'HAVE_' + funcspec[0].underscorify().to_upper()
|
||||||
define_value = cxx.has_function(funcspec).to_int()
|
define_value = cxx.has_function(funcspec[0]).to_int()
|
||||||
configdata.set(define_name, define_value)
|
configdata.set(define_name, define_value, description: funcspec[1])
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
configdata.set('HAVE_DECL_AT_SYMLINK_NOFOLLOW', cxx.has_header_symbol('fcntl.h', 'AT_SYMLINK_NOFOLLOW').to_int())
|
|
||||||
|
|
||||||
subdir('nix-meson-build-support/libatomic')
|
subdir('nix-meson-build-support/libatomic')
|
||||||
|
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
|
@ -116,16 +100,14 @@ deps_public += nlohmann_json
|
||||||
|
|
||||||
cxx = meson.get_compiler('cpp')
|
cxx = meson.get_compiler('cpp')
|
||||||
|
|
||||||
add_project_arguments(
|
config_priv_h = configure_file(
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
configuration : configdata,
|
||||||
# It would be nice for our headers to be idempotent instead.
|
output : 'util-config-private.hh',
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
sources = files(
|
sources = [config_priv_h] + files(
|
||||||
'archive.cc',
|
'archive.cc',
|
||||||
'args.cc',
|
'args.cc',
|
||||||
'canon-path.cc',
|
'canon-path.cc',
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
|
#include "util-config-private.hh"
|
||||||
|
#include "util-unix-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -1,10 +1,72 @@
|
||||||
|
#include <cerrno>
|
||||||
|
#include <climits>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "nix/file-system.hh"
|
#include "nix/file-system.hh"
|
||||||
|
|
||||||
|
#include "util-unix-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
namespace fs {
|
||||||
|
using namespace std::filesystem;
|
||||||
|
}
|
||||||
|
|
||||||
Descriptor openDirectory(const std::filesystem::path & path)
|
Descriptor openDirectory(const std::filesystem::path & path)
|
||||||
{
|
{
|
||||||
return open(path.c_str(), O_RDONLY | O_DIRECTORY);
|
return open(path.c_str(), O_RDONLY | O_DIRECTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setWriteTime(const fs::path & path, time_t accessedTime, time_t modificationTime, std::optional<bool> optIsSymlink)
|
||||||
|
{
|
||||||
|
// Would be nice to use std::filesystem unconditionally, but
|
||||||
|
// doesn't support access time just modification time.
|
||||||
|
//
|
||||||
|
// System clock vs File clock issues also make that annoying.
|
||||||
|
#if HAVE_UTIMENSAT && HAVE_DECL_AT_SYMLINK_NOFOLLOW
|
||||||
|
struct timespec times[2] = {
|
||||||
|
{
|
||||||
|
.tv_sec = accessedTime,
|
||||||
|
.tv_nsec = 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.tv_sec = modificationTime,
|
||||||
|
.tv_nsec = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (utimensat(AT_FDCWD, path.c_str(), times, AT_SYMLINK_NOFOLLOW) == -1)
|
||||||
|
throw SysError("changing modification time of %s (using `utimensat`)", path);
|
||||||
|
#else
|
||||||
|
struct timeval times[2] = {
|
||||||
|
{
|
||||||
|
.tv_sec = accessedTime,
|
||||||
|
.tv_usec = 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.tv_sec = modificationTime,
|
||||||
|
.tv_usec = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
# if HAVE_LUTIMES
|
||||||
|
if (lutimes(path.c_str(), times) == -1)
|
||||||
|
throw SysError("changing modification time of %s", path);
|
||||||
|
# else
|
||||||
|
bool isSymlink = optIsSymlink ? *optIsSymlink : fs::is_symlink(path);
|
||||||
|
|
||||||
|
if (!isSymlink) {
|
||||||
|
if (utimes(path.c_str(), times) == -1)
|
||||||
|
throw SysError("changing modification time of %s (not a symlink)", path);
|
||||||
|
} else {
|
||||||
|
throw Error("Cannot change modification time of symlink %s", path);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,53 @@
|
||||||
|
include_dirs += include_directories('.')
|
||||||
|
|
||||||
|
configdata_unix = configuration_data()
|
||||||
|
|
||||||
|
configdata_unix.set(
|
||||||
|
'HAVE_DECL_AT_SYMLINK_NOFOLLOW',
|
||||||
|
cxx.has_header_symbol('fcntl.h', 'AT_SYMLINK_NOFOLLOW').to_int(),
|
||||||
|
description : 'Optionally used for changing the files and symlinks.'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check for each of these functions, and create a define like `#define
|
||||||
|
# HAVE_CLOSE_RANGE 1`.
|
||||||
|
check_funcs_unix = [
|
||||||
|
[
|
||||||
|
'close_range',
|
||||||
|
'For closing many file descriptors after forking.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'lutimes',
|
||||||
|
'Optionally used for changing the mtime of symlinks.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'pipe2',
|
||||||
|
'Optionally used for creating pipes on Unix.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'strsignal',
|
||||||
|
'Optionally used to get more information about processes failing due to a signal on Unix.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'sysconf',
|
||||||
|
'Optionally used to try to close more file descriptors (e.g. before forking) on Unix.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'utimensat',
|
||||||
|
'Optionally used for changing the mtime of files and symlinks.',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
foreach funcspec : check_funcs_unix
|
||||||
|
define_name = 'HAVE_' + funcspec[0].underscorify().to_upper()
|
||||||
|
define_value = cxx.has_function(funcspec[0]).to_int()
|
||||||
|
configdata_unix.set(define_name, define_value, description: funcspec[1])
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
config_unix_priv_h = configure_file(
|
||||||
|
configuration : configdata_unix,
|
||||||
|
output : 'util-unix-config-private.hh',
|
||||||
|
)
|
||||||
|
sources += config_unix_priv_h
|
||||||
|
|
||||||
sources += files(
|
sources += files(
|
||||||
'environment-variables.cc',
|
'environment-variables.cc',
|
||||||
'file-descriptor.cc',
|
'file-descriptor.cc',
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "util-config-private.hh"
|
||||||
|
#include "util-unix-config-private.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,21 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
namespace fs {
|
||||||
|
using namespace std::filesystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWriteTime(const fs::path & path, time_t accessedTime, time_t modificationTime, std::optional<bool> optIsSymlink)
|
||||||
|
{
|
||||||
|
// FIXME use `fs::last_write_time`.
|
||||||
|
//
|
||||||
|
// Would be nice to use std::filesystem unconditionally, but
|
||||||
|
// doesn't support access time just modification time.
|
||||||
|
//
|
||||||
|
// System clock vs File clock issues also make that annoying.
|
||||||
|
warn("Changing file times is not yet implemented on Windows, path is %s", path);
|
||||||
|
}
|
||||||
|
|
||||||
Descriptor openDirectory(const std::filesystem::path & path)
|
Descriptor openDirectory(const std::filesystem::path & path)
|
||||||
{
|
{
|
||||||
return CreateFileW(
|
return CreateFileW(
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "self-exe.hh"
|
#include "self-exe.hh"
|
||||||
#include "crash-handler.hh"
|
#include "crash-handler.hh"
|
||||||
|
#include "cli-config-private.hh"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
|
@ -46,25 +46,15 @@ if not fs.is_absolute(bindir)
|
||||||
endif
|
endif
|
||||||
configdata.set_quoted('NIX_BIN_DIR', bindir)
|
configdata.set_quoted('NIX_BIN_DIR', bindir)
|
||||||
|
|
||||||
config_h = configure_file(
|
config_priv_h = configure_file(
|
||||||
configuration : configdata,
|
configuration : configdata,
|
||||||
output : 'config-nix-cli.hh',
|
output : 'cli-config-private.hh',
|
||||||
)
|
|
||||||
|
|
||||||
add_project_arguments(
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
'-include', 'config-nix-cli.hh',
|
|
||||||
language : 'cpp',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
subdir('nix-meson-build-support/generate-header')
|
subdir('nix-meson-build-support/generate-header')
|
||||||
|
|
||||||
nix_sources = [config_h] + files(
|
nix_sources = [config_priv_h] + files(
|
||||||
'add-to-store.cc',
|
'add-to-store.cc',
|
||||||
'app.cc',
|
'app.cc',
|
||||||
'self-exe.cc',
|
'self-exe.cc',
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "nix/current-process.hh"
|
#include "nix/current-process.hh"
|
||||||
#include "nix/file-system.hh"
|
#include "nix/file-system.hh"
|
||||||
#include "nix/globals.hh"
|
#include "nix/globals.hh"
|
||||||
|
|
||||||
#include "self-exe.hh"
|
#include "self-exe.hh"
|
||||||
|
#include "cli-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#include "nix/config-util.hh"
|
|
||||||
#include "nix/config-store.hh"
|
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
#include "perl.h"
|
#include "perl.h"
|
||||||
#include "XSUB.h"
|
#include "XSUB.h"
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
libplugintest = shared_module(
|
libplugintest = shared_module(
|
||||||
'plugintest',
|
'plugintest',
|
||||||
'plugintest.cc',
|
'plugintest.cc',
|
||||||
cpp_args : [
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
'-include', 'nix/config-expr.hh',
|
|
||||||
],
|
|
||||||
dependencies : [
|
dependencies : [
|
||||||
dependency('nix-expr'),
|
dependency('nix-expr'),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
libstoreconsumer_tester = executable(
|
libstoreconsumer_tester = executable(
|
||||||
'test-libstoreconsumer',
|
'test-libstoreconsumer',
|
||||||
'main.cc',
|
'main.cc',
|
||||||
cpp_args : [
|
|
||||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
|
||||||
# It would be nice for our headers to be idempotent instead.
|
|
||||||
'-include', 'nix/config-util.hh',
|
|
||||||
'-include', 'nix/config-store.hh',
|
|
||||||
],
|
|
||||||
dependencies : [
|
dependencies : [
|
||||||
dependency('nix-store'),
|
dependency('nix-store'),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue