mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
Fix some portability issues with the new C bindings
Build without GC is unbroken Fix #10403 Also building tests with Windows (assuming rest of Windows fixes) is unbroken.
This commit is contained in:
parent
19016c7b52
commit
c1e0769355
7 changed files with 25 additions and 13 deletions
|
@ -17,7 +17,7 @@ libexprc_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libutilc) \
|
||||||
|
|
||||||
libexprc_LIBS = libutil libutilc libstore libstorec libexpr
|
libexprc_LIBS = libutil libutilc libstore libstorec libexpr
|
||||||
|
|
||||||
libexprc_LDFLAGS += -pthread
|
libexprc_LDFLAGS += $(THREAD_LDFLAGS)
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-expr-c.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(d)/nix-expr-c.pc, $(libdir)/pkgconfig, 0644))
|
||||||
|
|
||||||
|
|
|
@ -155,13 +155,13 @@ void nix_gc_now()
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void nix_gc_incref(nix_c_context * context, const void *)
|
nix_err nix_gc_incref(nix_c_context * context, const void *)
|
||||||
{
|
{
|
||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
return NIX_OK;
|
return NIX_OK;
|
||||||
}
|
}
|
||||||
void nix_gc_decref(nix_c_context * context, const void *)
|
nix_err nix_gc_decref(nix_c_context * context, const void *)
|
||||||
{
|
{
|
||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "attr-set.hh"
|
#include "attr-set.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
#include "gc/gc.h"
|
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
#include "value.hh"
|
#include "value.hh"
|
||||||
|
|
||||||
|
@ -16,8 +15,9 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#ifdef HAVE_BOEHMGC
|
#ifdef HAVE_BOEHMGC
|
||||||
#define GC_INCLUDE_NEW 1
|
# include "gc/gc.h"
|
||||||
#include "gc_cpp.h"
|
# define GC_INCLUDE_NEW 1
|
||||||
|
# include "gc_cpp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void nix_set_string_return(nix_string_return * str, const char * c)
|
void nix_set_string_return(nix_string_return * str, const char * c)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "attr-set.hh"
|
#include "attr-set.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
#include "gc/gc.h"
|
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
#include "primops.hh"
|
#include "primops.hh"
|
||||||
#include "value.hh"
|
#include "value.hh"
|
||||||
|
@ -13,8 +12,9 @@
|
||||||
#include "nix_api_value.h"
|
#include "nix_api_value.h"
|
||||||
|
|
||||||
#ifdef HAVE_BOEHMGC
|
#ifdef HAVE_BOEHMGC
|
||||||
#define GC_INCLUDE_NEW 1
|
# include "gc/gc.h"
|
||||||
#include "gc_cpp.h"
|
# define GC_INCLUDE_NEW 1
|
||||||
|
# include "gc_cpp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper function to throw an exception if value is null
|
// Helper function to throw an exception if value is null
|
||||||
|
@ -444,7 +444,7 @@ void nix_list_builder_free(ListBuilder * list_builder)
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
GC_FREE(list_builder);
|
GC_FREE(list_builder);
|
||||||
#else
|
#else
|
||||||
delete bb;
|
delete list_builder;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ libstorec_SOURCES := $(wildcard $(d)/*.cc)
|
||||||
|
|
||||||
libstorec_LIBS = libutil libstore libutilc
|
libstorec_LIBS = libutil libstore libutilc
|
||||||
|
|
||||||
libstorec_LDFLAGS += -pthread
|
libstorec_LDFLAGS += $(THREAD_LDFLAGS)
|
||||||
|
|
||||||
# Not just for this library itself, but also for downstream libraries using this library
|
# Not just for this library itself, but also for downstream libraries using this library
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,6 @@ libutilc_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libutilc)
|
||||||
|
|
||||||
libutilc_LIBS = libutil
|
libutilc_LIBS = libutil
|
||||||
|
|
||||||
libutilc_LDFLAGS += -pthread
|
libutilc_LDFLAGS += $(THREAD_LDFLAGS)
|
||||||
|
|
||||||
libutilc_FORCE_INSTALL := 1
|
libutilc_FORCE_INSTALL := 1
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
///@file
|
///@file
|
||||||
#include "tests/nix_api_util.hh"
|
#include "tests/nix_api_util.hh"
|
||||||
|
|
||||||
|
#include "file-system.hh"
|
||||||
|
|
||||||
#include "nix_api_store.h"
|
#include "nix_api_store.h"
|
||||||
#include "nix_api_store_internal.h"
|
#include "nix_api_store_internal.h"
|
||||||
|
|
||||||
|
@ -37,8 +39,18 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void init_local_store()
|
void init_local_store()
|
||||||
{
|
{
|
||||||
auto tmpl = nix::getEnv("TMPDIR").value_or("/tmp") + "/tests_nix-store.XXXXXX";
|
#ifdef _WIN32
|
||||||
|
// no `mkdtemp` with MinGW
|
||||||
|
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.";
|
||||||
|
for (size_t i = 0; true; ++i) {
|
||||||
|
nixDir = tmpl + std::string { i };
|
||||||
|
if (fs::create_directory(nixDir)) break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.XXXXXX";
|
||||||
nixDir = mkdtemp((char *) tmpl.c_str());
|
nixDir = mkdtemp((char *) tmpl.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
nixStoreDir = nixDir + "/my_nix_store";
|
nixStoreDir = nixDir + "/my_nix_store";
|
||||||
|
|
||||||
// Options documented in `nix help-stores`
|
// Options documented in `nix help-stores`
|
||||||
|
|
Loading…
Reference in a new issue