1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Meson build for libexpr and libflake

This commit is contained in:
John Ericson 2024-06-26 22:15:33 -04:00
parent fbdc554908
commit 31257009e1
16 changed files with 731 additions and 122 deletions

View file

@ -9,13 +9,19 @@ project('nix-dev-shell', 'cpp',
subproject('libutil')
subproject('libstore')
subproject('libfetchers')
subproject('perl')
subproject('libexpr')
subproject('libflake')
# Docs
subproject('internal-api-docs')
subproject('external-api-docs')
# C wrappers
subproject('libutil-c')
# Language Bindings
subproject('perl')
# Testing
subproject('libutil-test-support')
subproject('libutil-test')

View file

@ -19,10 +19,13 @@ in
nix-fetchers = callPackage ../src/libfetchers/package.nix { };
nix-perl-bindings = callPackage ../src/perl/package.nix { };
nix-expr = callPackage ../src/libexpr/package.nix { };
nix-flake = callPackage ../src/libflake/package.nix { };
nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { };
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { };
nix-perl-bindings = callPackage ../src/perl/package.nix { };
}

1
src/libexpr/.version Symbolic link
View file

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

254
src/libexpr/meson.build Normal file
View file

@ -0,0 +1,254 @@
project('nix-expr', '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')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
configdata = configuration_data()
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-store'),
dependency('nix-fetchers'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
# This is only conditional to work around
# https://github.com/mesonbuild/meson/issues/13293. It should be
# unconditional.
if not (host_machine.system() == 'windows' and cxx.get_id() == 'gcc')
deps_private += dependency('threads')
endif
boost = dependency(
'boost',
modules : ['container', 'context'],
)
# boost is a public dependency, but not a pkg-config dependency unfortunately, so we
# put in `deps_other`.
deps_other += boost
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
deps_public += nlohmann_json
bdw_gc = dependency('bdw-gc', required : get_option('gc'))
if bdw_gc.found()
deps_public += bdw_gc
foreach funcspec : [
'pthread_attr_get_np',
'pthread_getattr_np',
]
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
define_value = cxx.has_function(funcspec).to_int()
configdata.set(define_name, define_value)
endforeach
configdata.set('GC_THREADS', 1)
endif
configdata.set('HAVE_BOEHMGC', bdw_gc.found().to_int())
config_h = configure_file(
configuration : configdata,
output : 'config-expr.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.
'-include', 'config-util.h',
'-include', 'config-store.h',
# '-include', 'config-fetchers.h',
'-include', 'config-expr.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-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',
language : 'cpp',
)
parser_tab = custom_target(
input : 'parser.y',
output : [
'parser-tab.cc',
'parser-tab.hh',
],
command : [
'bison',
'-v',
'-o',
'@OUTPUT0@',
'@INPUT@',
'-d',
],
# NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add
# an install script below which removes parser-tab.cc.
install : true,
install_dir : get_option('includedir') / 'nix',
)
lexer_tab = custom_target(
input : [
'lexer.l',
parser_tab,
],
output : [
'lexer-tab.cc',
'lexer-tab.hh',
],
command : [
'flex',
'--outfile',
'@OUTPUT0@',
'--header-file=' + '@OUTPUT1@',
'@INPUT0@',
],
# NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add
# an install script below which removes lexer-tab.cc.
install : true,
install_dir : get_option('includedir') / 'nix',
)
generated_headers = []
foreach header : [
'imported-drv-to-derivation.nix',
'fetchurl.nix',
'flake/call-flake.nix',
'primops/derivation.nix',
]
generated_headers += custom_target(
command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
input : header,
output : '@PLAINNAME@.gen.hh',
)
endforeach
sources = files(
'attr-path.cc',
'attr-set.cc',
'eval-cache.cc',
'eval-error.cc',
'eval-gc.cc',
'eval-settings.cc',
'eval.cc',
'function-trace.cc',
'get-drvs.cc',
'json-to-value.cc',
'nixexpr.cc',
'paths.cc',
'primops.cc',
'primops/context.cc',
'primops/fetchClosure.cc',
'primops/fetchMercurial.cc',
'primops/fetchTree.cc',
'primops/fromTOML.cc',
'print-ambiguous.cc',
'print.cc',
'search-path.cc',
'value-to-json.cc',
'value-to-xml.cc',
'value/context.cc',
)
headers = [config_h] + files(
'attr-path.hh',
'attr-set.hh',
'eval-cache.hh',
'eval-error.hh',
'eval-gc.hh',
'eval-inline.hh',
'eval-settings.hh',
'eval.hh',
'function-trace.hh',
'gc-small-vector.hh',
'get-drvs.hh',
'json-to-value.hh',
'nixexpr.hh',
'parser-state.hh',
'pos-idx.hh',
'pos-table.hh',
'primops.hh',
'print-ambiguous.hh',
'print-options.hh',
'print.hh',
'repl-exit-status.hh',
'search-path.hh',
'symbol-table.hh',
'value-to-json.hh',
'value-to-xml.hh',
'value.hh',
'value/context.hh',
)
this_library = library(
'nixexpr',
sources,
parser_tab,
lexer_tab,
generated_headers,
dependencies : deps_public + deps_private + deps_other,
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
name : 'Nix',
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : requires,
requires_private : deps_private,
libraries_private : ['-lboost_container', '-lboost_context'],
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_directories('.'),
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : deps_public_subproject + deps_public,
))

View file

@ -0,0 +1,3 @@
option('gc', type : 'feature',
description : 'enable garbage collection in the Nix expression evaluator (requires Boehm GC)',
)

130
src/libexpr/package.nix Normal file
View file

@ -0,0 +1,130 @@
{ lib
, stdenv
, releaseTools
, meson
, ninja
, pkg-config
, nix-util
, nix-store
, nix-fetchers
, boost
, boehmgc
, nlohmann_json
# Configuration Options
, versionSuffix ? ""
# Check test coverage of Nix. Probably want to use with at least
# one of `doCheck` or `doInstallCheck` enabled.
, withCoverageChecks ? false
# Whether to use garbage collection for the Nix language evaluator.
#
# If it is disabled, we just leak memory, but this is not as bad as it
# sounds so long as evaluation just takes places within short-lived
# processes. (When the process exits, the memory is reclaimed; it is
# only leaked *within* the process.)
#
# Temporarily disabled on Windows because the `GC_throw_bad_alloc`
# symbol is missing during linking.
, enableGC ? !stdenv.hostPlatform.isWindows
}:
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-expr";
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") ./.)
];
};
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
boost
];
propagatedBuildInputs = [
nix-util
nix-store
nix-fetchers
nlohmann_json
] ++ lib.optional enableGC boehmgc;
disallowedReferences = [ boost ];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix
''
echo ${version} > .version
'';
mesonFlags = [
(lib.mesonFeature "gc" enableGC)
];
env = {
# Needed for Meson to find Boost.
# https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
} // lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
postInstall =
# Remove absolute path to boost libs that ends up in `Libs.private`
# by default, and would clash with out `disallowedReferences`. Part
# of the https://github.com/NixOS/nixpkgs/issues/45462 workaround.
''
sed -i "$out/lib/pkgconfig/nix-expr.pc" -e 's, ${lib.getLib boost}[^ ]*,,g'
'';
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564
strictDeps = !withCoverageChecks;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
} // lib.optionalAttrs withCoverageChecks {
lcovFilter = [ "*/boost/*" "*-tab.*" ];
hardeningDisable = [ "fortify" ];
})

View file

@ -1,4 +1,4 @@
#include "libfetchers/attrs.hh"
#include "attrs.hh"
#include "primops.hh"
#include "eval-inline.hh"
#include "eval-settings.hh"

View file

@ -20,27 +20,24 @@ deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
configdata = configuration_data()
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_store = dependency('nix-store')
if nix_store.type_name() == 'internal'
# subproject sadly no good for pkg-config module
deps_other += nix_store
else
deps_public += nix_store
endif
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-store'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
deps_public += nlohmann_json
@ -113,14 +110,9 @@ this_library = library(
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
if nix_util.type_name() == 'internal'
# `requires` cannot contain declared dependencies (from the
# subproject), so we need to do this manually
requires += 'nix-util'
endif
if nix_store.type_name() == 'internal'
requires += 'nix-store'
endif
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
@ -138,5 +130,5 @@ meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_directories('.'),
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [nix_util, nix_store],
dependencies : deps_public_subproject + deps_public,
))

View file

@ -38,7 +38,7 @@ let
in
mkDerivation (finalAttrs: {
pname = "nix-fetchers";
pname = "nix-flake";
inherit version;
src = fileset.toSource {
@ -80,11 +80,6 @@ mkDerivation (finalAttrs: {
enableParallelBuilding = true;
postInstall =
# Remove absolute path to boost libs
''
'';
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated

1
src/libflake/.version Symbolic link
View file

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

120
src/libflake/meson.build Normal file
View file

@ -0,0 +1,120 @@
project('nix-flake', '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')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-store'),
dependency('nix-fetchers'),
dependency('nix-expr'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
deps_public += nlohmann_json
libgit2 = dependency('libgit2')
deps_public += 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', 'config-util.h',
'-include', 'config-store.h',
# '-include', 'config-fetchers.h',
'-include', 'config-expr.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
'-Werror=switch-enum',
'-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',
language : 'cpp',
)
sources = files(
'flake-settings.cc',
'flake/config.cc',
'flake/flake.cc',
'flake/flakeref.cc',
'flake/url-name.cc',
'flake/lockfile.cc',
)
headers = files(
'flake-settings.hh',
'flake/flake.hh',
'flake/flakeref.hh',
'flake/lockfile.hh',
'flake/url-name.hh',
)
this_library = library(
'nixflake',
sources,
dependencies : deps_public + deps_private + deps_other,
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
name : 'Nix',
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : requires,
requires_private : deps_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_directories('.'),
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : deps_public_subproject + deps_public,
))

99
src/libflake/package.nix Normal file
View file

@ -0,0 +1,99 @@
{ lib
, stdenv
, releaseTools
, meson
, ninja
, pkg-config
, nix-util
, nix-store
, nix-fetchers
, nix-expr
, nlohmann_json
, libgit2
, man
# Configuration Options
, versionSuffix ? ""
# Check test coverage of Nix. Probably want to use with 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-flake";
inherit version;
src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./meson.build
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
};
outputs = [ "out" "dev" ];
nativeBuildInputs = [
meson
ninja
pkg-config
];
propagatedBuildInputs = [
nix-store
nix-util
nix-fetchers
nix-expr
nlohmann_json
];
preConfigure =
# "Inline" .version so its not a symlink, and includes the suffix
''
echo ${version} > .version
'';
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
LDFLAGS = "-fuse-ld=gold";
};
enableParallelBuilding = true;
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated
# to work with `strictDeps`.
strictDeps = !withCoverageChecks;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
} // lib.optionalAttrs withCoverageChecks {
lcovFilter = [ "*-tab.*" ];
hardeningDisable = ["fortify"];
})

View file

@ -20,6 +20,9 @@ deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
@ -30,13 +33,17 @@ configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
configdata.set_quoted('SYSTEM', host_machine.system())
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
foreach nix_dep : [
dependency('nix-util'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
run_command('ln', '-s',
meson.project_build_root() / '__nothing_link_target',
@ -122,13 +129,16 @@ if enable_embedded_sandbox_shell
endif
generated_headers = []
foreach header : [ 'schema.sql', 'ca-specific-schema.sql' ]
foreach header : [
'schema.sql',
'ca-specific-schema.sql',
]
generated_headers += custom_target(
command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
input : header,
output : '@PLAINNAME@.gen.hh',
install : true,
install_dir : get_option('includedir') / 'nix'
install_dir : get_option('includedir') / 'nix',
)
endforeach
@ -248,7 +258,7 @@ include_dirs = [
include_directories('build'),
]
headers = [config_h] +files(
headers = [config_h] + files(
'binary-cache-store.hh',
'build-result.hh',
'build/derivation-goal.hh',
@ -427,11 +437,9 @@ this_library = library(
install_headers(headers, subdir : 'nix', preserve_path : true)
requires = []
if nix_util.type_name() == 'internal'
# `requires` cannot contain declared dependencies (from the
# subproject), so we need to do this manually
requires += 'nix-util'
endif
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
@ -450,5 +458,5 @@ meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [nix_util],
dependencies : deps_public_subproject + deps_public,
))

View file

@ -23,9 +23,6 @@
# Check test coverage of Nix. Probably want to use with at least
# one of `doCheck` or `doInstallCheck` enabled.
, withCoverageChecks ? false
# Avoid setting things that would interfere with a functioning devShell
, forDevShell ? false
}:
let

View file

@ -20,9 +20,27 @@ deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
# See note in ../nix-util/meson.build
deps_public_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
foreach nix_dep : [
dependency('nix-util'),
]
if nix_dep.type_name() == 'internal'
deps_public_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_public += nix_dep
endif
endforeach
rapidcheck = dependency('rapidcheck')
deps_public += rapidcheck
add_project_arguments(
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
@ -66,17 +84,6 @@ 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
this_library = library(
'nix-util-test-support',
sources,
@ -90,7 +97,11 @@ this_library = library(
install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
requires = []
foreach dep : deps_public_subproject
requires += dep.name()
endforeach
requires += deps_public
import('pkgconfig').generate(
this_library,
@ -99,7 +110,7 @@ import('pkgconfig').generate(
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : deps_public,
requires : requires,
requires_private : deps_private,
)
@ -107,5 +118,5 @@ meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [],
dependencies : deps_public_subproject + deps_public,
))

View file

@ -18,18 +18,57 @@ cxx = meson.get_compiler('cpp')
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_public = [ ]
deps_private_subproject = [ ]
# See note in ../nix-util/meson.build
deps_other = [ ]
configdata = configuration_data()
# TODO rename, because it will conflict with downstream projects
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
foreach nix_dep : [
dependency('nix-util'),
dependency('nix-util-c'),
dependency('nix-util-test-support'),
]
if nix_dep.type_name() == 'internal'
deps_private_subproject += nix_dep
# subproject sadly no good for pkg-config module
deps_other += nix_dep
else
deps_private += nix_dep
endif
endforeach
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
rapidcheck = dependency('rapidcheck')
deps_private += rapidcheck
gtest = dependency('gtest', main : true)
deps_private += gtest
config_h = configure_file(
configuration : configdata,
output : 'config-util-test.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.
'-include', 'config-util-test.h',
# '-include', 'config-store.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
@ -46,14 +85,6 @@ add_project_arguments(
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',
)
sources = files(
'args.cc',
'canon-path.cc',
@ -80,52 +111,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',
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'],
@ -139,5 +129,4 @@ meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_exe,
compile_args : ['-std=c++2a'],
dependencies : [],
))