Mesonify other external API

This commit is contained in:
John Ericson 2024-06-27 10:19:03 -04:00
parent 31257009e1
commit 4fa8068b78
12 changed files with 392 additions and 40 deletions

View file

@ -18,6 +18,8 @@ subproject('external-api-docs')
# C wrappers
subproject('libutil-c')
subproject('libstore-c')
subproject('libexpr-c')
# Language Bindings
subproject('perl')
@ -25,3 +27,8 @@ subproject('perl')
# Testing
subproject('libutil-test-support')
subproject('libutil-test')
#subproject('libstore-test-support')
#subproject('libstore-test')
#subproject('libexpr-test-support')
#subproject('libexpr-test')
#subproject('libflake-test')

1
src/libexpr-c/.version Symbolic link
View file

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

159
src/libexpr-c/meson.build Normal file
View file

@ -0,0 +1,159 @@
project('nix-expr-c', '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_private_subproject = [ ]
# 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-expr'),
]
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
foreach nix_dep : [
dependency('nix-util-c'),
dependency('nix-store-c'),
]
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
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.
# From C++ libraries, only for internals
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-include', 'config-expr.hh',
# From C libraries, for our public, installed headers too
'-include', 'config-util.h',
'-include', 'config-store.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(
'nix_api_expr.cc',
'nix_api_external.cc',
'nix_api_value.cc',
)
include_dirs = [include_directories('.')]
headers = [config_h] + files(
'nix_api_expr.h',
'nix_api_external.h',
'nix_api_value.h',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter ab_subprojectout 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
this_library = library(
'nixexprc',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args: linker_export_flags,
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires_private = []
foreach dep : deps_private_subproject
requires_private += dep.name()
endforeach
requires_private += deps_private
requires_public = []
foreach dep : deps_public_subproject
requires_public += dep.name()
endforeach
requires_public += 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_public,
requires_private : requires_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [],
))

View file

@ -77,16 +77,16 @@ configdata.set('HAVE_BOEHMGC', bdw_gc.found().to_int())
config_h = configure_file(
configuration : configdata,
output : 'config-expr.h',
output : 'config-expr.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', 'config-util.h',
'-include', 'config-store.h',
'-include', 'config-util.hh',
'-include', 'config-store.hh',
# '-include', 'config-fetchers.h',
'-include', 'config-expr.h',
'-include', 'config-expr.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',

View file

@ -48,8 +48,8 @@ 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-util.hh',
'-include', 'config-store.hh',
# '-include', 'config-fetchers.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',

View file

@ -50,10 +50,10 @@ 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-util.hh',
'-include', 'config-store.hh',
# '-include', 'config-fetchers.h',
'-include', 'config-expr.h',
'-include', 'config-expr.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',

1
src/libstore-c/.version Symbolic link
View file

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

151
src/libstore-c/meson.build Normal file
View file

@ -0,0 +1,151 @@
project('nix-store-c', '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_private_subproject = [ ]
# 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'),
]
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
foreach nix_dep : [
dependency('nix-util-c'),
]
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
config_h = configure_file(
configuration : configdata,
output : 'config-store.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', 'config-util.hh',
'-include', 'config-store.hh',
# From C libraries, for our public, installed headers too
'-include', 'config-util.h',
'-include', 'config-store.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(
'nix_api_store.cc',
)
include_dirs = [include_directories('.')]
headers = [config_h] + files(
'nix_api_store.h',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter ab_subprojectout 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
this_library = library(
'nixstorec',
sources,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args: linker_export_flags,
install : true,
)
install_headers(headers, subdir : 'nix', preserve_path : true)
requires_private = []
foreach dep : deps_private_subproject
requires_private += dep.name()
endforeach
requires_private += deps_private
requires_public = []
foreach dep : deps_public_subproject
requires_public += dep.name()
endforeach
requires_public += 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_public,
requires_private : requires_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : [],
))

View file

@ -162,14 +162,14 @@ endif
config_h = configure_file(
configuration : configdata,
output : 'config-store.h',
output : 'config-store.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', 'config-util.h',
'-include', 'config-store.h',
'-include', 'config-util.hh',
'-include', 'config-store.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',

View file

@ -17,19 +17,60 @@ cxx = meson.get_compiler('cpp')
# See note in ../nix-util/meson.build
deps_private = [ ]
# See note in ../nix-util/meson.build
deps_private_subproject = [ ]
# 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'),
]
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
foreach nix_dep : [
]
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
# 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.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', 'config-util.hh',
# From C libraries, for our public, installed headers too
'-include', 'config-util.h',
# '-include', 'config-store.h',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',
@ -52,13 +93,12 @@ sources = files(
include_dirs = [include_directories('.')]
headers = files(
headers = [config_h] + files(
'nix_api_util.h',
'nix_api_util_internal.h',
)
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# Windows DLLs are stricter about symbol visibility than Unix shared
# Windows DLLs are stricter ab_subprojectout 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.
@ -69,22 +109,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
# 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.h',
)
this_library = library(
'nixutilc',
sources,
@ -96,7 +120,17 @@ this_library = library(
install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
requires_private = []
foreach dep : deps_private_subproject
requires_private += dep.name()
endforeach
requires_private += deps_private
requires_public = []
foreach dep : deps_public_subproject
requires_public += dep.name()
endforeach
requires_public += deps_public
import('pkgconfig').generate(
this_library,
@ -105,9 +139,8 @@ import('pkgconfig').generate(
description : 'Nix Package Manager',
subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : deps_public,
requires_private : deps_private,
libraries_private : libraries_private,
requires : requires_public,
requires_private : requires_private,
)
meson.override_dependency(meson.project_name(), declare_dependency(

View file

@ -132,13 +132,13 @@ deps_public += nlohmann_json
config_h = configure_file(
configuration : configdata,
output : 'config-util.h',
output : 'config-util.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', 'config-util.h',
'-include', 'config-util.hh',
'-Wno-deprecated-declarations',
'-Wimplicit-fallthrough',
'-Werror=switch',

View file

@ -1,5 +1,5 @@
#include "config-util.h"
#include "config-store.h"
#include "config-util.hh"
#include "config-store.hh"
#include "EXTERN.h"
#include "perl.h"