mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-13 05:37:17 +02:00
![John Ericson](/assets/img/avatar_default.png)
The idea is two-fold: - Replace autotools with Meson - Build each library in its own derivation The interaction of these two features is that Meson's "subprojects" feature (https://mesonbuild.com/Subprojects) allows us to have single dev shell for building all libraries still, while also building things separately. This allows us to break up the build without a huge productivity lost. I tested the Linux native build, and NetBSD and Windows cross builds. Also do some clean ups of the Flake in the process of supporting new jobs. Special thanks to everyone that has worked on a Meson port so far, @p01arst0rm and @Qyriad in particular. Co-Authored-By: p01arst0rm <polar@ever3st.com> Co-Authored-By: Artemis Tosini <lix@artem.ist> Co-Authored-By: Artemis Tosini <me@artem.ist> Co-Authored-By: Felix Uhl <felix.uhl@outlook.com> Co-Authored-By: Jade Lovelace <lix@jade.fyi> Co-Authored-By: Lunaphied <lunaphied@lunaphied.me> Co-Authored-By: Maximilian Bosch <maximilian@mbosch.me> Co-Authored-By: Pierre Bourdon <delroth@gmail.com> Co-Authored-By: Qyriad <qyriad@qyriad.me> Co-Authored-By: Rebecca Turner <rbt@sent.as> Co-Authored-By: Winter <winter@winter.cafe> Co-Authored-By: eldritch horrors <pennae@lix.systems> Co-Authored-By: jade <lix@jade.fyi> Co-Authored-By: julia <midnight@trainwit.ch> Co-Authored-By: rebecca “wiggles” turner <rbt@sent.as> Co-Authored-By: wiggles dog <rbt@sent.as> Co-Authored-By: fricklerhandwerk <valentin@fricklerhandwerk.de> Co-authored-By: Eli Schwartz <eschwartz93@gmail.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
288 lines
6.9 KiB
Meson
288 lines
6.9 KiB
Meson
project('nix-util', 'cpp',
|
|
version : run_command('cat', './.version', check : true).stdout().strip(),
|
|
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 : '>= 0.64.0',
|
|
license : 'LGPL-2.1-or-later',
|
|
)
|
|
|
|
cxx = meson.get_compiler('cpp')
|
|
|
|
deps_private = [ ]
|
|
deps_public = [ ]
|
|
deps_other = [ ]
|
|
|
|
configdata = configuration_data()
|
|
|
|
# Check for each of these functions, and create a define like `#define HAVE_LUTIMES 1`.
|
|
check_funcs = [
|
|
# Optionally used for changing the mtime of symlinks.
|
|
'lutimes',
|
|
'pipe2',
|
|
'posix_fallocate',
|
|
'strsignal',
|
|
'sysconf',
|
|
]
|
|
foreach funcspec : check_funcs
|
|
define_name = 'HAVE_' + funcspec.underscorify().to_upper()
|
|
define_value = cxx.has_function(funcspec).to_int()
|
|
configdata.set(define_name, define_value)
|
|
endforeach
|
|
|
|
# Conditional to work around https://github.com/mesonbuild/meson/issues/13293
|
|
if host_machine.system() != 'windows' and cxx.get_id() == 'gcc'
|
|
deps_private += dependency('threads')
|
|
endif
|
|
|
|
if host_machine.system() == 'windows'
|
|
socket = cxx.find_library('ws2_32')
|
|
deps_other += socket
|
|
elif host_machine.system() == 'sunos'
|
|
socket = cxx.find_library('socket')
|
|
network_service_library = cxx.find_library('nsl')
|
|
deps_other += [socket, network_service_library]
|
|
endif
|
|
|
|
boost = dependency(
|
|
'boost',
|
|
modules : ['context', 'coroutine'],
|
|
)
|
|
# Actually public, but wrong type of dep for pkg config
|
|
deps_other += boost
|
|
|
|
openssl = dependency(
|
|
'libcrypto',
|
|
'openssl',
|
|
version : '>= 1.1.1',
|
|
)
|
|
deps_private += openssl
|
|
|
|
libarchive = dependency('libarchive', version : '>= 3.1.2')
|
|
deps_public += libarchive
|
|
if get_option('default_library') == 'static'
|
|
# Workaround until https://github.com/libarchive/libarchive/issues/1446 is fixed
|
|
add_project_arguments('-lz', language : 'cpp')
|
|
endif
|
|
|
|
sodium = dependency('libsodium', 'sodium')
|
|
deps_private += sodium
|
|
|
|
brotli = [
|
|
dependency('libbrotlicommon'),
|
|
dependency('libbrotlidec'),
|
|
dependency('libbrotlienc'),
|
|
]
|
|
deps_private += brotli
|
|
|
|
# cpuid only makes sense on x86_64
|
|
cpuid_required = host_machine.cpu_family() == 'x86_64' ? get_option('cpuid') : false
|
|
cpuid = dependency('libcpuid', 'cpuid', required : cpuid_required)
|
|
configdata.set('HAVE_LIBCPUID', cpuid.found().to_int())
|
|
deps_private += cpuid
|
|
|
|
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
|
|
deps_public += nlohmann_json
|
|
|
|
config_util_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.
|
|
'-include', 'config-util.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(
|
|
'archive.cc',
|
|
'args.cc',
|
|
'canon-path.cc',
|
|
'compression.cc',
|
|
'compute-levels.cc',
|
|
'config.cc',
|
|
'current-process.cc',
|
|
'english.cc',
|
|
'environment-variables.cc',
|
|
'error.cc',
|
|
'exit.cc',
|
|
'experimental-features.cc',
|
|
'file-content-address.cc',
|
|
'file-descriptor.cc',
|
|
'file-system.cc',
|
|
'fs-sink.cc',
|
|
'git.cc',
|
|
'hash.cc',
|
|
'hilite.cc',
|
|
'json-utils.cc',
|
|
'logging.cc',
|
|
'memory-source-accessor.cc',
|
|
'position.cc',
|
|
'posix-source-accessor.cc',
|
|
'references.cc',
|
|
'serialise.cc',
|
|
'signature/local-keys.cc',
|
|
'signature/signer.cc',
|
|
'source-accessor.cc',
|
|
'source-path.cc',
|
|
'suggestions.cc',
|
|
'tarfile.cc',
|
|
'terminal.cc',
|
|
'thread-pool.cc',
|
|
'unix-domain-socket.cc',
|
|
'url.cc',
|
|
'users.cc',
|
|
'util.cc',
|
|
'xml-writer.cc',
|
|
)
|
|
|
|
include_dirs = [include_directories('.')]
|
|
|
|
headers = [config_util_h] + files(
|
|
'abstract-setting-to-json.hh',
|
|
'ansicolor.hh',
|
|
'archive.hh',
|
|
'args.hh',
|
|
'args/root.hh',
|
|
'callback.hh',
|
|
'canon-path.hh',
|
|
'chunked-vector.hh',
|
|
'closure.hh',
|
|
'comparator.hh',
|
|
'compression.hh',
|
|
'compute-levels.hh',
|
|
'config-impl.hh',
|
|
'config.hh',
|
|
'current-process.hh',
|
|
'english.hh',
|
|
'environment-variables.hh',
|
|
'error.hh',
|
|
'exit.hh',
|
|
'experimental-features.hh',
|
|
'file-content-address.hh',
|
|
'file-descriptor.hh',
|
|
'file-path-impl.hh',
|
|
'file-path.hh',
|
|
'file-system.hh',
|
|
'finally.hh',
|
|
'fmt.hh',
|
|
'fs-sink.hh',
|
|
'git.hh',
|
|
'hash.hh',
|
|
'hilite.hh',
|
|
'json-impls.hh',
|
|
'json-utils.hh',
|
|
'logging.hh',
|
|
'lru-cache.hh',
|
|
'memory-source-accessor.hh',
|
|
'muxable-pipe.hh',
|
|
'pool.hh',
|
|
'position.hh',
|
|
'posix-source-accessor.hh',
|
|
'processes.hh',
|
|
'ref.hh',
|
|
'references.hh',
|
|
'regex-combinators.hh',
|
|
'repair-flag.hh',
|
|
'serialise.hh',
|
|
'signals.hh',
|
|
'signature/local-keys.hh',
|
|
'signature/signer.hh',
|
|
'source-accessor.hh',
|
|
'source-path.hh',
|
|
'split.hh',
|
|
'suggestions.hh',
|
|
'sync.hh',
|
|
'tarfile.hh',
|
|
'terminal.hh',
|
|
'thread-pool.hh',
|
|
'topo-sort.hh',
|
|
'types.hh',
|
|
'unix-domain-socket.hh',
|
|
'url-parts.hh',
|
|
'url.hh',
|
|
'users.hh',
|
|
'util.hh',
|
|
'variant-wrapper.hh',
|
|
'xml-writer.hh',
|
|
)
|
|
|
|
if host_machine.system() == 'linux'
|
|
subdir('linux')
|
|
endif
|
|
|
|
if host_machine.system() == 'windows'
|
|
subdir('windows')
|
|
else
|
|
subdir('unix')
|
|
endif
|
|
|
|
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
|
|
|
|
libutil = library(
|
|
'nixutil',
|
|
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)
|
|
|
|
libraries_private = ['-lboost_context', '-lboost_coroutine']
|
|
if host_machine.system() == 'windows'
|
|
# `libraries_private` cannot contain ad-hoc dependencies (from
|
|
# `find_library), so we need to do this manually
|
|
libraries_private += ['-lws2_32']
|
|
endif
|
|
|
|
import('pkgconfig').generate(
|
|
libutil,
|
|
filebase : 'nix-util',
|
|
name : 'Nix',
|
|
description : 'Nix Package Manager',
|
|
subdirs : ['nix'],
|
|
extra_cflags : ['-std=c++2a'],
|
|
requires : deps_public,
|
|
requires_private : deps_private,
|
|
# avoid absolute paths, use vendored ones
|
|
libraries_private : libraries_private,
|
|
)
|
|
|
|
nix_util = declare_dependency(
|
|
include_directories : include_dirs,
|
|
link_with : libutil,
|
|
compile_args : ['-std=c++2a'],
|
|
dependencies : [],
|
|
)
|
|
meson.override_dependency('nix-util', nix_util)
|