diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 00000000000..f09e5ece57b --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,18 @@ +#! /usr/bin/env bash + +export PKG_CONFIG_PATH="/usr/lib/pkgconfig/;/lib/pkgconfig/;/usr/share/pkgconfig/" + +# Delete existing buildfiles +#--------------------------------------------------- +rm -rf build + + +# Call meson +#--------------------------------------------------- +meson setup build -Dprefix="/usr" + + +# Build nix +#--------------------------------------------------- +cd build +ninja \ No newline at end of file diff --git a/dependencies/archive/meson.build b/dependencies/archive/meson.build new file mode 100644 index 00000000000..efdfb26625b --- /dev/null +++ b/dependencies/archive/meson.build @@ -0,0 +1,7 @@ +# LibArchive Dependency File +#============================================================================ + + +# Look for libarchive, a required dependency +#-------------------------------------------------- +libarchive_dep = cpp.find_library('archive') diff --git a/dependencies/aws-sdk-cpp/meson.build b/dependencies/aws-sdk-cpp/meson.build new file mode 100644 index 00000000000..1a99321329d --- /dev/null +++ b/dependencies/aws-sdk-cpp/meson.build @@ -0,0 +1,82 @@ +# aws s3 Dependency File +#============================================================================ + +#-------------------------------------------------- +# FIXME: aws-cpp-sdk should be an optional dependency Unfortunately, importing +# it using the pkg-config option, which could be optional, fails because of +# the cflags in the pkg-config. They contain "-fno-exceptions -std=c++11", +# both of which break existing Nix code. +#-------------------------------------------------- + +# Look for aws-cpp-sdk +#-------------------------------------------------- +aws_sdk_cpp_core_dep = declare_dependency( + dependencies : cpp.find_library('aws-cpp-sdk-core', + dirs : get_option('aws_sdk_cpp_lib_dir')), + include_directories : include_directories( + get_option('aws_sdk_cpp_include_dir'))) + +aws_sdk_cpp_s3_dep = declare_dependency( + dependencies : cpp.find_library('aws-cpp-sdk-s3', + dirs : get_option('aws_sdk_cpp_lib_dir')), + include_directories : include_directories( + get_option('aws_sdk_cpp_include_dir'))) + +aws_sdk_cpp_transfer_dep = declare_dependency( + dependencies : cpp.find_library('aws-cpp-sdk-transfer', + dirs : get_option('aws_sdk_cpp_lib_dir')), + include_directories : include_directories( + get_option('aws_sdk_cpp_include_dir'))) + + +aws_sdk_cpp_dep = [ + aws_sdk_cpp_core_dep, + aws_sdk_cpp_s3_dep, + aws_sdk_cpp_transfer_dep, +] + +# check if dependencies are found +#-------------------------------------------------- +have_aws_sdk_cpp = true +foreach dep : aws_sdk_cpp_dep + if not dep.found() + have_aws_sdk_cpp = false + endif +endforeach + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'ENABLE_S3', + have_aws_sdk_cpp.to_int(), + description : 'Whether to enable S3 support via aws-sdk-cpp.') + +if have_aws_sdk_cpp + check_s3client = cpp.check_header( + 'aws/s3/S3Client.h', + dependencies: aws_sdk_cpp_dep) + + if check_s3client + config_h.set( + 'HAVE_AWS_S3_S3CLIENT_H', 1, + description : 'Whether to enable S3 support via aws-sdk-cpp.') + endif + + aws_version = meson.get_compiler('cpp').get_define( + 'AWS_SDK_VERSION_STRING', + prefix : '#include ' + ).strip('"').split('.') + + config_h.set( + 'AWS_VERSION_MAJOR', aws_version[0], + description : 'Major version of aws-sdk-cpp.') + + config_h.set( + 'AWS_VERSION_MINOR', aws_version[1], + description : 'Minor version of aws-sdk-cpp.') + config_h.set( + 'AWS_VERSION_PATCH', aws_version[2], + description : 'Patch version of aws-sdk-cpp.') + +endif diff --git a/dependencies/bdw-gc/meson.build b/dependencies/bdw-gc/meson.build new file mode 100644 index 00000000000..a9f32b0b8ff --- /dev/null +++ b/dependencies/bdw-gc/meson.build @@ -0,0 +1,13 @@ +# Boehm-gc Dependency File +#============================================================================ + + +# Look for Boehm garbage collector, an optional dependency +#-------------------------------------------------- +gc_dep = dependency('bdw-gc', required: get_option('gc')) + + +config_h.set( + 'HAVE_BOEHMGC', + gc_dep.found().to_int(), + description : 'Whether to use the Boehm garbage collector.') diff --git a/dependencies/boost/meson.build b/dependencies/boost/meson.build new file mode 100644 index 00000000000..fd091aa22b7 --- /dev/null +++ b/dependencies/boost/meson.build @@ -0,0 +1,22 @@ +# Boost Dependency File +#============================================================================ + + +# Look for boost, a required dependency +#---------------------------------------------------- +boost_mod_list = [ + 'system', + 'context', + 'thread'] + + +boost_dep = dependency( + 'boost', + modules: boost_mod_list) + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_BOOST', 1, + description : 'Define if the Boost library is available.') diff --git a/dependencies/brotli/meson.build b/dependencies/brotli/meson.build new file mode 100644 index 00000000000..4dcf4af2f5a --- /dev/null +++ b/dependencies/brotli/meson.build @@ -0,0 +1,17 @@ +# LibBrotli Dependency File +#============================================================================ + + +# Look for libbrotli{enc,dec}, a required dependency +#-------------------------------------------------- +libbrotli_dep = declare_dependency( + dependencies: [ + dependency('libbrotlienc'), + dependency('libbrotlidec')]) + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_BROTLI', 1, + description : 'Define if the brotli library is available.') diff --git a/dependencies/cpuid/meson.build b/dependencies/cpuid/meson.build new file mode 100644 index 00000000000..218cab42c82 --- /dev/null +++ b/dependencies/cpuid/meson.build @@ -0,0 +1,13 @@ +# cpuid Dependency File +#============================================================================ + + +# Look for cpuid, a required dependency +#-------------------------------------------------- +libcpuid_dep = dependency('libcpuid') + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_LIBCPUID', 1, + description : 'Define if the CPUID is available.') diff --git a/dependencies/curl/meson.build b/dependencies/curl/meson.build new file mode 100644 index 00000000000..0759219d2e2 --- /dev/null +++ b/dependencies/curl/meson.build @@ -0,0 +1,14 @@ +# LibCurl Dependency File +#============================================================================ + + +# Look for libcurl, a required dependency +#-------------------------------------------------- +libcurl_dep = dependency('libcurl') + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_CURL', 1, + description : 'Define if the curl library is available.') diff --git a/dependencies/dl/meson.build b/dependencies/dl/meson.build new file mode 100644 index 00000000000..9e0954bb61d --- /dev/null +++ b/dependencies/dl/meson.build @@ -0,0 +1,7 @@ +# libdl Dependency File +#============================================================================ + + +# Look for libdl, a required dependency +#-------------------------------------------------- +libdl_dep = cpp.find_library('dl') diff --git a/dependencies/editline/meson.build b/dependencies/editline/meson.build new file mode 100644 index 00000000000..1c745969750 --- /dev/null +++ b/dependencies/editline/meson.build @@ -0,0 +1,35 @@ +# Editline Dependency File +#============================================================================ + + +# Look for editline, a required dependency +#-------------------------------------------------- +# NOTE: The the libeditline.pc file was added only in libeditline >= 1.15.2, see +# https://github.com/troglobit/editline/commit/0a8f2ef4203c3a4a4726b9dd1336869cd0da8607, +# but e.g. Ubuntu 16.04 has an older version, so we fall back to searching for +# editline.h when the pkg-config approach fails. + +editline_dep = cpp.find_library('editline') + +if not ( + cpp.has_header( + 'editline.h', + dependencies : editline_dep)) + error('Nix requires editline.h; however the header was not found.') +endif + + +if not ( + cpp.has_function( + 'read_history', + prefix : '#include \n#include "editline.h"', + dependencies : editline_dep)) + error('Nix requires libeditline; However, required functions do not work.' +\ + 'Maybe libeditline version is too old? >= 1.14 is required.') +endif + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_EDITLINE_H', 1, + description : 'Define to 1 if you have the header file.') diff --git a/dependencies/functions/meson.build b/dependencies/functions/meson.build new file mode 100644 index 00000000000..32371203896 --- /dev/null +++ b/dependencies/functions/meson.build @@ -0,0 +1,40 @@ +# nix check functions +#============================================================================ + + +# check for required functions +#-------------------------------------------------- +required_functions = [ + 'lutimes', + 'lchown', + 'pipe2', + 'posix_fallocate', + 'setresuid', + 'setreuid', + 'statvfs', + 'strsignal', + 'sysconf'] + +foreach f : required_functions + if cpp.has_function(f) + config_h.set( + 'HAVE_@0@'.format(f.to_upper()), 1, + description : 'Define to 1 if you have the `@0@` function.'.format(f)) + endif +endforeach + + +# compiler check for pubsetbuff +#-------------------------------------------------- +pubsetbuff_c = ''' +#include +using namespace std; +static char buf[1024]; +void func() { +cerr.rdbuf()->pubsetbuf(buf, sizeof(buf)); +}''' + +check_pubsetbuff = meson.get_compiler('cpp').compiles(pubsetbuff_c, name : 'pubsetbuf') +config_h.set( + 'HAVE_PUBSETBUF', check_pubsetbuff.to_int(), + description : 'Define to 1 if you have the `pubsetbuf` function.') diff --git a/dependencies/gtest/meson.build b/dependencies/gtest/meson.build new file mode 100644 index 00000000000..45dc5c595f7 --- /dev/null +++ b/dependencies/gtest/meson.build @@ -0,0 +1,24 @@ +# gtest Dependency File +#======================================================================== + + +# check if gtest is already installed +#--------------------------------------------------- +gtest_dep = dependency( + 'gtest', + main : true, + required : false) + +gmock_dep = dependency( + 'gmock', + main : true, + required : false) + + +# If not, include the submodule +#--------------------------------------------------- +if not gtest_dep.found() + gtest_proj = subproject('gtest') + gtest_dep = gtest_proj.get_variable('gtest_main_dep') + gmock_dep = gtest_proj.get_variable('gmock_dep') +endif diff --git a/dependencies/headers/meson.build b/dependencies/headers/meson.build new file mode 100644 index 00000000000..9cfa730427f --- /dev/null +++ b/dependencies/headers/meson.build @@ -0,0 +1,45 @@ +# nix check headers +#============================================================================ + +# check for various headers +#-------------------------------------------------- +project_header_deps = [ + 'sys/stat.h', + 'sys/types.h', + 'sys/dir.h', + 'sys/ndir.h', + 'dirent.h', + 'locale.h', + 'unistd.h', + 'stdint.h', + 'stdlib.h', + 'strings.h', + 'string.h', + 'inttypes.h', + 'memory.h'] + +foreach f : project_header_deps + if cpp.has_header(f) + config_h.set( + 'HAVE_@0@'.format(f.to_upper().underscorify()), 1, + description : 'Define to 1 if you have the `<@0@>` header file..'.format(f)) + endif +endforeach + + +# TODO: this was carried over from the autotools buildsystem, +# but i think it may no longer be needed. + +# compiler check for dirent.h +#-------------------------------------------------- +dirent_h_prefix = ''' + #include + #include +''' + +check_struct_dirent = meson.get_compiler('cpp').has_member( + 'struct dirent', 'd_type', prefix: dirent_h_prefix) + +if ((config_h.get('HAVE_DIRENT_H') == 1) and (check_struct_dirent)) + config_h.set('HAVE_STRUCT_DIRENT_D_TYPE', 1) +endif diff --git a/dependencies/libgit2/meson.build b/dependencies/libgit2/meson.build new file mode 100644 index 00000000000..913be23babe --- /dev/null +++ b/dependencies/libgit2/meson.build @@ -0,0 +1,11 @@ +# libgit2 Dependency File +#============================================================================ + + +# FIXME !! lowdown is seemingly a required dependency for building, but +# it isn't listed anywhere on documentation that i could find. dependency +# object needs to be added to meson. + +# Look for lowdown, a required dependency +#-------------------------------------------------- +libgit_dep = dependency('libgit2') diff --git a/dependencies/lowdown/meson.build b/dependencies/lowdown/meson.build new file mode 100644 index 00000000000..c18b185ff60 --- /dev/null +++ b/dependencies/lowdown/meson.build @@ -0,0 +1,11 @@ +# lowdown Dependency File +#============================================================================ + + +# FIXME !! lowdown is seemingly a required dependency for building, but +# it isn't listed anywhere on documentation that i could find. dependency +# object needs to be added to meson. + +# Look for lowdown, a required dependency +#-------------------------------------------------- +liblowdown_dep = dependency('lowdown') diff --git a/dependencies/meson.build b/dependencies/meson.build new file mode 100644 index 00000000000..2c41c29f70b --- /dev/null +++ b/dependencies/meson.build @@ -0,0 +1,48 @@ +# nix Dependencies +#============================================================================ + + +# declare dependency types +#--------------------------------------------------- +required_dep_dirs = [ + 'archive', + 'boost', + 'brotli', + 'cpuid', + 'curl', + 'dl', + 'editline', + 'lowdown', + 'libgit2', + 'nlohmann-json', + 'openssl', + 'pthread', + 'rapidcheck', + 'seccomp', + 'sqlite', + 'toml11'] + +optional_dep_dirs = [ + 'aws-sdk-cpp', + 'bdw-gc', + 'gtest', + 'sodium'] + +check_dirs = [ + 'functions', + 'headers'] + + +# Build dependencies +#--------------------------------------------------- +foreach dir : required_dep_dirs + subdir(dir) +endforeach + +foreach dir : optional_dep_dirs + subdir(dir) +endforeach + +foreach dir : check_dirs + subdir(dir) +endforeach diff --git a/dependencies/nlohmann-json/meson.build b/dependencies/nlohmann-json/meson.build new file mode 100644 index 00000000000..59c840d51e7 --- /dev/null +++ b/dependencies/nlohmann-json/meson.build @@ -0,0 +1,8 @@ +# Nlohmann JSON Dependency File +#============================================================================ + + +# Look for nlohmann json, a required dependency +#-------------------------------------------------- +nlohmann_dep = declare_dependency( + dependencies: dependency('nlohmann_json')) diff --git a/dependencies/openssl/meson.build b/dependencies/openssl/meson.build new file mode 100644 index 00000000000..128f0cb422c --- /dev/null +++ b/dependencies/openssl/meson.build @@ -0,0 +1,14 @@ +# OpenSSL Dependency File +#============================================================================ + + +# Look for OpenSSL, a required dependency +#-------------------------------------------------- +openssl_dep = dependency('openssl') + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_OPENSSL', 1, + description : 'Define if the OpenSSL library is available.') diff --git a/dependencies/pthread/meson.build b/dependencies/pthread/meson.build new file mode 100644 index 00000000000..7b4f7b6c849 --- /dev/null +++ b/dependencies/pthread/meson.build @@ -0,0 +1,7 @@ +# pthread Dependency File +#============================================================================ + + +# Look for pthread, a required dependency +#-------------------------------------------------- +pthread_dep = dependency('threads') diff --git a/dependencies/rapidcheck/meson.build b/dependencies/rapidcheck/meson.build new file mode 100644 index 00000000000..ebfef5cb88b --- /dev/null +++ b/dependencies/rapidcheck/meson.build @@ -0,0 +1,24 @@ +# rapidcheck Dependency File +#======================================================================== + + +# First, attempt to find rapidcheck automatically: +rapidcheck_dep = dependency('rapidcheck', required : false) + +# If not found, fallback to manual decleration +if not rapidcheck_dep.found() + + # fetch rapidcheck location + rapidcheck_dir = get_option('rapidcheck_dir') + + # include rapidcheck directories + rapidcheck_inc = [ + # include_directories(join_paths(rapidcheck_dir, 'extras', 'gtest', 'include')), + include_directories(get_option('rapidcheck_headers'))] + + # declare rapidcheck dependency + rapidcheck_dep = declare_dependency( + dependencies : cpp.find_library('rapidcheck'), + include_directories : rapidcheck_inc) +endif + diff --git a/dependencies/seccomp/meson.build b/dependencies/seccomp/meson.build new file mode 100644 index 00000000000..e5dfcd4944f --- /dev/null +++ b/dependencies/seccomp/meson.build @@ -0,0 +1,22 @@ +# OS Specific checks +#============================================================================ + + +# Look for libsecppomp, required for Linux sandboxing +#---------------------------------------------------- +if sys_name == 'linux' + libseccomp_dep = dependency( + 'libseccomp', + version : '>= 2.3.1', + not_found_message : 'Nix requires libseccomp on a linux host system') +else + libseccomp_dep = dependency('', required: false) +endif + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_SECCOMP', + libseccomp_dep.found().to_int(), + description : 'Define if the libseccomp is available.') diff --git a/dependencies/sodium/meson.build b/dependencies/sodium/meson.build new file mode 100644 index 00000000000..ee35b1a968b --- /dev/null +++ b/dependencies/sodium/meson.build @@ -0,0 +1,20 @@ +# LibSodium Dependency File +#============================================================================ + +# FIXME !! sodium is seemingly a required dependency for building, but +# it isn't listed anywhere on documentation that i could find. dependency +# object needs to be added to meson. +# +# 0df69d96e02ce4c9e17bd33333c5d78313341dd3 made it required but docs were not +# updated. + +# look for libsodium, a required dependency +#-------------------------------------------------- +libsodium_dep = cpp.find_library('sodium') + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_SODIUM', 1, + description : 'Whether to use libsodium for cryptography.') diff --git a/dependencies/sqlite/meson.build b/dependencies/sqlite/meson.build new file mode 100644 index 00000000000..584f16c5a3b --- /dev/null +++ b/dependencies/sqlite/meson.build @@ -0,0 +1,16 @@ +# SQLite Dependency File +#============================================================================ + + +# Look for sqlite3, a required dependency +#-------------------------------------------------- +sqlite3_dep = declare_dependency( + dependencies: cpp.find_library('sqlite3'), + version : '>= 3.6.19') + + +# set config variable(s) +#-------------------------------------------------- +config_h.set( + 'HAVE_SQLITE', 1, + description : 'Define if the SQLite3 is available.') diff --git a/dependencies/toml11/meson.build b/dependencies/toml11/meson.build new file mode 100644 index 00000000000..4f0c4abd527 --- /dev/null +++ b/dependencies/toml11/meson.build @@ -0,0 +1,14 @@ +# toml Dependency File +#======================================================================== + + +# First, attempt to find toml automatically: +toml11_dep = dependency('toml11', required : false) + +# If not found, fallback to manual decleration +if not toml11_dep.found() + toml_proj = cmake.subproject('toml11') + gtest_dep = gtest_proj.get_variable('gtest_main_dep') + gmock_dep = gtest_proj.get_variable('gmock_dep') +endif + diff --git a/doc/manual/meson.build b/doc/manual/meson.build new file mode 100644 index 00000000000..7421eae5799 --- /dev/null +++ b/doc/manual/meson.build @@ -0,0 +1,74 @@ +# Nix Manual +#============================================================================ + + +doc_manual_inc = [include_directories('.')] +doc_manual_dir = meson.current_source_dir() + +if get_option('doc_generate').allowed() + + # Provide a dummy environment for nix, so that it will not access files outside the macOS sandbox. + dummy_env = [ + 'HOME=/dummy', + 'NIX_CONF_DIR=/dummy', + 'NIX_SSL_CERT_FILE=/dummy/no-ca-bundle.crt', + 'NIX_STATE_DIR=/dummy', + ] + + foreach dir : ['src'] + subdir(dir) + endforeach + + # generate the web version of the manual + #--------------------------------------------------- + + custom_target( + 'index.html', + input: src_markdown_files + [ + summary_dot_md, + new_cli, + conf_file_dot_md, + builtins_dot_md, + ] + files( + 'book.toml', + 'custom.css', + join_paths('theme', 'highlight.js'), + ), + output: 'manual', + command: [ + 'mdbook', + 'build', + meson.current_build_dir(), + '-d', + 'manual', + ], + env: ['RUST_LOG=warn'], + install: true, + install_dir: docdir, + build_by_default: true, + ) + +endif + +# targets +#============================================================================ + +# nix generators +#--------------------------------------------------- +nix_generator_conf = configuration_data() +nix_generator_conf.set('localstatedir', localstatedir) +nix_generator_conf.set('coreutils', coreutils) + + + +# build +#============================================================================ + + + +# # install scripts +# #--------------------------------------------------- +# install_data( +# scripts_data, +# install_mode : 'rwxr-xr-x', +# install_dir : profiledir) diff --git a/doc/manual/misc/generate-manpage/meson.build b/doc/manual/misc/generate-manpage/meson.build new file mode 100644 index 00000000000..94387ade0ef --- /dev/null +++ b/doc/manual/misc/generate-manpage/meson.build @@ -0,0 +1,12 @@ +# Nix Manual Generate-Manpage +#============================================================================ + + +# configure generate-manpage.nix.gen.hh +#--------------------------------------------------- +generate_manpage_nix = custom_target( + 'generate-manpage.nix', + output : 'generate-manpage.nix.gen.hh', + input : 'generate-manpage.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + \ No newline at end of file diff --git a/doc/manual/misc/meson.build b/doc/manual/misc/meson.build new file mode 100644 index 00000000000..7bb380cdc9d --- /dev/null +++ b/doc/manual/misc/meson.build @@ -0,0 +1,14 @@ +# Nix Manual Misc +#============================================================================ + + + + +# configure utils.nix.gen.hh +#--------------------------------------------------- +utils_nix = custom_target( + 'utils.nix.gen.hh', + output : 'utils.nix.gen.hh', + input : 'utils.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + \ No newline at end of file diff --git a/doc/manual/misc/utils/meson.build b/doc/manual/misc/utils/meson.build new file mode 100644 index 00000000000..1d642357638 --- /dev/null +++ b/doc/manual/misc/utils/meson.build @@ -0,0 +1,11 @@ +# Nix Manual Misc +#============================================================================ + +# configure utils.nix.gen.hh +#--------------------------------------------------- +utils_nix = custom_target( + 'utils.nix.gen.hh', + output : 'utils.nix.gen.hh', + input : 'utils.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + \ No newline at end of file diff --git a/doc/manual/src/command-ref/meson.build b/doc/manual/src/command-ref/meson.build new file mode 100644 index 00000000000..4ea499a5e30 --- /dev/null +++ b/doc/manual/src/command-ref/meson.build @@ -0,0 +1,160 @@ +doc_manual_src_command_ref_src = meson.current_source_dir() + +# generate `doc/manual/src/command-ref/new-cli` +#============================================================================ + +nix_dot_json = custom_target( + 'nix.json', + output: 'nix.json', + command: [ + nix_bin, + '__dump-args', + ], + capture: true, + env: dummy_env, + install: true, + install_dir: mandir, + build_by_default: true, +) + +new_cli = custom_target( + 'new-cli', + input: [ + nix_bin, + nix_dot_json, + join_paths(doc_manual_dir, 'generate-manpage.nix'), + ], + output: 'new-cli', + command: [ + find_program( + 'write-new-cli.sh', + dirs: [join_paths(scripts_dir, 'manual')], + ), + '@INPUT@', + '@OUTPUT@', + ], + env: dummy_env, + install: true, + install_dir: mandir, + build_by_default: true, +) + +# generate `doc/manual/src/command-ref/conf-file.md` +#============================================================================ + +conf_file_dot_json = custom_target( + 'conf-file.json', + output: 'conf-file.json', + command: [ + nix_bin, + 'show-config', + '--json', + '--experimental-features', + 'nix-command', + ], + capture: true, + env: dummy_env, + install: true, + install_dir: mandir, + build_by_default: true, +) + +conf_file_dot_md = custom_target( + 'conf-file.md', + input: [ + nix_bin, + conf_file_dot_json, + join_paths(doc_manual_dir, 'generate-options.nix') + ] + files( + 'conf-file-prefix.md' + ), + output: 'conf-file.md', + command: [ + find_program( + 'write-conf-file.sh', + dirs: [join_paths(scripts_dir, 'manual')], + ), + '@INPUT@', + ], + capture: true, + install: true, + install_dir: mandir, + build_by_default: true, +) + +# man pages +#============================================================================ + +prepend_title = generator( + find_program( + 'prepend-title-to-manpage.sh', + dirs: [join_paths(scripts_dir, 'manual')], + ), + arguments: ['@BASENAME@', '@EXTRA_ARGS@', '@INPUT@'], + capture: true, + output: '@BASENAME@.tmp', +) + +man_pages = { + '1': [ + 'nix-env', + 'nix-build', + 'nix-shell', + 'nix-store', + 'nix-instantiate', + 'nix-collect-garbage', + 'nix-prefetch-url', + 'nix-channel', + 'nix-hash', + 'nix-copy-closure', + ], + '8': [ + 'nix-daemon', + ] +} + +foreach section, pages : man_pages + foreach page : pages + man_dst = '@0@.@1@'.format(page, section) + man_src = files('@0@.md'.format(page)) + + custom_target( + man_dst, + input: prepend_title.process(man_src, extra_args: [section]), + output: man_dst, + command: [ + 'lowdown', + '-sT', + 'man', + '-M section=@0@'.format(section), + '@INPUT@', + '-o', + '@OUTPUT@' + ], + install: true, + install_dir: mandir, + build_by_default: true, + ) + endforeach +endforeach + +custom_target( + 'nix.conf.5', + input: prepend_title.process( + conf_file_dot_md, + extra_args: ['5'] + ), + output: 'nix.conf.5', + command: [ + 'lowdown', + '-sT', + 'man', + '-M section=5', + '@INPUT@', + '-o', + '@OUTPUT@', + ], + install: true, + install_dir: mandir, + build_by_default: true, +) diff --git a/doc/manual/src/language/meson.build b/doc/manual/src/language/meson.build new file mode 100644 index 00000000000..8eaf159a5c9 --- /dev/null +++ b/doc/manual/src/language/meson.build @@ -0,0 +1,42 @@ +doc_manual_src_expressions_dir = meson.current_source_dir() + +# Generate `doc/manual/src/expressions/builtins.md` +#============================================================================ + +builtins_dot_json = custom_target( + 'builtins.json', + output: 'builtins.json', + command: [ + nix_bin, + '__dump-builtins', + ], + capture: true, + env: dummy_env + ['NIX_PATH=nix/corepkgs=corepkgs'], + install: true, + install_dir: mandir, + build_by_default: true, +) + +builtins_dot_md = custom_target( + 'builtins.md', + input: [ + nix_bin, + builtins_dot_json, + join_paths(doc_manual_dir, 'generate-builtins.nix') + ] + files( + 'builtins-prefix.md', + 'builtins-suffix.md', + ), + output: 'builtins.md', + command: [ + find_program( + 'write-builtins.sh', + dirs: [join_paths(scripts_dir, 'manual')], + ), + '@INPUT@', + ], + capture: true, + install: true, + install_dir: mandir, + build_by_default: true, +) diff --git a/doc/manual/src/meson.build b/doc/manual/src/meson.build new file mode 100644 index 00000000000..18b7c5c6482 --- /dev/null +++ b/doc/manual/src/meson.build @@ -0,0 +1,34 @@ +doc_manual_src_dir = meson.current_source_dir() + +nix_manual_dirs = [ + # 'command-ref', + # 'expressions' +] + +foreach dir : nix_manual_dirs + subdir(dir) +endforeach + +# generate `doc/manual/src/SUMMARY.md` +#============================================================================ + +summary_dot_md = custom_target( + 'SUMMARY.md', + input: [ + join_paths(doc_manual_dir, 'src', 'SUMMARY.md.in'), + new_cli, + ], + output: 'SUMMARY.md', + command: [ + find_program( + 'write-summary.sh', + dirs: [join_paths(scripts_dir, 'manual')], + ), + '@INPUT@', + ], + capture: true, + install: true, + install_dir: mandir, + build_by_default: true, +) + diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 00000000000..fe2b561173c --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,11 @@ +# Nix Documentation +#============================================================================ + +doc_dirs = [ + # 'internal-api', + 'manual'] + + +foreach dir : doc_dirs + subdir(dir) +endforeach diff --git a/meson.build b/meson.build new file mode 100644 index 00000000000..a5f5e3ec325 --- /dev/null +++ b/meson.build @@ -0,0 +1,241 @@ +# Nix project build file +#============================================================================ + + +# init +#============================================================================ + + +# init project +#------------------------------------------------- +project( + 'nix', + 'cpp', + meson_version : '>= 0.61.0', + default_options : [ + 'cpp_std=c++20', + 'warning_level=3', + 'optimization=3', + 'debug=true' + ], + version : files('.version'), + license : 'MIT') + + +# init compiler +#------------------------------------------------- +cpp = meson.get_compiler('cpp') + +add_project_arguments(get_option('cxxflags'), language : 'cpp') +add_project_link_arguments(get_option('ldflags'), language: 'cpp') + +if(get_option('optimization') == '0') + add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c']) + message('Disabling FORTIFY_SOURCE as optimization is set to 0') +endif + + +# init configuration +#------------------------------------------------- +config_h = configuration_data() + +config_h.set( + 'HAVE_CXX17', 1, + description : 'Define if the compiler supports basic C++17 syntax') + +package_name = meson.project_name() +config_h.set_quoted( + 'PACKAGE_NAME', package_name, + description : 'Define to the full name of this package.' + ) + +package_tarname = meson.project_name() +config_h.set_quoted( + 'PACKAGE_TARNAME', package_tarname, + description : 'Define to the one symbol short name of this package.') + +package_version = meson.project_version() +config_h.set_quoted( + 'PACKAGE_VERSION', package_version, + description : 'Define to the version of this package.') + +package_string = '@0@ @1@'.format(package_name, package_version) +config_h.set_quoted( + 'PACKAGE_STRING', package_string, + description : 'Define to the full name and version of this package.') + +package_url = 'https://nixos.org/nix/' +config_h.set_quoted( + 'PACKAGE_URL', package_url, + description : 'Define to the home page for this package.') + +package_bug_url = 'https://github.com/nixos/nix/issues' +config_h.set_quoted( + 'PACKAGE_BUGREPORT', package_bug_url, + description : 'Define to the address where bug reports for this package should be sent.') + + +# env +#============================================================================ + + +# set install directories +#------------------------------------------------- +prefix = get_option('prefix') +libdir = join_paths(prefix, get_option('libdir')) +bindir = join_paths(prefix, get_option('bindir')) +datadir = join_paths(prefix, get_option('datadir')) +sysconfdir = join_paths(prefix, get_option('sysconfdir')) +libexecdir = join_paths(prefix, get_option('libexecdir')) +mandir = join_paths(prefix, get_option('mandir')) +docdir = join_paths(prefix, get_option('docdir')) +includedir = join_paths(prefix, get_option('includedir')) + +# set nix directories +#------------------------------------------------- + +# State should be stored in /nix/var, unless the user overrides it explicitly. +if get_option('normal_var') + localstatedir = '/nix/var' +else + localstatedir = join_paths(prefix, get_option('localstatedir')) +endif + +nixstoredir = get_option('nixstoredir') + +profiledir = join_paths(sysconfdir, 'profile.d') + + +# Construct a Nix system name (like "i686-linux"). +#------------------------------------------------- +machine_name = host_machine.cpu() +sys_name = host_machine.system().to_lower() + +cpu_archs = ['x86_64', 'armv6', 'armv7', ''] + +foreach cpu : cpu_archs + if host_machine.cpu().contains(cpu) + if cpu.contains('armv') + machine_name = cpu + '1' + else + machine_name = cpu + endif + break + endif +endforeach + +system= '"' + machine_name + '-' + sys_name + '"' +message('system name: ' + system) +config_h.set( + 'SYSTEM', system, + description : 'platform identifier (`cpu-os`)') + + +# required dependencies +#============================================================================ + + +# look for required programs +#-------------------------------------------------- +cat = find_program('cat', required : true) +ln = find_program('ln', required : true) +cp = find_program('cp', required : true) +rm = find_program('rm', required : true) +bash = find_program('bash', required : true) +echo = find_program('echo', required : true) +patch = find_program('patch', required : true) +flex = find_program('flex', required : true) +bison = find_program('bison', required : true) +sed = find_program('sed', required : true) +tar = find_program('tar', required : true) +bzip2 = find_program('bzip2', required : true) +gzip = find_program('gzip', required : true) +xz = find_program('xz', required : true) +dot = find_program('dot', required : false) +lsof = find_program('lsof', required : false) +tr = find_program('tr', required : true) +tr = find_program('jq', required : true) +coreutils = run_command('dirname', cat.full_path()).stdout().strip() + +# Import meson modules +#-------------------------------------------------- +find_program('cmake', required : false) +cmake = import('cmake') + +find_program('pkgconfig', required : false) +pkgconfig = import('pkgconfig') + +# Check whether the store optimiser can optimise symlinks. +#------------------------------------------------- +gen_header = ''' +ln -s bla tmp_link +if ln tmp_link tmp_link2 2> /dev/null; then + echo 1 +else + echo 0 +fi +''' + +run_command('sh', '-c', 'rm tmp_link*') +can_link_symlink = run_command('sh', '-c', gen_header).stdout().strip() +if can_link_symlink.to_int() == 1 + run_command('sh', '-c', 'rm tmp_link*') +endif + +config_h.set( + 'CAN_LINK_SYMLINK', can_link_symlink, + description : 'Whether link() works on symlinks') + + +# OS Specific checks +#============================================================================ + + +# freebsd requires _GNU_SOURCE flag +#--------------------------------------------------- +if sys_name == 'freebsd' + add_project_arguments('-D_GNU_SOURCE', language : 'cpp') + config_h.set('_GNU_SOURCE', 1) +endif + + +# Builing for Darwin requires XMLlint +#--------------------------------------------------- +if sys_name == 'Darwin' + xmllint = find_program('xmllint', required : true) +endif + + +# Solaris requires -lsocket -lnsl for network functions +#--------------------------------------------------- +if sys_name == 'sunos' + add_project_arguments('-lsocket', language : 'cpp') + add_project_arguments('-lnsl', language : 'cpp') +endif + + + + +# build +#============================================================================ + + +proj_inc = [include_directories('.')] + +# build nix +#--------------------------------------------------- +project_dirs = [ + 'dependencies', + 'misc', + # 'doc', + 'nix', + + # 'scripts', + # 'misc', + 'tests', +] + + +foreach dir : project_dirs + subdir(dir) +endforeach diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000000..ed4b420ef2a --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,147 @@ +# Nix project build options +#============================================================================ + +# dirs +#============================================================================ + +option( + 'nixstoredir', + type : 'string', + value : '/nix/store', + description : 'path of the Nix store (defaults to /nix/store)') + +option( + 'profiledir', + type : 'string', + value : '/etc/profile.d', + description : 'path of the Nix store (defaults to /nix/store)') + +option( + 'docdir', + type : 'string', + value : 'share/doc', + description : 'Documentation location path') + +# option( +# 'mandir', +# type : 'string', +# value : 'share/man', +# description : 'Man pages location path') + + +# compiler args +#============================================================================ + +option( + 'ldflags', + type : 'array', + value : [ + '-L/usr/local/lib', + '-L/usr/lib', + '-L/lib'], + description : 'Link flags') + + +option( + 'cxxflags', + type : 'array', + value : [ + '-Wno-pedantic', + '-Wno-non-virtual-dtor', + '-Wno-unused-parameter', + '-Wno-variadic-macros', + '-Wdeprecated-declarations', + '-Wno-missing-field-initializers', + ], + description : 'C build flags') + + +# location of rapidcheck install +#============================================================================ +option( + 'rapidcheck_dir', + type : 'string', + value : '/usr/lib', + description : 'path to rapidcheck') + +option( + 'rapidcheck_headers', + type : 'string', + value : '/usr/include/rapidcheck', + description : 'path to rapidcheck') + + +# location of aws_sdk_cpp install +#============================================================================ +# FIXME: this isnt correct. Meson MUST find these dependencies itself to +# allow for potability. hardcoding for now. +option( + 'aws_sdk_cpp_include_dir', + type : 'string', + value : '/usr/lib', + description : 'path to aws_sdk_cpp includes') +option( + 'aws_sdk_cpp_lib_dir', + type : 'string', + value : '/usr/lib', + description : 'path to aws_sdk_cpp libs') + + +# optional dependencies +#============================================================================ + +option( + 'gc', + type : 'feature', + value : 'auto', + description : 'Build nix with Boehm garbage collector') + +option( + 's3', + type : 'feature', + value : 'auto', + description : 'Build nix with s3') + +option( + 'coreutils_bin', + type : 'string', + description : 'path of cat, mkdir, etc.') + +option( + 'nix_perl', + type : 'feature', + value : 'enabled', + description : 'Build nix with nix-perl') + +# misc +#============================================================================ +option( + 'doc_generate', + type : 'feature', + value : 'enabled', + description : 'Build the documentation and manpages') + +option( + 'build_shared_libs', + type : 'boolean', + value : 'false', + description : 'Build nix with shared libs') + +option( + 'sandbox_shell', + type : 'string', + value : '/usr/bin/busybox', + description : 'path of a statically-linked shell to use as /bin/sh in sandboxes') + +option( + 'normal_var', + type : 'boolean', + value : 'true', + description : 'Whether to use `/nix/var` or the user-overridable `localstatedir`.') + +option( + 'PRECOMPILE_HEADERS', + type : 'boolean', + value : 'true', + description : 'Whether to use precompiled headers.') + diff --git a/misc/config_h/meson.build b/misc/config_h/meson.build new file mode 100644 index 00000000000..2fa51bd5b4d --- /dev/null +++ b/misc/config_h/meson.build @@ -0,0 +1,27 @@ +# include.config_h build file +#======================================================================== + +# generate headers +#======================================================================== + +# build config.h +#--------------------------------------------------- +config_h = configure_file( + #input : 'config.h.in', + output : 'config.h', + configuration : config_h) + +add_project_arguments('-include', 'config.h', language : 'cpp') + + +# install headers +#--------------------------------------------------- +install_headers( + config_h, + install_dir : join_paths(includedir, 'nix')) + + +# include directories +#======================================================================== + +proj_inc += include_directories('.') diff --git a/misc/macros/meson.build b/misc/macros/meson.build new file mode 100644 index 00000000000..fc98a71a8e1 --- /dev/null +++ b/misc/macros/meson.build @@ -0,0 +1,11 @@ +# include.macros file +#======================================================================== + + +# macro used to generate R headers +#--------------------------------------------------- +gen_rheader = ''' + echo 'R"foo(' >> "$1" + cat @INPUT@ >> "$1" + echo ')foo"' >> "$1" +''' diff --git a/misc/meson.build b/misc/meson.build new file mode 100644 index 00000000000..4549ac58dab --- /dev/null +++ b/misc/meson.build @@ -0,0 +1,19 @@ +# Nix Misc +#======================================================================== + +include_dir = meson.current_source_dir() +proj_inc += include_directories('.') + +# include directories +#======================================================================== + + +include_dirs = [ + 'config_h', + 'precompiled_headers_h', + 'macros'] + + +foreach dir : include_dirs + subdir(dir) +endforeach diff --git a/misc/precompiled_headers_h/meson.build b/misc/precompiled_headers_h/meson.build new file mode 100644 index 00000000000..25601c776bf --- /dev/null +++ b/misc/precompiled_headers_h/meson.build @@ -0,0 +1,23 @@ +# Nix Misc.precompiled_headers_h +#======================================================================== + +# generate headers +#======================================================================== + +# build config.h +#--------------------------------------------------- + +# add_project_arguments('-include', 'precompiled-headers.h', language : 'cpp') + + +# install headers +#--------------------------------------------------- +# install_headers( +# config_h, +# install_dir : join_paths(includedir, 'nix')) + + +# include directories +#======================================================================== + +proj_inc += include_directories('.') diff --git a/nix/libcmd/meson.build b/nix/libcmd/meson.build new file mode 100644 index 00000000000..7edf76f7c07 --- /dev/null +++ b/nix/libcmd/meson.build @@ -0,0 +1 @@ +subdir('src') \ No newline at end of file diff --git a/nix/libcmd/src/meson.build b/nix/libcmd/src/meson.build new file mode 100644 index 00000000000..6132f1ad285 --- /dev/null +++ b/nix/libcmd/src/meson.build @@ -0,0 +1,93 @@ +# libcmd build file +#============================================================================ + +libcmd_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +libcmd_dep_list = [ + gc_dep, + editline_dep, + libsodium_dep, + liblowdown_dep, + nlohmann_dep, + openssl_dep, + pthread_dep, + + libutil_dep, + libmain_dep, + libstore_dep, + libexpr_dep, + libfetchers_dep] + + +# src files +#============================================================================ + +libcmd_src = files( + 'built-path.cc', + 'command.cc', + 'command-installable-value.cc', + 'common-eval-args.cc', + 'editor-for.cc', + 'installable-attr-path.cc', + 'installable-derived-path.cc', + 'installable-flake.cc', + 'installables.cc', + 'installable-value.cc', + 'legacy.cc', + 'markdown.cc', + 'misc-store-flags.cc', + 'repl.cc') + +libcmd_headers = files( + 'built-path.hh', + 'command.hh', + 'command-installable-value.hh', + 'common-eval-args.hh', + 'editor-for.hh', + 'installable-attr-path.hh', + 'installable-derived-path.hh', + 'installable-flake.hh', + 'installables.hh', + 'installable-value.hh', + 'legacy.hh', + 'markdown.hh', + 'misc-store-flags.hh', + 'repl.hh') + +# set build args +#--------------------------------------------------- +nix_cxx_args = [] +libcmd_cxx_args = [] + +nix_link_args = [] +libcmd_link_args = [] + +# build library +#--------------------------------------------------- +libcmd_lib = library( + 'nixcmd', + sources : libcmd_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : [ + libcmd_inc, + proj_inc], + cpp_args : libcmd_cxx_args, + link_args : libcmd_link_args, + dependencies : libcmd_dep_list) + +# install headers +#--------------------------------------------------- +install_headers( + libcmd_headers, + install_dir : join_paths(includedir, 'nix')) + +# declare dependency +#--------------------------------------------------- +libcmd_dep = declare_dependency( + link_with : libcmd_lib, + include_directories : libcmd_inc) diff --git a/nix/libexpr/meson.build b/nix/libexpr/meson.build new file mode 100644 index 00000000000..3e34bf616ca --- /dev/null +++ b/nix/libexpr/meson.build @@ -0,0 +1,2 @@ +subdir('misc') +subdir('src') \ No newline at end of file diff --git a/nix/libexpr/misc/fetchurl/meson.build b/nix/libexpr/misc/fetchurl/meson.build new file mode 100644 index 00000000000..815c2498f89 --- /dev/null +++ b/nix/libexpr/misc/fetchurl/meson.build @@ -0,0 +1,10 @@ +# libexpr fetchurl +#============================================================================ + +# generate fetchurl.nix.gen.hh +#--------------------------------------------------- +fetchurl_nix_gen_hh = custom_target( + 'fetchurl.nix.gen.hh', + output : 'fetchurl.nix.gen.hh', + input : 'fetchurl.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/libexpr/misc/imported-drv-to-derivation/meson.build b/nix/libexpr/misc/imported-drv-to-derivation/meson.build new file mode 100644 index 00000000000..d170ca89d78 --- /dev/null +++ b/nix/libexpr/misc/imported-drv-to-derivation/meson.build @@ -0,0 +1,10 @@ +# libexpr imported-drv-to-derivation +#============================================================================ + +# generate imported-drv-to-derivation.nix.gen.hh +#--------------------------------------------------- +imported_drv_to_derivation_nix_gen_hh = custom_target( + 'imported-drv-to-derivation.nix.gen.hh', + output : 'imported-drv-to-derivation.nix.gen.hh', + input : 'imported-drv-to-derivation.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/libexpr/misc/meson.build b/nix/libexpr/misc/meson.build new file mode 100644 index 00000000000..19711768b26 --- /dev/null +++ b/nix/libexpr/misc/meson.build @@ -0,0 +1,2 @@ +subdir('fetchurl') +subdir('imported-drv-to-derivation') \ No newline at end of file diff --git a/nix/libexpr/src/flake/meson.build b/nix/libexpr/src/flake/meson.build new file mode 100644 index 00000000000..9563c36c7a4 --- /dev/null +++ b/nix/libexpr/src/flake/meson.build @@ -0,0 +1,28 @@ +# Nix lib expr build file +#============================================================================ + + +# src files +#============================================================================ + +libexpr_inc += include_directories('.') + +libexpr_src += files( + 'config.cc', + 'flake.cc', + 'flakeref.cc', + 'lockfile.cc') + +libexpr_headers += files( + 'flake.hh', + 'flakeref.hh', + 'lockfile.hh') + +# targets +#============================================================================ + +libexpr_src += custom_target( + 'call-flake.nix.gen.hh', + output : 'call-flake.nix.gen.hh', + input : 'call-flake.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/libexpr/src/meson.build b/nix/libexpr/src/meson.build new file mode 100644 index 00000000000..6932f82f296 --- /dev/null +++ b/nix/libexpr/src/meson.build @@ -0,0 +1,175 @@ +# Nix libexpr +#============================================================================ + + +# dependencies +#============================================================================ + +libexpr_dep_list = [ + boost_dep, + libdl_dep, + libsodium_dep, + gc_dep, + toml11_dep, + + libutil_dep, + libstore_dep, + libmain_dep, + libfetchers_dep] + + +# src files +#============================================================================ + +libexpr_src = files( + 'attr-path.cc', + 'attr-set.cc', + 'eval-cache.cc', + 'eval.cc', + 'eval-error.cc', + 'eval-settings.cc', + 'function-trace.cc', + 'get-drvs.cc', + 'json-to-value.cc', + 'nixexpr.cc', + 'paths.cc', + 'primops.cc', + 'print-ambiguous.cc', + 'print.cc', + 'search-path.cc', + 'value-to-json.cc', + 'value-to-xml.cc') + +libexpr_headers = files( + 'attr-path.hh', + 'attr-set.hh', + 'eval-cache.hh', + 'eval-error.hh', + 'eval.hh', + 'eval-inline.hh', + 'eval-settings.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.hh', + 'print-options.hh', + 'repl-exit-status.hh', + 'search-path.hh', + 'symbol-table.hh', + 'value.hh', + 'value-to-json.hh', + 'value-to-xml.hh') + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libexpr_inc = [include_directories('.')] + +# add subdirectories +#--------------------------------------------------- +libexpr_dirs = [ + 'flake', + 'primops', + 'value'] + +foreach dir : libexpr_dirs + subdir(dir) +endforeach + + +# targets +#============================================================================ + +libexpr_src += custom_target( + 'parser_tab.[cchh]', + output : [ + 'parser-tab.cc', + 'parser-tab.hh'], + input : 'parser.y', + command : [ + bison, + '-v', + '--output=@OUTPUT0@', + '--defines=@OUTPUT1@', + '@INPUT@']) + +libexpr_src += custom_target( + 'lexer_tab.[cchh]', + output : ['lexer-tab.cc', 'lexer-tab.hh'], + input : 'lexer.l', + command : [ + flex, + '--outfile=@OUTPUT0@', + '--header-file=@OUTPUT1@', + '@INPUT@']) + +libexpr_src += [ + +] + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libexpr_cxx_args = [] + +libexpr_link_args = [] + + +# build library +#--------------------------------------------------- +libexpr_lib = library( + 'nixexpr', + sources : [ + libexpr_src, + imported_drv_to_derivation_nix_gen_hh, + fetchurl_nix_gen_hh], + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : [ + libexpr_inc, + proj_inc, + ], + cpp_args : libexpr_cxx_args, + link_args : libexpr_link_args, + dependencies : libexpr_dep_list) + +# install headers +#--------------------------------------------------- +install_headers( + libexpr_headers, + install_dir : join_paths(includedir, 'nix')) + + +# generate pkg-config +#--------------------------------------------------- +# libexpr_config = pkgconfig.generate( +# libexpr_lib, +# libraries : [ +# libstore_lib], +# version : meson.project_version(), +# name : 'Nix', +# subdirs : ['nix/'], +# filebase : 'nix-expr', +# extra_cflags : '-std=c++17', +# description : 'Nix Package Manager.') + + +# declare dependency +#--------------------------------------------------- +libexpr_dep = declare_dependency( + link_with : libexpr_lib, + include_directories : include_directories('.')) diff --git a/nix/libexpr/src/primops/fetchTree.cc b/nix/libexpr/src/primops/fetchTree.cc index 5061e40fdf2..d72b86c3108 100644 --- a/nix/libexpr/src/primops/fetchTree.cc +++ b/nix/libexpr/src/primops/fetchTree.cc @@ -1,4 +1,4 @@ -#include "libfetchers/attrs.hh" +#include "attrs.hh" #include "primops.hh" #include "eval-inline.hh" #include "eval-settings.hh" diff --git a/nix/libexpr/src/primops/fromTOML.cc b/nix/libexpr/src/primops/fromTOML.cc index 94be7960a06..07f0b9c1173 100644 --- a/nix/libexpr/src/primops/fromTOML.cc +++ b/nix/libexpr/src/primops/fromTOML.cc @@ -1,7 +1,7 @@ #include "primops.hh" #include "eval-inline.hh" -#include "../../toml11/toml.hpp" +#include "toml.hpp" #include diff --git a/nix/libexpr/src/primops/meson.build b/nix/libexpr/src/primops/meson.build new file mode 100644 index 00000000000..25f805d6162 --- /dev/null +++ b/nix/libexpr/src/primops/meson.build @@ -0,0 +1,24 @@ +# Nix lib expr build file +#============================================================================ + + +# src files +#============================================================================ + +libexpr_inc += include_directories('.') + +libexpr_src += files( + 'context.cc', + 'fetchClosure.cc', + 'fetchMercurial.cc', + 'fetchTree.cc', + 'fromTOML.cc') + +# targets +#============================================================================ + +libexpr_src += custom_target( + 'derivation.nix.gen.hh', + output : 'derivation.nix.gen.hh', + input : 'derivation.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/libexpr/src/value/meson.build b/nix/libexpr/src/value/meson.build new file mode 100644 index 00000000000..c954c0a97e8 --- /dev/null +++ b/nix/libexpr/src/value/meson.build @@ -0,0 +1,14 @@ +# libexpr/value build file +#============================================================================ + + +# src files +#============================================================================ + +libexpr_inc += include_directories('.') + +libexpr_src += files( + 'context.cc') + +libexpr_headers += files( + 'context.cc') \ No newline at end of file diff --git a/nix/libfetchers/meson.build b/nix/libfetchers/meson.build new file mode 100644 index 00000000000..7edf76f7c07 --- /dev/null +++ b/nix/libfetchers/meson.build @@ -0,0 +1 @@ +subdir('src') \ No newline at end of file diff --git a/nix/libfetchers/src/meson.build b/nix/libfetchers/src/meson.build new file mode 100644 index 00000000000..b67250dad1d --- /dev/null +++ b/nix/libfetchers/src/meson.build @@ -0,0 +1,117 @@ +# libfetchers build file +#============================================================================ + + +# dependencies +#============================================================================ + +libfetchers_dep_list = [ + libcurl_dep, + libdl_dep, + libseccomp_dep, + libsodium_dep, + pthread_dep, + sqlite3_dep, + libgit_dep, + + libutil_dep, + libstore_dep] + + +# src files +#============================================================================ + +libfetchers_src = files( + 'attrs.cc', + 'cache.cc', + 'fetchers.cc', + 'fetch-settings.cc', + 'fetch-to-store.cc', + 'filtering-input-accessor.cc', + 'fs-input-accessor.cc', + 'git.cc', + 'github.cc', + 'git-utils.cc', + 'indirect.cc', + 'memory-input-accessor.cc', + 'mercurial.cc', + 'mounted-input-accessor.cc', + 'path.cc', + 'registry.cc', + 'tarball.cc') + +libfetchers_headers = files( + 'attrs.hh', + 'cache.hh', + 'fetchers.hh', + 'fetch-settings.hh', + 'fetch-to-store.hh', + 'filtering-input-accessor.hh', + 'fs-input-accessor.hh', + 'git-utils.hh', + 'memory-input-accessor.hh', + 'mounted-input-accessor.hh', + 'registry.hh', + 'tarball.hh') + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libfetchers_inc = [include_directories('.')] + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libfetchers_cxx_args = [] + +libfetchers_link_args = [] + + +# build library +#--------------------------------------------------- +libfetchers_lib = library( + 'nixfetchers', + sources : libfetchers_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : [ + libfetchers_inc, + proj_inc], + cpp_args : libfetchers_cxx_args, + link_args : libfetchers_link_args, + dependencies : libfetchers_dep_list) + + +# install headers +#--------------------------------------------------- +install_headers( + libfetchers_headers, + install_dir : join_paths(includedir, 'nix')) + + +# generate pkg-config +#--------------------------------------------------- +libfetchers_config = pkgconfig.generate( + libfetchers_lib, + libraries : [ + libfetchers_lib], + version : meson.project_version(), + name : 'Nix', + subdirs : ['nix/'], + filebase : 'nix-store', + extra_cflags : '-std=c++17', + description : 'Nix Package Manager.') + + +# declare dependency +#--------------------------------------------------- +libfetchers_dep = declare_dependency( + link_with : libfetchers_lib, + include_directories : libfetchers_inc) diff --git a/nix/libmain/meson.build b/nix/libmain/meson.build new file mode 100644 index 00000000000..e7c3258e77b --- /dev/null +++ b/nix/libmain/meson.build @@ -0,0 +1,12 @@ +subdir('src') + + + +# libmain_config = pkgconfig.generate( +# libmain_lib, +# version : meson.project_version(), +# name : 'Nix', +# subdirs : ['nix/'], +# filebase : 'nix-main', +# extra_cflags : '-std=c++17', +# description : 'Nix Package Manager.') diff --git a/nix/libmain/src/meson.build b/nix/libmain/src/meson.build new file mode 100644 index 00000000000..6cce8db32e7 --- /dev/null +++ b/nix/libmain/src/meson.build @@ -0,0 +1,77 @@ +# libmain build file +#============================================================================ + +libmain_inc = [include_directories('.')] + + +# dependencies +#============================================================================ + +libmain_dep_list = [ + pthread_dep, + openssl_dep, + libsodium_dep, + + libutil_dep, + libstore_dep] + + +# src files +#============================================================================ + +libmain_src = files( + 'common-args.cc', + 'loggers.cc', + 'progress-bar.cc', + 'shared.cc', + 'stack.cc') + + +libmain_headers = files( + 'common-args.hh', + 'loggers.hh', + 'progress-bar.hh', + 'shared.hh') + + +# targets +#============================================================================ + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libmain_cxx_args = [] + +libmain_link_args = [] + + +# build library +#--------------------------------------------------- +libmain_lib = library( + 'nixmain', + sources : libmain_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : [ + libmain_inc, + proj_inc], + cpp_args : libmain_cxx_args, + link_args : libmain_link_args, + dependencies : libmain_dep_list) + + +# install headers +#--------------------------------------------------- +install_headers( + libmain_headers, + install_dir : join_paths(includedir, 'nix')) + +# declare dependency +#--------------------------------------------------- +libmain_dep = declare_dependency( + link_with : libmain_lib, + include_directories : libmain_inc) diff --git a/nix/libstore/meson.build b/nix/libstore/meson.build new file mode 100644 index 00000000000..b50a7eb92b7 --- /dev/null +++ b/nix/libstore/meson.build @@ -0,0 +1,13 @@ +subdir('src') + +# libstore_config = pkgconfig.generate( +# libstore_lib, +# libraries : [ +# libutil_lib], +# version : meson.project_version(), +# name : 'Nix', +# subdirs : ['nix/'], +# filebase : 'nix-store', +# extra_cflags : '-std=c++17', +# description : 'Nix Package Manager.') + diff --git a/nix/libstore/src/build/meson.build b/nix/libstore/src/build/meson.build new file mode 100644 index 00000000000..b193f65143c --- /dev/null +++ b/nix/libstore/src/build/meson.build @@ -0,0 +1,38 @@ +# libstore.build build file +#============================================================================ + +libstore_inc += include_directories('.') + + +# src files +#============================================================================ + +libstore_src += files( + 'child.cc', + 'derivation-goal.cc', + 'drv-output-substitution-goal.cc', + 'entry-points.cc', + 'goal.cc', + 'hook-instance.cc', + 'local-derivation-goal.cc', + 'personality.cc', + 'substitution-goal.cc', + 'worker.cc') + + + +libstore_headers += files( + 'child.hh', + 'derivation-goal.hh', + 'drv-output-substitution-goal.hh', + 'goal.hh', + 'hook-instance.hh', + 'local-derivation-goal.hh', + 'personality.hh', + 'substitution-goal.hh', + 'worker.hh') + +libstore_data += files( + 'sandbox-defaults.sb', + 'sandbox-minimal.sb', + 'sandbox-network.sb') diff --git a/nix/libstore/src/builtins/meson.build b/nix/libstore/src/builtins/meson.build new file mode 100644 index 00000000000..d6e68fee0ff --- /dev/null +++ b/nix/libstore/src/builtins/meson.build @@ -0,0 +1,17 @@ +# libstore.builtins build file +#============================================================================ + +libstore_inc += include_directories('.') + + +# src files +#============================================================================ + +libstore_src += files( + 'buildenv.cc', + 'fetchurl.cc', + 'unpack-channel.cc') + + +libstore_headers += files( + 'buildenv.hh') diff --git a/nix/libstore/src/meson.build b/nix/libstore/src/meson.build new file mode 100644 index 00000000000..a6e2e84b25a --- /dev/null +++ b/nix/libstore/src/meson.build @@ -0,0 +1,241 @@ +# libstore build file +#============================================================================ + + +# dependencies +#============================================================================ + +libstore_dep_list = [ + aws_sdk_cpp_dep, + libcurl_dep, + libdl_dep, + libseccomp_dep, + libsodium_dep, + nlohmann_dep, + pthread_dep, + sqlite3_dep, + + + libutil_dep] + + +# src files +#============================================================================ + +libstore_src = files( + 'binary-cache-store.cc', + 'build-result.cc', + 'common-protocol.cc', + 'content-address.cc', + 'daemon.cc', + 'derivations.cc', + 'derived-path.cc', + 'derived-path-map.cc', + 'downstream-placeholder.cc', + 'dummy-store.cc', + 'export-import.cc', + 'filetransfer.cc', + 'gc.cc', + 'globals.cc', + 'http-binary-cache-store.cc', + 'keys.cc', + 'legacy-ssh-store.cc', + 'local-binary-cache-store.cc', + 'local-fs-store.cc', + 'local-store.cc', + 'lock.cc', + 'log-store.cc', + 'machines.cc', + 'make-content-addressed.cc', + 'misc.cc', + 'names.cc', + 'nar-accessor.cc', + 'nar-info.cc', + 'nar-info-disk-cache.cc', + 'optimise-store.cc', + 'outputs-spec.cc', + 'parsed-derivations.cc', + 'path.cc', + 'path-info.cc', + 'pathlocks.cc', + 'path-references.cc', + 'path-with-outputs.cc', + 'posix-fs-canonicalise.cc', + 'profiles.cc', + 'realisation.cc', + 'remote-fs-accessor.cc', + 'remote-store.cc', + 's3-binary-cache-store.cc', + 'serve-protocol.cc', + 'serve-protocol-impl.cc', + 'sqlite.cc', + 'ssh.cc', + 'ssh-store.cc', + 'store-api.cc', + 'uds-remote-store.cc', + 'worker-protocol.cc') + + +libstore_headers = files( + 'binary-cache-store.hh', + 'build-result.hh', + 'builtins.hh', + 'common-protocol.hh', + 'common-protocol-impl.hh', + 'content-address.hh', + 'daemon.hh', + 'derivations.hh', + 'derived-path.hh', + 'derived-path-map.hh', + 'downstream-placeholder.hh', + 'filetransfer.hh', + 'gc-store.hh', + 'globals.hh', + 'indirect-root-store.hh', + 'keys.hh', + 'legacy-ssh-store.hh', + 'length-prefixed-protocol-helper.hh', + 'local-fs-store.hh', + 'local-store.hh', + 'lock.hh', + 'log-store.hh', + 'machines.hh', + 'make-content-addressed.hh', + 'names.hh', + 'nar-accessor.hh', + 'nar-info-disk-cache.hh', + 'nar-info.hh', + 'outputs-spec.hh', + 'parsed-derivations.hh', + 'path.hh', + 'path-info.hh', + 'pathlocks.hh', + 'path-references.hh', + 'path-regex.hh', + 'path-with-outputs.hh', + 'posix-fs-canonicalise.hh', + 'profiles.hh', + 'realisation.hh', + 'remote-fs-accessor.hh', + 'remote-store-connection.hh', + 'remote-store.hh', + 's3-binary-cache-store.hh', + 's3.hh', + 'serve-protocol.hh', + 'serve-protocol-impl.hh', + 'sqlite.hh', + 'ssh.hh', + 'ssh-store-config.hh', + 'store-api.hh', + 'store-cast.hh', + 'store-dir-config.hh', + 'uds-remote-store.hh', + 'worker-protocol.hh', + 'worker-protocol-impl.hh') + +libstore_data = files() + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libstore_inc = [include_directories('.')] + +libstore_dirs = [ + 'build', + 'builtins'] + +foreach dir : libstore_dirs + subdir(dir) +endforeach + + +# targets +#============================================================================ + +libstore_src += custom_target( + 'schema.sql.gen.hh', + output : 'schema.sql.gen.hh', + input : 'schema.sql', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + + +libstore_src += custom_target( + 'ca-specific-schema.sql.gen.hh', + output : 'ca-specific-schema.sql.gen.hh', + input : 'ca-specific-schema.sql', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libstore_cxx_args = [ + '-DNIX_PREFIX="@0@" '.format(prefix), + '-DNIX_STORE_DIR="@0@" '.format(nixstoredir), + '-DNIX_DATA_DIR="@0@" '.format(datadir), + '-DNIX_STATE_DIR="@0@" '.format(join_paths(localstatedir, 'nix')), + '-DNIX_LOG_DIR="@0@" '.format(join_paths(localstatedir, 'log/nix')), + '-DNIX_CONF_DIR="@0@" '.format(join_paths(sysconfdir, 'nix')), + '-DNIX_LIBEXEC_DIR="@0@" '.format(libexecdir), + '-DNIX_BIN_DIR="@0@" '.format(bindir), + '-DNIX_MAN_DIR="@0@" '.format(mandir), + '-DSANDBOX_SHELL="@0@" '.format(get_option('sandbox_shell')), + '-DLSOF="@0@" '.format(lsof.full_path())] + +libstore_link_args = [] + + +# build library +#--------------------------------------------------- +libstore_lib = library( + 'nixstore', + sources : libstore_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : [ + libstore_inc, + proj_inc], + cpp_args : libstore_cxx_args, + link_args : libstore_link_args, + dependencies : libstore_dep_list) + + +# install headers +#--------------------------------------------------- +install_headers( + libstore_headers, + install_dir : join_paths(includedir, 'nix')) + + +# install data +#--------------------------------------------------- +install_data( + libstore_data, + install_dir : join_paths(datadir, 'nix/sandbox')) + + +# generate pkg-config +#--------------------------------------------------- +libstore_config = pkgconfig.generate( + libstore_lib, + libraries : [ + libstore_lib], + version : meson.project_version(), + name : 'Nix', + subdirs : ['nix/'], + filebase : 'nix-store', + extra_cflags : '-std=c++17', + description : 'Nix Package Manager.') + + +# declare dependency +#--------------------------------------------------- +libstore_dep = declare_dependency( + link_with : libstore_lib, + include_directories : libstore_inc) diff --git a/nix/libutil/meson.build b/nix/libutil/meson.build new file mode 100644 index 00000000000..7edf76f7c07 --- /dev/null +++ b/nix/libutil/meson.build @@ -0,0 +1 @@ +subdir('src') \ No newline at end of file diff --git a/nix/libutil/src/args/meson.build b/nix/libutil/src/args/meson.build new file mode 100644 index 00000000000..71d4f6c74ad --- /dev/null +++ b/nix/libutil/src/args/meson.build @@ -0,0 +1,10 @@ +# libutil.args build file +#============================================================================ + + +# src files +#============================================================================ + +libutil_headers += files( + 'root.hh') + diff --git a/nix/libutil/src/meson.build b/nix/libutil/src/meson.build new file mode 100644 index 00000000000..093b155d711 --- /dev/null +++ b/nix/libutil/src/meson.build @@ -0,0 +1,187 @@ +# libutil build file +#============================================================================ + + +# dependencies +#============================================================================ + +libutil_dep_list = [ + aws_sdk_cpp_dep, + boost_dep, + libarchive_dep, + libbrotli_dep, + libcpuid_dep, + libsodium_dep, + nlohmann_dep, + openssl_dep, + pthread_dep, +] + + +# src files +#============================================================================ + +libutil_src = files( + 'archive.cc', + 'args.cc', + 'canon-path.cc', + 'cgroup.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', + 'namespaces.cc', + 'position.cc', + 'posix-source-accessor.cc', + 'processes.cc', + 'references.cc', + 'serialise.cc', + 'signals.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') + + +libutil_headers = files( + 'abstract-setting-to-json.hh', + 'ansicolor.hh', + 'archive.hh', + 'args.hh', + 'callback.hh', + 'canon-path.hh', + 'cgroup.hh', + 'chunked-vector.hh', + 'closure.hh', + 'comparator.hh', + 'compression.hh', + 'compute-levels.hh', + 'config.hh', + 'config-impl.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-system.hh', + 'finally.hh', + 'fmt.hh', + 'fs-sink.hh', + 'git.hh', + 'hash.hh', + 'hilite.hh', + 'input-accessor.hh', + 'json-impls.hh', + 'json-utils.hh', + 'logging.hh', + 'lru-cache.hh', + 'memory-source-accessor.hh', + 'monitor-fd.hh', + 'namespaces.hh', + 'pool.hh', + 'position.hh', + 'posix-source-accessor.hh', + 'processes.hh', + 'references.hh', + 'ref.hh', + 'regex-combinators.hh', + 'repair-flag.hh', + 'serialise.hh', + 'signals.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.hh', + 'url-parts.hh', + 'users.hh', + 'util.hh', + 'variant-wrapper.hh', + 'xml-writer.hh') + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libutil_inc = [include_directories('.')] + +libutil_dirs = [ + 'args', + 'signature'] + +foreach dir : libutil_dirs + subdir(dir) +endforeach + + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libutil_cxx_args = [] + +libutil_link_args = [] + + +# build library +#--------------------------------------------------- +libutil_lib = library( + 'nixutil', + sources : libutil_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : libdir, + include_directories : proj_inc, + cpp_args : libutil_cxx_args, + link_args : libutil_link_args, + dependencies : libutil_dep_list) + + +# install headers +#--------------------------------------------------- +install_headers( + libutil_headers, + install_dir : join_paths(includedir, 'nix')) + + +# declare dependency +#--------------------------------------------------- +libutil_dep = declare_dependency( + link_with : libutil_lib, + include_directories : libutil_inc) diff --git a/nix/libutil/src/signature/meson.build b/nix/libutil/src/signature/meson.build new file mode 100644 index 00000000000..7fff2314bfa --- /dev/null +++ b/nix/libutil/src/signature/meson.build @@ -0,0 +1,15 @@ +# libutil.signature build file +#============================================================================ + + +# src files +#============================================================================ + +libutil_src += files( + 'local-keys.cc', + 'signer.cc') + +libutil_headers += files( + 'local-keys.hh', + 'signer.hh') + diff --git a/nix/meson.build b/nix/meson.build new file mode 100644 index 00000000000..f817e4e8e63 --- /dev/null +++ b/nix/meson.build @@ -0,0 +1,22 @@ +# nix build file +#============================================================================ + +proj_inc += include_directories('.') + +src_dirs = [ + 'libutil', + 'libstore', + 'libmain', + 'libfetchers', + 'libexpr', + 'libcmd', + # 'nixbin', +] + +# if get_option('nix_perl').allowed() +# src_dirs += ['perl'] +# endif + +foreach dir : src_dirs + subdir(dir) +endforeach diff --git a/nix/nixbin/meson.build b/nix/nixbin/meson.build new file mode 100644 index 00000000000..367eb31cb30 --- /dev/null +++ b/nix/nixbin/meson.build @@ -0,0 +1,13 @@ +# nix build file +#============================================================================ + +nix_inc = [include_directories('.')] + +nixbin_dirs = [ + 'data', + 'misc', + 'src'] + +foreach dir : nixbin_dirs + subdir(dir) +endforeach diff --git a/nix/nixbin/src/bin/meson.build b/nix/nixbin/src/bin/meson.build new file mode 100644 index 00000000000..8b92e61bab4 --- /dev/null +++ b/nix/nixbin/src/bin/meson.build @@ -0,0 +1,80 @@ +# Nix binary build file +#============================================================================ + + + + +# dependencies +#============================================================================ + +nix_dep_list = [ + pthread_dep, + libdl_dep, + boost_dep, + editline_dep, + libsodium_dep, + gc_dep, + + libutil_dep, + libstore_dep, + libmain_dep, + libfetchers_dep, + libexpr_dep, + libcmd_dep] + + +# src files +#============================================================================ + +nix_src = files( + 'add-to-store.cc', + 'app.cc', + 'build.cc', + 'bundle.cc', + 'cat.cc', + 'config.cc', + 'config-check.cc', + 'copy.cc', + 'daemon.cc', + 'derivation-add.cc', + 'derivation.cc', + 'derivation-show.cc', + 'develop.cc', + 'diff-closures.cc', + 'dump-path.cc', + 'edit.cc', + 'eval.cc', + 'flake.cc', + 'fmt.cc', + 'hash.cc', + 'log.cc', + 'ls.cc', + 'main.cc', + 'make-content-addressed.cc', + 'nar.cc', + 'optimise-store.cc', + 'path-from-hash-part.cc', + 'path-info.cc', + 'prefetch.cc', + 'profile.cc', + 'realisation.cc', + 'registry.cc', + 'repl.cc', + 'run.cc', + 'search.cc', + 'sigs.cc', + 'store.cc', + 'store-copy-log.cc', + 'store-delete.cc', + 'store-gc.cc', + 'store-info.cc', + 'store-repair.cc', + 'upgrade-nix.cc', + 'verify.cc', + 'why-depends.cc') + +nix_headers = files( + 'run.hh') + +nix_markdown_files += files( + join_paths('realisation', 'info.md')) diff --git a/nix/nixbin/src/build-remote/meson.build b/nix/nixbin/src/build-remote/meson.build new file mode 100644 index 00000000000..8a54fd61409 --- /dev/null +++ b/nix/nixbin/src/build-remote/meson.build @@ -0,0 +1,11 @@ +# build-remote build file +#============================================================================ + +build_remote_inc = [include_directories('.')] + + +# src files +#============================================================================ + +build_remote_src = files( + 'build-remote.cc') diff --git a/nix/nixbin/src/meson.build b/nix/nixbin/src/meson.build new file mode 100644 index 00000000000..2b03121e4b7 --- /dev/null +++ b/nix/nixbin/src/meson.build @@ -0,0 +1,79 @@ +# nix build file +#============================================================================ + +nix_inc += include_directories('.') + +nix_src_dirs = [ + 'build-remote', + 'nix-build', + 'nix-channel', + 'nix-collect-garbage', + 'nix-copy-closure', + 'nix-env', + 'nix-instantiate', + 'nix-store', + 'bin', +] + +if sys_name == 'Darwin' + nix_src_dirs += 'resolve-system-dependencies' +endif + +foreach dir : nix_src_dirs + subdir(dir) +endforeach + + +# build +#============================================================================ + +# build executable +#--------------------------------------------------- +nix_bin = executable( + 'nix', + sources : [ + get_env_hh, + nix_src, + build_remote_src, + nix_build_src, + nix_channel_src, + nix_collect_garbage_src, + nix_copy_closure_src, + # nix_daemon_src, + nix_env_src, + nix_instantiate_src, + nix_store_src, + # utils_nix, + # generate_manpage_nix + ], + install : true, + install_mode : 'rwxr-xr-x', + install_dir : bindir, + include_directories : [ + nix_inc, + # doc_manual_inc, + proj_inc], + cpp_args : nix_cxx_args, + link_args : nix_link_args, + dependencies : nix_dep_list) + +# Install the symlinks for the nix binary +nix_symlink_list = [ + 'nix-build', + 'nix-channel', + 'nix-collect-garbage', + 'nix-copy-closure', + 'nix-daemon', + 'nix-env', + 'nix-hash', + 'nix-instantiate', + 'nix-prefetch-url', + 'nix-shell', + 'nix-store'] + +foreach nix_symlink : nix_symlink_list + install_symlink( + nix_symlink, + install_dir : bindir, + pointing_to : 'nix') +endforeach diff --git a/nix/nixbin/src/nix-build/meson.build b/nix/nixbin/src/nix-build/meson.build new file mode 100644 index 00000000000..dfb925a7592 --- /dev/null +++ b/nix/nixbin/src/nix-build/meson.build @@ -0,0 +1,11 @@ +# nix-build build file +#============================================================================ + +nix_build_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_build_src = files( + 'nix-build.cc') diff --git a/nix/nixbin/src/nix-channel/meson.build b/nix/nixbin/src/nix-channel/meson.build new file mode 100644 index 00000000000..6813b80ae27 --- /dev/null +++ b/nix/nixbin/src/nix-channel/meson.build @@ -0,0 +1,20 @@ +# nix-channel channel file +#============================================================================ + +nix_channel_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_channel_src = files( + 'nix-channel.cc') + + +# targets +#============================================================================ +nix_channel_src += custom_target( + 'unpack-channel.nix.gen.hh', + output : 'unpack-channel.nix.gen.hh', + input : 'unpack-channel.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/nixbin/src/nix-collect-garbage/meson.build b/nix/nixbin/src/nix-collect-garbage/meson.build new file mode 100644 index 00000000000..10ca61116c8 --- /dev/null +++ b/nix/nixbin/src/nix-collect-garbage/meson.build @@ -0,0 +1,11 @@ +# build-remote build file +#============================================================================ + +nix_collect_garbage_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_collect_garbage_src = files( + 'nix-collect-garbage.cc') diff --git a/nix/nixbin/src/nix-copy-closure/meson.build b/nix/nixbin/src/nix-copy-closure/meson.build new file mode 100644 index 00000000000..c13f6151982 --- /dev/null +++ b/nix/nixbin/src/nix-copy-closure/meson.build @@ -0,0 +1,11 @@ +# nix-copy-closure build file +#============================================================================ + +nix_copy_closure_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_copy_closure_src = files( + 'nix-copy-closure.cc') diff --git a/nix/nixbin/src/nix-env/meson.build b/nix/nixbin/src/nix-env/meson.build new file mode 100644 index 00000000000..64c92440054 --- /dev/null +++ b/nix/nixbin/src/nix-env/meson.build @@ -0,0 +1,20 @@ +# nix-env build file +#============================================================================ + +nix_env_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_env_src = files( + 'nix-env.cc', + 'user-env.cc') + +# targets +#============================================================================ +nix_env_src += custom_target( + 'buildenv.nix.gen.hh', + output : 'buildenv.nix.gen.hh', + input : 'buildenv.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) diff --git a/nix/nixbin/src/nix-instantiate/meson.build b/nix/nixbin/src/nix-instantiate/meson.build new file mode 100644 index 00000000000..5a25767150c --- /dev/null +++ b/nix/nixbin/src/nix-instantiate/meson.build @@ -0,0 +1,11 @@ +# nix-instantiate build file +#============================================================================ + +nix_instantiate_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_instantiate_src = files( + 'nix-instantiate.cc') diff --git a/nix/nixbin/src/nix-store/meson.build b/nix/nixbin/src/nix-store/meson.build new file mode 100644 index 00000000000..fd65e3ceea8 --- /dev/null +++ b/nix/nixbin/src/nix-store/meson.build @@ -0,0 +1,13 @@ +# nix-store build file +#============================================================================ + +nix_store_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_store_src = files( + 'dotgraph.cc', + 'graphml.cc', + 'nix-store.cc') diff --git a/nix/nixbin/src/resolve-system-dependencies/meson.build b/nix/nixbin/src/resolve-system-dependencies/meson.build new file mode 100644 index 00000000000..6e3acd6ef8b --- /dev/null +++ b/nix/nixbin/src/resolve-system-dependencies/meson.build @@ -0,0 +1,39 @@ +# resolve-system-dependencies build file +#============================================================================ + +resolvesysdeps_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +resolvesysdeps_dep_list = [] + + +# src files +#============================================================================ + +resolvesysdeps_src = files( + 'resolve-system-dependencies.cc') + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +resolvesysdeps_cxx_args = [] + +resolvesysdeps_link_args = [] + +# build executable +#--------------------------------------------------- +resolvesysdeps_bin = executable( + 'resolve-system-dependencies', + sources : resolvesysdeps_src, + install : true, + install_mode : 'rwxr-xr-x', + install_dir : bindir, + include_directories : proj_inc, + cpp_args : resolvesysdeps_cxx_args, + link_args : resolvesysdeps_link_args, + dependencies : resolvesysdeps_dep_list) diff --git a/subprojects/bdwgc.wrap b/subprojects/bdwgc.wrap new file mode 100644 index 00000000000..e4f005ca3b3 --- /dev/null +++ b/subprojects/bdwgc.wrap @@ -0,0 +1,6 @@ +[wrap-file] +directory = bdwgc + +source_url = https://github.com/nlohmann/json +revision = v3.11.3 + diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 00000000000..adb8a9a6d94 --- /dev/null +++ b/subprojects/gtest.wrap @@ -0,0 +1,16 @@ +[wrap-file] +directory = googletest-1.14.0 +source_url = https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz +source_filename = gtest-1.14.0.tar.gz +source_hash = 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7 +patch_filename = gtest_1.14.0-2_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.14.0-2/get_patch +patch_hash = 4ec7f767364386a99f7b2d61678287a73ad6ba0f9998be43b51794c464a63732 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.14.0-2/gtest-1.14.0.tar.gz +wrapdb_version = 1.14.0-2 + +[provide] +gtest = gtest_dep +gtest_main = gtest_main_dep +gmock = gmock_dep +gmock_main = gmock_main_dep diff --git a/subprojects/nlohmann-json.wrap b/subprojects/nlohmann-json.wrap new file mode 100644 index 00000000000..5a4594cff5c --- /dev/null +++ b/subprojects/nlohmann-json.wrap @@ -0,0 +1,6 @@ +[wrap-file] +directory = nlohmann-json + +source_url = https://github.com/nlohmann/json +revision = v3.11.3 + diff --git a/subprojects/packagefiles/bdwgc/boehmgc-coroutine-sp-fallback.diff b/subprojects/packagefiles/bdwgc/boehmgc-coroutine-sp-fallback.diff new file mode 100644 index 00000000000..2afbe96712b --- /dev/null +++ b/subprojects/packagefiles/bdwgc/boehmgc-coroutine-sp-fallback.diff @@ -0,0 +1,99 @@ +diff --git a/darwin_stop_world.c b/darwin_stop_world.c +index 0468aaec..b348d869 100644 +--- a/darwin_stop_world.c ++++ b/darwin_stop_world.c +@@ -356,6 +356,7 @@ GC_INNER void GC_push_all_stacks(void) + int nthreads = 0; + word total_size = 0; + mach_msg_type_number_t listcount = (mach_msg_type_number_t)THREAD_TABLE_SZ; ++ size_t stack_limit; + if (!EXPECT(GC_thr_initialized, TRUE)) + GC_thr_init(); + +@@ -411,6 +412,19 @@ GC_INNER void GC_push_all_stacks(void) + GC_push_all_stack_sections(lo, hi, p->traced_stack_sect); + } + if (altstack_lo) { ++ // When a thread goes into a coroutine, we lose its original sp until ++ // control flow returns to the thread. ++ // While in the coroutine, the sp points outside the thread stack, ++ // so we can detect this and push the entire thread stack instead, ++ // as an approximation. ++ // We assume that the coroutine has similarly added its entire stack. ++ // This could be made accurate by cooperating with the application ++ // via new functions and/or callbacks. ++ stack_limit = pthread_get_stacksize_np(p->id); ++ if (altstack_lo >= altstack_hi || altstack_lo < altstack_hi - stack_limit) { // sp outside stack ++ altstack_lo = altstack_hi - stack_limit; ++ } ++ + total_size += altstack_hi - altstack_lo; + GC_push_all_stack(altstack_lo, altstack_hi); + } +diff --git a/include/gc.h b/include/gc.h +index edab6c22..f2c61282 100644 +--- a/include/gc.h ++++ b/include/gc.h +@@ -2172,6 +2172,11 @@ GC_API void GC_CALL GC_win32_free_heap(void); + (*GC_amiga_allocwrapper_do)(a,GC_malloc_atomic_ignore_off_page) + #endif /* _AMIGA && !GC_AMIGA_MAKINGLIB */ + ++#if !__APPLE__ ++/* Patch doesn't work on apple */ ++#define NIX_BOEHM_PATCH_VERSION 1 ++#endif ++ + #ifdef __cplusplus + } /* extern "C" */ + #endif +diff --git a/pthread_stop_world.c b/pthread_stop_world.c +index b5d71e62..aed7b0bf 100644 +--- a/pthread_stop_world.c ++++ b/pthread_stop_world.c +@@ -768,6 +768,8 @@ STATIC void GC_restart_handler(int sig) + /* world is stopped. Should not fail if it isn't. */ + GC_INNER void GC_push_all_stacks(void) + { ++ size_t stack_limit; ++ pthread_attr_t pattr; + GC_bool found_me = FALSE; + size_t nthreads = 0; + int i; +@@ -851,6 +853,37 @@ GC_INNER void GC_push_all_stacks(void) + hi = p->altstack + p->altstack_size; + /* FIXME: Need to scan the normal stack too, but how ? */ + /* FIXME: Assume stack grows down */ ++ } else { ++#ifdef HAVE_PTHREAD_ATTR_GET_NP ++ if (!pthread_attr_init(&pattr) ++ || !pthread_attr_get_np(p->id, &pattr)) ++#else /* HAVE_PTHREAD_GETATTR_NP */ ++ if (pthread_getattr_np(p->id, &pattr)) ++#endif ++ { ++ ABORT("GC_push_all_stacks: pthread_getattr_np failed!"); ++ } ++ if (pthread_attr_getstacksize(&pattr, &stack_limit)) { ++ ABORT("GC_push_all_stacks: pthread_attr_getstacksize failed!"); ++ } ++ if (pthread_attr_destroy(&pattr)) { ++ ABORT("GC_push_all_stacks: pthread_attr_destroy failed!"); ++ } ++ // When a thread goes into a coroutine, we lose its original sp until ++ // control flow returns to the thread. ++ // While in the coroutine, the sp points outside the thread stack, ++ // so we can detect this and push the entire thread stack instead, ++ // as an approximation. ++ // We assume that the coroutine has similarly added its entire stack. ++ // This could be made accurate by cooperating with the application ++ // via new functions and/or callbacks. ++ #ifndef STACK_GROWS_UP ++ if (lo >= hi || lo < hi - stack_limit) { // sp outside stack ++ lo = hi - stack_limit; ++ } ++ #else ++ #error "STACK_GROWS_UP not supported in boost_coroutine2 (as of june 2021), so we don't support it in Nix." ++ #endif + } + GC_push_all_stack_sections(lo, hi, traced_stack_sect); + # ifdef STACK_GROWS_UP diff --git a/subprojects/packagefiles/bdwgc/boehmgc-traceable_allocator-public.diff b/subprojects/packagefiles/bdwgc/boehmgc-traceable_allocator-public.diff new file mode 100644 index 00000000000..903c707a698 --- /dev/null +++ b/subprojects/packagefiles/bdwgc/boehmgc-traceable_allocator-public.diff @@ -0,0 +1,12 @@ +diff --git a/include/gc_allocator.h b/include/gc_allocator.h +index 597c7f13..587286be 100644 +--- a/include/gc_allocator.h ++++ b/include/gc_allocator.h +@@ -312,6 +312,7 @@ public: + + template<> + class traceable_allocator { ++public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; diff --git a/subprojects/packagefiles/nlohmann-json/meson.build b/subprojects/packagefiles/nlohmann-json/meson.build new file mode 100644 index 00000000000..7d4cdeac511 --- /dev/null +++ b/subprojects/packagefiles/nlohmann-json/meson.build @@ -0,0 +1,18 @@ +# nlohmann-json build file +#============================================================================ + +nlohmann_inc = [include_directories('.')] + +nlohmann_headers = files( + 'json.hpp', + 'json_fwd.hpp', +) + +install_headers( + nlohmann_headers, + install_dir : join_paths(includedir, 'nix')) + +# declare dependency +#--------------------------------------------------- +nlohmann_dep = declare_dependency( + include_directories : nlohmann_inc) diff --git a/subprojects/toml11.wrap b/subprojects/toml11.wrap new file mode 100644 index 00000000000..ce0bfd62d55 --- /dev/null +++ b/subprojects/toml11.wrap @@ -0,0 +1,7 @@ +[wrap-file] +directory = toml11-3.8.1 +source_url = https://github.com/ToruNiina/toml11/archive/refs/tags/v3.8.1.zip +source_filename = toml11-3.8.1.zip +source_hash = 72e956f42002dd1566c5551a693ec0f6fa3bea3a0e7bcea29bcdace98738da74 +wrapdb_version = 3.8.0-1 +buildsystem = cmake diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 00000000000..a4f9b626bfc --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,13 @@ +# nix tests +#============================================================================ + +test_dirs = [ + 'nix', + # 'funtional', + # 'installer', + # 'nixos' + ] + +foreach dir : test_dirs + subdir(dir) +endforeach diff --git a/tests/nix/libstore/meson.build b/tests/nix/libstore/meson.build new file mode 100644 index 00000000000..3925d5464e7 --- /dev/null +++ b/tests/nix/libstore/meson.build @@ -0,0 +1,13 @@ +# libstore unit tests +#============================================================================ + +libstore_test_data_dir = join_paths(meson.current_source_dir(), 'data') + +libstore_unit_test_dirs = [ + # 'data', + 'support', + 'unit'] + +foreach dir : libstore_unit_test_dirs + subdir(dir) +endforeach diff --git a/tests/nix/libstore/support/meson.build b/tests/nix/libstore/support/meson.build new file mode 100644 index 00000000000..3a97c58c524 --- /dev/null +++ b/tests/nix/libstore/support/meson.build @@ -0,0 +1,58 @@ +# libstore.tests.support +#============================================================================ + +libstore_support_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +libstore_support_dep_list = [ + gtest_dep, + rapidcheck_dep, + + libutil_dep, + libutil_support_dep, + libstore_dep] + + +# src files +#============================================================================ + +libstore_support_src = files( + join_paths('tests', 'derived-path.cc'), + join_paths('tests', 'outputs-spec.cc'), + join_paths('tests', 'path.cc')) + +libstore_support_headers = files( + join_paths('tests', 'derived-path.hh'), + join_paths('tests', 'outputs-spec.hh'), + join_paths('tests', 'path.hh'), + join_paths('tests', 'protocol.hh')) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libstore_support_cxx_args = [] + +libstore_support_link_args = [] + +libstore_support_lib = library( + 'nixstore-support', + sources : libstore_support_src, + include_directories : [ + proj_inc, + libstore_support_inc], + cpp_args : libstore_support_cxx_args, + link_args : libstore_support_link_args, + dependencies : libstore_support_dep_list) + + + +# declare dependency +#--------------------------------------------------- +libstore_support_dep = declare_dependency( + link_with : libstore_support_lib, + include_directories : libstore_support_inc) diff --git a/tests/nix/libstore/unit/common-protocol/meson.build b/tests/nix/libstore/unit/common-protocol/meson.build new file mode 100644 index 00000000000..12ff91bdce1 --- /dev/null +++ b/tests/nix/libstore/unit/common-protocol/meson.build @@ -0,0 +1,20 @@ +# libstore.test.common-protocol +# ============================================================================ + + +# build test +#--------------------------------------------------- +libstore_common_protocol_test = executable( + 'common-protocol-test', + install : false, + sources : 'common-protocol.cc', + include_directories : proj_inc, + dependencies : libstore_tests_dep_list) + + +test( + 'common-protocol-test', + libstore_common_protocol_test, + protocol : 'gtest', + suite : ['unit', 'libstore']) + diff --git a/tests/nix/libstore/unit/content-address/meson.build b/tests/nix/libstore/unit/content-address/meson.build new file mode 100644 index 00000000000..134d8c3fdce --- /dev/null +++ b/tests/nix/libstore/unit/content-address/meson.build @@ -0,0 +1,21 @@ +# libstore.test.content-addresss +# ============================================================================ + + +# build test +#--------------------------------------------------- +libstore_content_address_test = executable( + 'content-address-test', + install : false, + sources : 'content-address.cc', + include_directories : proj_inc, + dependencies : libstore_tests_dep_list) + + +test( + 'content-address-test', + libstore_content_address_test, + env : ['_NIX_TEST_UNIT_DATA=@0@'.format(libstore_test_data_dir)], + protocol : 'gtest', + suite : ['unit', 'libstore']) + diff --git a/tests/nix/libstore/unit/derivation/meson.build b/tests/nix/libstore/unit/derivation/meson.build new file mode 100644 index 00000000000..ae4b453cdb4 --- /dev/null +++ b/tests/nix/libstore/unit/derivation/meson.build @@ -0,0 +1,21 @@ +# libstore.test.derivation +# ============================================================================ + + +# build test +#--------------------------------------------------- +libstore_content_address_test = executable( + 'derivation', + install : false, + sources : 'derivation.cc', + include_directories : proj_inc, + dependencies : libstore_tests_dep_list) + + +test( + 'derivation', + libstore_content_address_test, + env : ['_NIX_TEST_UNIT_DATA=@0@'.format(libstore_test_data_dir)], + protocol : 'gtest', + suite : ['unit', 'libstore']) + diff --git a/tests/nix/libstore/unit/machines/meson.build b/tests/nix/libstore/unit/machines/meson.build new file mode 100644 index 00000000000..8527b524e2e --- /dev/null +++ b/tests/nix/libstore/unit/machines/meson.build @@ -0,0 +1,8 @@ + + +# TODO: currently, the test has hardcoded paths +# to the needed test data files. this isnt handled +# in this manner elsewhere in the codebase, and +# will need to be normalised. + + diff --git a/tests/nix/libstore/unit/meson.build b/tests/nix/libstore/unit/meson.build new file mode 100644 index 00000000000..1dc9baa36fd --- /dev/null +++ b/tests/nix/libstore/unit/meson.build @@ -0,0 +1,55 @@ +# libstore.tests +#============================================================================ + +libstore_tests_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +libstore_tests_dep_list = [ + aws_sdk_cpp_dep, + libcurl_dep, + libdl_dep, + libseccomp_dep, + libsodium_dep, + nlohmann_dep, + pthread_dep, + sqlite3_dep, + + + + + gtest_dep, + gmock_dep, + rapidcheck_dep, + + libutil_support_dep, + libutil_dep, + libstore_support_dep, + libstore_dep] + + +# include directories +#============================================================================ + +libstore_unit_test_dirs = [ + 'common-protocol', + 'content-address', + # 'derivation', + # 'derived-path', + # 'downstream-placeholder', + # 'machines', + # 'nar-info', + # 'nar-info-disk-cache', + # 'outputs-spec', + # 'path', + # 'path-info', + # 'references', + # 'serve-protocol', + # 'worker-protocol' + ] + +foreach dir : libstore_unit_test_dirs + subdir(dir) +endforeach + diff --git a/tests/nix/libutil/meson.build b/tests/nix/libutil/meson.build new file mode 100644 index 00000000000..c69a84dd290 --- /dev/null +++ b/tests/nix/libutil/meson.build @@ -0,0 +1,13 @@ +# libutil unit tests +#============================================================================ + +libutil_test_data_dir = join_paths(meson.current_source_dir(), 'data') + +libutil_unit_test_dirs = [ + # 'data', + 'support', + 'unit'] + +foreach dir : libutil_unit_test_dirs + subdir(dir) +endforeach diff --git a/tests/nix/libutil/support/meson.build b/tests/nix/libutil/support/meson.build new file mode 100644 index 00000000000..218a6a89077 --- /dev/null +++ b/tests/nix/libutil/support/meson.build @@ -0,0 +1,53 @@ +# libutil.tests.support +#============================================================================ + +libutil_support_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +libutil_support_dep_list = [ + gtest_dep, + rapidcheck_dep, + # rapidcheck_gtest_dep, + + libutil_dep] + + +# src files +#============================================================================ + +libutil_support_src = files( + join_paths('tests', 'hash.cc')) + +libutil_support_headers = files( + join_paths('tests', 'characterization.hh'), + join_paths('tests', 'hash.hh')) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libutil_support_cxx_args = [] + +libutil_support_link_args = [] + +libutil_support_lib = library( + 'nixutil-support', + sources : libutil_support_src, + include_directories : [ + proj_inc, + libutil_support_inc], + cpp_args : libutil_support_cxx_args, + link_args : libutil_support_link_args, + dependencies : libutil_support_dep_list) + + + +# declare dependency +#--------------------------------------------------- +libutil_support_dep = declare_dependency( + link_with : libutil_support_lib, + include_directories : libutil_support_inc) diff --git a/tests/nix/libutil/unit/args/meson.build b/tests/nix/libutil/unit/args/meson.build new file mode 100644 index 00000000000..aae0ce1da05 --- /dev/null +++ b/tests/nix/libutil/unit/args/meson.build @@ -0,0 +1,17 @@ +# libutil.test.args +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_args_test = executable( + 'libutil-args-test', + install : false, + sources : 'args.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-args-test', + libutil_args_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/canon-path/meson.build b/tests/nix/libutil/unit/canon-path/meson.build new file mode 100644 index 00000000000..dbdc208263e --- /dev/null +++ b/tests/nix/libutil/unit/canon-path/meson.build @@ -0,0 +1,17 @@ +# libutil.test.canon-path +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_canon_path_test = executable( + 'libutil-canon-path-test', + install : false, + sources : 'canon-path.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-canon-path-test', + libutil_canon_path_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/chunked-vector/meson.build b/tests/nix/libutil/unit/chunked-vector/meson.build new file mode 100644 index 00000000000..609193196d5 --- /dev/null +++ b/tests/nix/libutil/unit/chunked-vector/meson.build @@ -0,0 +1,17 @@ +# libutil.test.chunked-vector +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_chunked_vector_test = executable( + 'libutil-chunked-vector-test', + install : false, + sources : 'chunked-vector.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-chunked-vector-test', + libutil_chunked_vector_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/closure/meson.build b/tests/nix/libutil/unit/closure/meson.build new file mode 100644 index 00000000000..90289e9c47e --- /dev/null +++ b/tests/nix/libutil/unit/closure/meson.build @@ -0,0 +1,18 @@ +# libutil.test.closure +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_closure_test = executable( + 'libutil-closure-test', + install : false, + sources : 'closure.cc', + include_directories : [ + proj_inc], + dependencies : libutil_tests_dep_list) + +test( + 'libutil-closure-test', + libutil_closure_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/compression/meson.build b/tests/nix/libutil/unit/compression/meson.build new file mode 100644 index 00000000000..d13ef06b51f --- /dev/null +++ b/tests/nix/libutil/unit/compression/meson.build @@ -0,0 +1,17 @@ +# libutil.test.compression +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_compression_test = executable( + 'libutil-compression-test', + install : false, + sources : 'compression.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-compression-test', + libutil_compression_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/config/meson.build b/tests/nix/libutil/unit/config/meson.build new file mode 100644 index 00000000000..88b4a90b7b8 --- /dev/null +++ b/tests/nix/libutil/unit/config/meson.build @@ -0,0 +1,17 @@ +# libutil.test.config +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_config_test = executable( + 'libutil-config-test', + install : false, + sources : 'config.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-config-test', + libutil_config_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/file-content-address/meson.build b/tests/nix/libutil/unit/file-content-address/meson.build new file mode 100644 index 00000000000..96d88218907 --- /dev/null +++ b/tests/nix/libutil/unit/file-content-address/meson.build @@ -0,0 +1,17 @@ +# libutil.test.file-content-address +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_file_content_address_test = executable( + 'libutil-file-content-address-test', + install : false, + sources : 'file-content-address.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-file-content-address-test', + libutil_file_content_address_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/git/meson.build b/tests/nix/libutil/unit/git/meson.build new file mode 100644 index 00000000000..be307585643 --- /dev/null +++ b/tests/nix/libutil/unit/git/meson.build @@ -0,0 +1,18 @@ +# libutil.test.git +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_git_test = executable( + 'libutil-git-test', + install : false, + sources : ['git.cc'], + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-git-test', + libutil_git_test, + env : ['_NIX_TEST_UNIT_DATA=@0@'.format(libutil_test_data_dir)], + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/hash/meson.build b/tests/nix/libutil/unit/hash/meson.build new file mode 100644 index 00000000000..01b9818cdfe --- /dev/null +++ b/tests/nix/libutil/unit/hash/meson.build @@ -0,0 +1,17 @@ +# libutil.test.hash +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_hash_test = executable( + 'libutil-hash-test', + install : false, + sources : 'hash.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-hash-test', + libutil_hash_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/hilite/meson.build b/tests/nix/libutil/unit/hilite/meson.build new file mode 100644 index 00000000000..1c9b2bf83c7 --- /dev/null +++ b/tests/nix/libutil/unit/hilite/meson.build @@ -0,0 +1,17 @@ +# libutil.test.hilite +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_hilite_test = executable( + 'libutil-hilite-test', + install : false, + sources : 'hilite.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-hilite-test', + libutil_hilite_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/json-utils/meson.build b/tests/nix/libutil/unit/json-utils/meson.build new file mode 100644 index 00000000000..5f24407b46b --- /dev/null +++ b/tests/nix/libutil/unit/json-utils/meson.build @@ -0,0 +1,18 @@ +# libutil.test.json-utils +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_json_utils_test = executable( + 'libutil-json-utils-test', + install : false, + sources : 'json-utils.cc', + include_directories : [ + proj_inc], + dependencies : libutil_tests_dep_list) + +test( + 'libutil-json-utils-test', + libutil_json_utils_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/logging/meson.build b/tests/nix/libutil/unit/logging/meson.build new file mode 100644 index 00000000000..414dc191839 --- /dev/null +++ b/tests/nix/libutil/unit/logging/meson.build @@ -0,0 +1,17 @@ +# libutil.test.logging +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_logging_test = executable( + 'libutil-logging-test', + install : false, + sources : 'logging.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-logging-test', + libutil_logging_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/lru-cache/meson.build b/tests/nix/libutil/unit/lru-cache/meson.build new file mode 100644 index 00000000000..89903faf353 --- /dev/null +++ b/tests/nix/libutil/unit/lru-cache/meson.build @@ -0,0 +1,17 @@ +# libutil.test.lru-cache +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_lru_cache_test = executable( + 'libutil-lru-cache-test', + install : false, + sources : 'lru-cache.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-lru-cache-test', + libutil_lru_cache_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/meson.build b/tests/nix/libutil/unit/meson.build new file mode 100644 index 00000000000..c92d0073a26 --- /dev/null +++ b/tests/nix/libutil/unit/meson.build @@ -0,0 +1,44 @@ +# libutil.tests +#============================================================================ + + + +# dependencies +#============================================================================ + +libutil_tests_dep_list = [ + gtest_dep, + gmock_dep, + rapidcheck_dep, + + libutil_dep, + libutil_support_dep] + + +# include directories +#============================================================================ + +libutil_unit_test_dirs = [ + 'args', + 'canon-path', + 'chunked-vector', + 'closure', + 'compression', + 'config', + 'file-content-address', + 'git', + 'hash', + 'hilite', + 'json-utils', + 'logging', + 'lru-cache', + 'misc', + 'pool', + 'references', + 'suggestions', + 'url', + 'xml-writer'] + +foreach dir : libutil_unit_test_dirs + subdir(dir) +endforeach diff --git a/tests/nix/libutil/unit/misc/meson.build b/tests/nix/libutil/unit/misc/meson.build new file mode 100644 index 00000000000..fce294a1465 --- /dev/null +++ b/tests/nix/libutil/unit/misc/meson.build @@ -0,0 +1,17 @@ +# libutil.test.misc +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_misc_test = executable( + 'libutil-misc-test', + install : false, + sources : 'misc.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-misc-test', + libutil_misc_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) \ No newline at end of file diff --git a/tests/nix/libutil/unit/pool/meson.build b/tests/nix/libutil/unit/pool/meson.build new file mode 100644 index 00000000000..0a666bc67eb --- /dev/null +++ b/tests/nix/libutil/unit/pool/meson.build @@ -0,0 +1,17 @@ +# libutil.test.pool +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_pool_test = executable( + 'libutil-pool-test', + install : false, + sources : 'pool.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-pool-test', + libutil_pool_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/references/meson.build b/tests/nix/libutil/unit/references/meson.build new file mode 100644 index 00000000000..c7a11083f46 --- /dev/null +++ b/tests/nix/libutil/unit/references/meson.build @@ -0,0 +1,17 @@ +# libutil.test.references +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_references_test = executable( + 'libutil-references-test', + install : false, + sources : 'references.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-references-test', + libutil_references_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) diff --git a/tests/nix/libutil/unit/suggestions/meson.build b/tests/nix/libutil/unit/suggestions/meson.build new file mode 100644 index 00000000000..e5f8f1faa7c --- /dev/null +++ b/tests/nix/libutil/unit/suggestions/meson.build @@ -0,0 +1,17 @@ +# libutil.test.suggestions +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_suggestions_test = executable( + 'libutil-suggestions-test', + install : false, + sources : 'suggestions.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-suggestions-test', + libutil_suggestions_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) \ No newline at end of file diff --git a/tests/nix/libutil/unit/url/meson.build b/tests/nix/libutil/unit/url/meson.build new file mode 100644 index 00000000000..9ce484be103 --- /dev/null +++ b/tests/nix/libutil/unit/url/meson.build @@ -0,0 +1,17 @@ +# libutil.test.url +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_url_test = executable( + 'libutil-url-test', + install : false, + sources : 'url.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-url-test', + libutil_url_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) \ No newline at end of file diff --git a/tests/nix/libutil/unit/xml-writer/meson.build b/tests/nix/libutil/unit/xml-writer/meson.build new file mode 100644 index 00000000000..f1e16983de4 --- /dev/null +++ b/tests/nix/libutil/unit/xml-writer/meson.build @@ -0,0 +1,17 @@ +# libutil.test.xml-writer +# ============================================================================ + +# build test +#--------------------------------------------------- +libutil_xml_writer_test = executable( + 'libutil-xml-writer-test', + install : false, + sources : 'xml-writer.cc', + include_directories : proj_inc, + dependencies : libutil_tests_dep_list) + +test( + 'libutil-xml-writer-test', + libutil_xml_writer_test, + protocol : 'gtest', + suite : ['unit', 'libutil']) \ No newline at end of file diff --git a/tests/nix/meson.build b/tests/nix/meson.build new file mode 100644 index 00000000000..3c39abf9797 --- /dev/null +++ b/tests/nix/meson.build @@ -0,0 +1,12 @@ +# nix unit tests +#============================================================================ + +unit_test_dirs = [ + 'libutil', + 'libstore', + # 'libexpr' + ] + +foreach dir : unit_test_dirs + subdir(dir) +endforeach