Progress on Wine CI support, MinGW dev shell with Meson (#10975)

* Only build perl subproject on Linux

* Fix various Windows regressions

* Don't put the emulator hook in test builds

  We run the tests in a separate derivation. Only need it for the dev shell.

* Fix native dev shells

* Fix cross dev shells we don't know how to emulate

Co-authored-by: PoweredByPie <poweredbypie@users.noreply.github.com>
Co-authored-by: Joachim Schiele <js@lastlog.de>
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
This commit is contained in:
poweredbypie 2024-07-21 15:03:04 -07:00 committed by GitHub
parent 56757e15cf
commit 0ec5e3a1bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 49 additions and 29 deletions

View File

@ -278,6 +278,7 @@
in
"-D${prefix}:${rest}";
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags;
in {
pname = "shell-for-" + attrs.pname;
@ -309,10 +310,12 @@
};
mesonFlags =
map (transformFlag "libutil") pkgs.nixComponents.nix-util.mesonFlags
++ map (transformFlag "libstore") pkgs.nixComponents.nix-store.mesonFlags
++ map (transformFlag "libfetchers") pkgs.nixComponents.nix-fetchers.mesonFlags
++ lib.optionals havePerl (map (transformFlag "perl") pkgs.nixComponents.nix-perl-bindings.mesonFlags)
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents.nix-store.mesonFlags)
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents.nix-fetchers.mesonFlags)
++ lib.optionals havePerl (map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents.nix-perl-bindings.mesonFlags))
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents.nix-cmd.mesonFlags)
;
nativeBuildInputs = attrs.nativeBuildInputs or []
@ -322,9 +325,16 @@
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs
++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ lib.optional
(!stdenv.buildPlatform.canExecute stdenv.hostPlatform
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
&& !(stdenv.hostPlatform.isWindows && stdenv.buildPlatform.isDarwin)
&& stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages
&& lib.meta.availableOn stdenv.buildPlatform (stdenv.hostPlatform.emulator pkgs.buildPackages))
pkgs.buildPackages.mesonEmulatorHook
++ [
pkgs.buildPackages.cmake
pkgs.shellcheck
pkgs.buildPackages.shellcheck
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install"
modular.pre-commit.settings.installationScript)

View File

@ -29,7 +29,9 @@ subproject('libexpr-c')
subproject('libmain-c')
# Language Bindings
if not meson.is_cross_build()
subproject('perl')
endif
# Testing
subproject('nix-util-test-support')

View File

@ -14,7 +14,7 @@
#include "nix_api_util.h"
#include "nix_api_util_internal.h"
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
# include <mutex>
# define GC_INCLUDE_NEW 1
# include "gc_cpp.h"
@ -131,7 +131,7 @@ void nix_state_free(EvalState * state)
delete state;
}
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
std::unordered_map<
const void *,
unsigned int,
@ -207,7 +207,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))
{
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
GC_REGISTER_FINALIZER(obj, finalizer, cd, 0, 0);
#endif
}

View File

@ -14,7 +14,7 @@
#include <nlohmann/json.hpp>
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
# include "gc/gc.h"
# define GC_INCLUDE_NEW 1
# include "gc_cpp.h"
@ -174,7 +174,7 @@ ExternalValue * nix_create_external_value(nix_c_context * context, NixCExternalV
context->last_err_code = NIX_OK;
try {
auto ret = new
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
(GC)
#endif
NixCExternalValue(*desc, v);

View File

@ -14,7 +14,7 @@
#include "nix_api_value.h"
#include "value/context.hh"
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
# include "gc/gc.h"
# define GC_INCLUDE_NEW 1
# include "gc_cpp.h"
@ -131,7 +131,7 @@ PrimOp * nix_alloc_primop(
try {
using namespace std::placeholders;
auto p = new
#ifdef HAVE_BOEHMGC
#if HAVE_BOEHMGC
(GC)
#endif
nix::PrimOp{

View File

@ -62,7 +62,7 @@ Goal::Co DrvOutputSubstitutionGoal::init()
#ifndef _WIN32
outPipe->readSide.get()
#else
&outPipe
&*outPipe
#endif
}, true, false);

View File

@ -416,7 +416,11 @@ void deletePath(const fs::path & path)
void createDir(const Path & path, mode_t mode)
{
if (mkdir(path.c_str(), mode) == -1)
if (mkdir(path.c_str()
#ifndef _WIN32
, mode
#endif
) == -1)
throw SysError("creating directory '%1%'", path);
}

View File

@ -97,7 +97,7 @@ void RestoreSink::createRegularFile(const CanonPath & path, std::function<void(C
RestoreRegularFile crf;
crf.fd =
#ifdef _WIN32
CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
CreateFileW(p.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
#else
open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666)
#endif
@ -145,7 +145,7 @@ void RestoreRegularFile::operator () (std::string_view data)
void RestoreSink::createSymlink(const CanonPath & path, const std::string & target)
{
auto p = append(dstPath, path);
nix::createSymlink(target, p);
nix::createSymlink(target, p.string());
}

View File

@ -88,12 +88,17 @@ nix_sources = files(
'store-info.cc',
'store-repair.cc',
'store.cc',
'unix/daemon.cc',
'upgrade-nix.cc',
'verify.cc',
'why-depends.cc',
)
if host_machine.system() != 'windows'
nix_sources += files(
'unix/daemon.cc',
)
endif
nix_sources += [
gen_header.process('doc/manual/generate-manpage.nix'),
gen_header.process('doc/manual/generate-settings.nix'),
@ -104,12 +109,6 @@ nix_sources += [
gen_header.process('help-stores.md'),
]
if host_machine.system() != 'windows'
nix_sources += files(
'unix/daemon.cc',
)
endif
# The rest of the subdirectories aren't separate components,
# just source files in another directory, so we process them here.
@ -146,9 +145,7 @@ nix_store_sources = files(
# Hurray for Meson list flattening!
sources = [
nix_sources,
build_remote_sources,
nix_build_sources,
nix_channel_sources,
unpack_channel_gen,
nix_collect_garbage_sources,
nix_copy_closure_sources,
@ -158,6 +155,13 @@ sources = [
nix_store_sources,
]
if host_machine.system() != 'windows'
sources += [
build_remote_sources,
nix_channel_sources,
]
endif
include_dirs = [include_directories('.')]
this_exe = executable(