1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

Merge pull request #10973 from NixOS/meson-libexpr

Meson build for libexpr libflake, external C API, unit tests
This commit is contained in:
Robert Hensing 2024-07-05 20:27:12 +02:00 committed by GitHub
commit ddff76f667
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
101 changed files with 2446 additions and 810 deletions

View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -0,0 +1,74 @@
project('nix-expr-test-support', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
]
deps_public_maybe_subproject = [
dependency('nix-util'),
dependency('nix-util-test-support'),
dependency('nix-store'),
dependency('nix-store-test-support'),
dependency('nix-expr'),
]
subdir('build-utils-meson/subprojects')
rapidcheck = dependency('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', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-expr.hh',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'tests/value/context.cc',
)
include_dirs = [include_directories('.')]
headers = files(
'tests/libexpr.hh',
'tests/nix_api_expr.hh',
'tests/value/context.hh',
)
subdir('build-utils-meson/export-all-symbols')
this_library = library(
'nix-expr-test-support',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
prelink : true, # For C++ static initializers
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
subdir('build-utils-meson/export')

View file

@ -0,0 +1,83 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-store-test-support
, nix-expr
, rapidcheck
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-util-test-support";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
propagatedBuildInputs = [
nix-store-test-support
nix-expr
rapidcheck
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

1
tests/unit/libexpr/.version Symbolic link
View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

View file

@ -0,0 +1,90 @@
project('nix-expr-tests', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
dependency('nix-expr'),
dependency('nix-expr-c'),
dependency('nix-expr-test-support'),
]
deps_public_maybe_subproject = [
]
subdir('build-utils-meson/subprojects')
subdir('build-utils-meson/export-all-symbols')
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest')
deps_private += gtest
gtest = dependency('gmock')
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', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-store.hh',
'-include', 'config-util.h',
'-include', 'config-store.h',
'-include', 'config-expr.h',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'derived-path.cc',
'error_traces.cc',
'eval.cc',
'json.cc',
'main.cc',
'nix_api_expr.cc',
'nix_api_external.cc',
'nix_api_value.cc',
'primops.cc',
'search-path.cc',
'trivial.cc',
'value/context.cc',
'value/print.cc',
'value/value.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
install : true,
)
test(
meson.project_name(),
this_exe,
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
},
protocol : 'gtest',
)

View file

@ -0,0 +1,100 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-expr
, nix-expr-c
, nix-expr-test-support
, rapidcheck
, gtest
, runCommand
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-expr-tests";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
nix-expr
nix-expr-c
nix-expr-test-support
rapidcheck
gtest
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
nix-expr-tests
touch $out
'';
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -0,0 +1,71 @@
project('nix-fetchers-tests', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
dependency('nix-store-test-support'),
dependency('nix-fetchers'),
]
deps_public_maybe_subproject = [
]
subdir('build-utils-meson/subprojects')
subdir('build-utils-meson/export-all-symbols')
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
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', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-store.hh',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'public-key.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(
meson.project_name(),
this_exe,
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
},
protocol : 'gtest',
)

View file

@ -0,0 +1,98 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-fetchers
, nix-store-test-support
, rapidcheck
, gtest
, runCommand
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-fetchers-tests";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
nix-fetchers
nix-store-test-support
rapidcheck
gtest
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
nix-fetchers-tests
touch $out
'';
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

View file

@ -0,0 +1,72 @@
project('nix-flake-tests', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
dependency('nix-expr-test-support'),
dependency('nix-flake'),
]
deps_public_maybe_subproject = [
]
subdir('build-utils-meson/subprojects')
subdir('build-utils-meson/export-all-symbols')
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
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', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-expr.hh',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'flakeref.cc',
'url-name.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(
meson.project_name(),
this_exe,
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
},
protocol : 'gtest',
)

View file

@ -0,0 +1,98 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-flake
, nix-expr-test-support
, rapidcheck
, gtest
, runCommand
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-flake-tests";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
nix-flake
nix-expr-test-support
rapidcheck
gtest
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
nix-flake-tests
touch $out
'';
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -0,0 +1,76 @@
project('nix-store-test-support', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
]
deps_public_maybe_subproject = [
dependency('nix-util'),
dependency('nix-util-test-support'),
dependency('nix-store'),
]
subdir('build-utils-meson/subprojects')
rapidcheck = dependency('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', 'config-util.hh',
'-include', 'config-store.hh',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'tests/derived-path.cc',
'tests/outputs-spec.cc',
'tests/path.cc',
)
include_dirs = [include_directories('.')]
headers = files(
'tests/derived-path.hh',
'tests/libstore.hh',
'tests/nix_api_store.hh',
'tests/outputs-spec.hh',
'tests/path.hh',
'tests/protocol.hh',
)
subdir('build-utils-meson/export-all-symbols')
this_library = library(
'nix-store-test-support',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
prelink : true, # For C++ static initializers
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
subdir('build-utils-meson/export')

View file

@ -0,0 +1,83 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-util-test-support
, nix-store
, rapidcheck
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-store-test-support";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
propagatedBuildInputs = [
nix-util-test-support
nix-store
rapidcheck
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -0,0 +1,95 @@
project('nix-store-tests', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
deps_private_maybe_subproject = [
dependency('nix-store'),
dependency('nix-store-c'),
dependency('nix-store-test-support'),
]
deps_public_maybe_subproject = [
]
subdir('build-utils-meson/subprojects')
subdir('build-utils-meson/export-all-symbols')
sqlite = dependency('sqlite3', 'sqlite', version : '>=3.6.19')
deps_private += sqlite
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
deps_private += gtest
gtest = dependency('gmock')
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', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-util.h',
'-include', 'config-store.h',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'common-protocol.cc',
'content-address.cc',
'derivation-advanced-attrs.cc',
'derivation.cc',
'derived-path.cc',
'downstream-placeholder.cc',
'machines.cc',
'nar-info-disk-cache.cc',
'nar-info.cc',
'nix_api_store.cc',
'outputs-spec.cc',
'path-info.cc',
'path.cc',
'references.cc',
'serve-protocol.cc',
'store-reference.cc',
'worker-protocol.cc',
)
include_dirs = [include_directories('.')]
this_exe = executable(
meson.project_name(),
sources,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
# get main from gtest
install : true,
)
test(
meson.project_name(),
this_exe,
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
},
protocol : 'gtest',
)

View file

@ -0,0 +1,111 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
, ninja
, pkg-config
, nix-store
, nix-store-c
, nix-store-test-support
, sqlite
, rapidcheck
, gtest
, runCommand
# Configuration Options
, versionSuffix ? ""
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-store-tests";
inherit version;
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
nix-store
nix-store-c
nix-store-test-support
sqlite
rapidcheck
gtest
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = let
# Some data is shared with the functional tests: they create it,
# we consume it.
data = lib.fileset.toSource {
root = ../..;
fileset = lib.fileset.unions [
./data
../../functional/derivation
];
};
in runCommand "${finalAttrs.pname}-run" {} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${data + "/unit/libstore/data"}
nix-store-tests
touch $out
'';
};
};
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -14,32 +14,27 @@ project('nix-util-test-support', 'cpp',
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
subdir('build-utils-meson/deps-lists')
# See note in ../nix-util/meson.build
deps_public = [ ]
deps_private_maybe_subproject = [
]
deps_public_maybe_subproject = [
dependency('nix-util'),
]
subdir('build-utils-meson/subprojects')
# See note in ../nix-util/meson.build
deps_other = [ ]
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
add_project_arguments(
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Werror=unused-result',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
# It would be nice for our headers to be idempotent instead.
'-include', 'config-util.hh',
language : 'cpp',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'tests/hash.cc',
'tests/string_callback.cc',
@ -54,28 +49,7 @@ headers = files(
'tests/string_callback.hh',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
nix_util = dependency('nix-util')
if nix_util.type_name() == 'internal'
# subproject sadly no good for pkg-config module
deps_other += nix_util
else
deps_public += nix_util
endif
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
subdir('build-utils-meson/export-all-symbols')
this_library = library(
'nix-util-test-support',
@ -85,6 +59,7 @@ this_library = library(
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
prelink : true, # For C++ static initializers
install : true,
)
@ -92,20 +67,4 @@ install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
name : 'Nix',
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : deps_public,
requires_private : deps_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [],
))
subdir('build-utils-meson/export')

View file

@ -1,5 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
@ -13,40 +14,29 @@
# Configuration Options
, versionSuffix ? ""
# Check test coverage of Nix. Probably want to use with at least
# one of `doCheck` or `doInstallCheck` enabled.
, withCoverageChecks ? false
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
mkDerivation =
if withCoverageChecks
then
# TODO support `finalAttrs` args function in
# `releaseTools.coverageAnalysis`.
argsFun:
releaseTools.coverageAnalysis (let args = argsFun args; in args)
else stdenv.mkDerivation;
in
mkDerivation (finalAttrs: {
mkMesonDerivation (finalAttrs: {
pname = "nix-util-test-support";
inherit version;
src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
};
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
@ -56,20 +46,17 @@ mkDerivation (finalAttrs: {
pkg-config
];
buildInputs = [
nix-util
rapidcheck
]
;
propagatedBuildInputs = [
nix-util
rapidcheck
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
echo ${version} > .version
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
@ -83,8 +70,7 @@ mkDerivation (finalAttrs: {
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564
strictDeps = !withCoverageChecks;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
@ -92,8 +78,4 @@ mkDerivation (finalAttrs: {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
} // lib.optionalAttrs withCoverageChecks {
lcovFilter = [ "*/boost/*" "*-tab.*" ];
hardeningDisable = [ "fortify" ];
})

View file

@ -1 +0,0 @@
2.24.0

1
tests/unit/libutil/.version Symbolic link
View file

@ -0,0 +1 @@
../../../.version

View file

@ -0,0 +1 @@
../../../build-utils-meson/

View file

@ -1,4 +1,4 @@
project('nix-util-test', 'cpp',
project('nix-util-tests', 'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++2a',
@ -14,45 +14,34 @@ project('nix-util-test', 'cpp',
cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
subdir('build-utils-meson/deps-lists')
# See note in ../nix-util/meson.build
deps_public = [ ]
deps_private_maybe_subproject = [
dependency('nix-util'),
dependency('nix-util-c'),
dependency('nix-util-test-support'),
]
deps_public_maybe_subproject = [
]
subdir('build-utils-meson/subprojects')
# See note in ../nix-util/meson.build
deps_other = [ ]
subdir('build-utils-meson/export-all-symbols')
configdata = configuration_data()
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
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', 'config-util-test.h',
# '-include', 'config-store.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-Werror=unused-result',
'-Wdeprecated-copy',
'-Wignored-qualifiers',
# Enable assertions in libstdc++ by default. Harmless on libc++. Benchmarked
# at ~1% overhead in `nix search`.
#
# FIXME: remove when we get meson 1.4.0 which will default this to on for us:
# https://mesonbuild.com/Release-notes-for-1-4-0.html#ndebug-setting-now-controls-c-stdlib-assertions
'-D_GLIBCXX_ASSERTIONS=1',
'-include', 'config-util.hh',
'-include', 'config-util.h',
language : 'cpp',
)
# TODO rename, because it will conflict with downstream projects
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h = configure_file(
configuration : configdata,
output : 'config-util-test.h',
)
subdir('build-utils-meson/diagnostics')
sources = files(
'args.cc',
@ -80,52 +69,11 @@ sources = files(
include_dirs = [include_directories('.')]
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
# This is a temporary sledgehammer to export everything like on Unix,
# and not detail with this yet.
#
# TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = ['-Wl,--export-all-symbols']
else
linker_export_flags = []
endif
nix_util = dependency('nix-util')
if nix_util.type_name() == 'internal'
# subproject sadly no good for pkg-config module
deps_other += nix_util
else
deps_public += nix_util
endif
nix_util_c = dependency('nix-util-c')
if nix_util_c.type_name() == 'internal'
# subproject sadly no good for pkg-config module
deps_other += nix_util_c
else
deps_public += nix_util_c
endif
nix_util_test_support = dependency('nix-util-test-support')
if nix_util_test_support.type_name() == 'internal'
# subproject sadly no good for pkg-config module
deps_other += nix_util_test_support
else
deps_public += nix_util_test_support
endif
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
gtest = dependency('gtest', main : true)
deps_public += gtest
this_exe = executable(
'nix-util-test',
meson.project_name(),
sources,
dependencies : deps_public + deps_private + deps_other,
dependencies : deps_private_subproject + deps_private + deps_other,
include_directories : include_dirs,
# TODO: -lrapidcheck, see ../libutil-support/build.meson
link_args: linker_export_flags + ['-lrapidcheck'],
@ -133,11 +81,11 @@ this_exe = executable(
install : true,
)
test('nix-util-test', this_exe, env : ['_NIX_TEST_UNIT_DATA=' + meson.current_source_dir() + '/data'])
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_exe,
compile_args : ['-std=c++2a'],
dependencies : [],
))
test(
meson.project_name(),
this_exe,
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
},
protocol : 'gtest',
)

View file

@ -1,5 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, releaseTools
, meson
@ -17,40 +18,29 @@
# Configuration Options
, versionSuffix ? ""
# Check test coverage of Nix. Probably want to use with at least
# one of `doCheck` or `doInstallCheck` enabled.
, withCoverageChecks ? false
}:
let
inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
mkDerivation =
if withCoverageChecks
then
# TODO support `finalAttrs` args function in
# `releaseTools.coverageAnalysis`.
argsFun:
releaseTools.coverageAnalysis (let args = argsFun args; in args)
else stdenv.mkDerivation;
in
mkDerivation (finalAttrs: {
pname = "nix-util-test";
mkMesonDerivation (finalAttrs: {
pname = "nix-util-tests";
inherit version;
src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
};
workDir = ./.;
fileset = fileset.unions [
../../../build-utils-meson
./build-utils-meson
../../../.version
./.version
./meson.build
# ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
@ -69,9 +59,11 @@ mkDerivation (finalAttrs: {
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
echo ${version} > .version
chmod u+w ./.version
echo ${version} > ../../../.version
'';
mesonFlags = [
@ -85,8 +77,7 @@ mkDerivation (finalAttrs: {
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564
strictDeps = !withCoverageChecks;
strictDeps = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
@ -96,7 +87,7 @@ mkDerivation (finalAttrs: {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
nix-util-test
nix-util-tests
touch $out
'';
};
@ -106,8 +97,4 @@ mkDerivation (finalAttrs: {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
} // lib.optionalAttrs withCoverageChecks {
lcovFilter = [ "*/boost/*" "*-tab.*" ];
hardeningDisable = [ "fortify" ];
})