diff --git a/dependencies/archive/meson.build b/dependencies/archive/meson.build new file mode 100644 index 000000000000..efdfb26625b7 --- /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 000000000000..8f835aee6a29 --- /dev/null +++ b/dependencies/aws-sdk-cpp/meson.build @@ -0,0 +1,48 @@ +# aws s3 dependency file +#============================================================================ + + +# Look for aws-cpp-sdk, an optional dependency +#-------------------------------------------------- +if get_option('with_s3') + + has_s3client = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') + + aws_version = meson.get_compiler('cpp').get_define( + 'AWS_SDK_VERSION_STRING', + prefix : '#include ' + ).strip('"').split('.') + + aws_sdk_cpp_dep = declare_dependency( + dependencies : [ + dependency('aws-cpp-sdk-core'), + dependency('aws-cpp-sdk-s3'), + dependency('aws-cpp-sdk-transfer')]) + + config_h.set( + 'ENABLE_S3', 1, + description : 'Whether to enable S3 support via aws-sdk-cpp.') + + if has_s3client + config_h.set( + 'HAVE_AWS_S3_S3CLIENT_H', 1, + description : 'Whether to enable S3 support via aws-sdk-cpp.') + endif + + 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.') + +else + aws_sdk_cpp_dep = dependency('', required: false) + config_h.set( + 'ENABLE_S3', 0, + description : 'Whether to enable S3 support via aws-sdk-cpp.') +endif diff --git a/dependencies/bdw-gc/meson.build b/dependencies/bdw-gc/meson.build new file mode 100644 index 000000000000..5d39896a3069 --- /dev/null +++ b/dependencies/bdw-gc/meson.build @@ -0,0 +1,22 @@ +# Boehm-gc Dependency File +#============================================================================ + + +## FIXME !! Boehm is supposed to be an optional dependency +## but is currently required for libexpr & libcmd to compile +## correctly. + + +# Look for Boehm garbage collector, an optional dependency +#-------------------------------------------------- +if get_option('with_gc') + gc_dep = dependency('bdw-gc') +else + gc_dep = dependency('', required: false) +endif + + +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 000000000000..573fca1eaa03 --- /dev/null +++ b/dependencies/boost/meson.build @@ -0,0 +1,20 @@ +# Boost Dependency File +#============================================================================ + + +# Look for boost, a required dependency +#---------------------------------------------------- +boost_mod_list = [ + 'system', + 'context', + 'thread'] + + +boost_dep = dependency( + 'boost', + modules: boost_mod_list) + + +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 000000000000..47885095b7cc --- /dev/null +++ b/dependencies/brotli/meson.build @@ -0,0 +1,15 @@ +# LibBrotli Dependency File +#============================================================================ + + +# Look for libbrotli{enc,dec}, a required dependency +#-------------------------------------------------- +libbrotli_dep = declare_dependency( + dependencies: [ + dependency('libbrotlienc'), + dependency('libbrotlidec')]) + + +config_h.set( + 'HAVE_BROTLI', 1, + description : 'Define if the brotli library is available.') diff --git a/dependencies/bz2/meson.build b/dependencies/bz2/meson.build new file mode 100644 index 000000000000..f32b6c1f6e0a --- /dev/null +++ b/dependencies/bz2/meson.build @@ -0,0 +1,12 @@ +# bz2 Dependency File +#============================================================================ + + +# Look for libbz2, a required dependency +#-------------------------------------------------- +libbz2_dep = cpp.find_library('bz2') + + +config_h.set( + 'HAVE_BZ2', 1, + description : 'Define if the libbz2 is available.') diff --git a/dependencies/cpuid/meson.build b/dependencies/cpuid/meson.build new file mode 100644 index 000000000000..4f96ffb14683 --- /dev/null +++ b/dependencies/cpuid/meson.build @@ -0,0 +1,12 @@ +# cpuid dependency file +#============================================================================ + + +# Look for cpuid, a required dependency +#-------------------------------------------------- +libcpuid_dep = dependency('libcpuid') + + +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 000000000000..f3543f1941b4 --- /dev/null +++ b/dependencies/curl/meson.build @@ -0,0 +1,11 @@ +# LibCurl Dependency File +#============================================================================ + + +# Look for libcurl, a required dependency +#-------------------------------------------------- +libcurl_dep = dependency('libcurl') + +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 000000000000..9e0954bb61d2 --- /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 000000000000..916faa26c1ec --- /dev/null +++ b/dependencies/editline/meson.build @@ -0,0 +1,29 @@ +# 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 (cpp.has_header('editline.h')) + config_h.set( + 'HAVE_EDITLINE_H', 1, + description : 'Define to 1 if you have the header file.') +else + 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 ' +\ + 'it is too old? >= 1.14 is required.') +endif diff --git a/dependencies/functions/meson.build b/dependencies/functions/meson.build new file mode 100644 index 000000000000..a2e5c651c787 --- /dev/null +++ b/dependencies/functions/meson.build @@ -0,0 +1,73 @@ +# nix check functions +#============================================================================ + +if (cpp.has_function('lutimes')) + config_h.set( + 'HAVE_LUTIMES', 1, + description : 'Define to 1 if you have the `lutimes` function.') +endif + +if (cpp.has_function('lchown')) + config_h.set( + 'HAVE_LCHOWN', 1, + description : 'Define to 1 if you have the `lchown` function.') +endif + +if (cpp.has_function('pipe2')) + config_h.set( + 'HAVE_PIPE2', 1, + description : 'Define to 1 if you have the `pipe2` function.') +endif + +if (cpp.has_function('posix_fallocate')) + config_h.set( + 'HAVE_POSIX_FALLOCATE', 1, + description : 'Define to 1 if you have the `posix_fallocate` function.') +endif + +if (cpp.has_function('setresuid')) + config_h.set( + 'HAVE_SETRESUID', 1, + description : 'Define to 1 if you have the `setresuid` function.') +endif + +if (cpp.has_function('setreuid')) + config_h.set( + 'HAVE_SETREUID', 1, + description : 'Define to 1 if you have the `setreuid` function.') +endif + +if (cpp.has_function('statvfs')) + config_h.set( + 'HAVE_STATVFS', 1, + description : 'Define to 1 if you have the `statvfs` function.') +endif + +if (cpp.has_function('strsignal')) + config_h.set( + 'HAVE_STRSIGNAL', 1, + description : 'Define to 1 if you have the `strsignal` function.') +endif + +if (cpp.has_function('sysconf')) + config_h.set( + 'HAVE_SYSCONF', 1, + description : 'Define to 1 if you have the `sysconf` function.') +endif + +pubsetbuff_c = ''' +#include +using namespace std; +static char buf[1024]; +void func() { +cerr.rdbuf()->pubsetbuf(buf, sizeof(buf)); +}''' + +if meson.get_compiler('cpp').compiles( + pubsetbuff_c, + name : 'pubsetbuf' + ) + config_h.set( + 'HAVE_PUBSETBUF', 1, + description : 'Define to 1 if you have the `pubsetbuf` function.') +endif diff --git a/dependencies/gtest/meson.build b/dependencies/gtest/meson.build new file mode 100644 index 000000000000..29a41ac1549a --- /dev/null +++ b/dependencies/gtest/meson.build @@ -0,0 +1,17 @@ +# gtest Dependency File +#======================================================================== + + +# check if gtest is already installed +#--------------------------------------------------- +gtest_dep = dependency( + 'gtest', + required : false) + + +# If not, include the submodule +#--------------------------------------------------- +if not gtest_dep.found() + gtest_proj = cmake.subproject('gtest') + gtest_dep = gtest_proj.dependency('gtest') +endif diff --git a/dependencies/headers/meson.build b/dependencies/headers/meson.build new file mode 100644 index 000000000000..a25bd3167d32 --- /dev/null +++ b/dependencies/headers/meson.build @@ -0,0 +1,99 @@ +# nix check headers +#============================================================================ + +if (cpp.has_header('sys/stat.h')) + config_h.set( + 'HAVE_SYS_STAT_H', 1, + description : 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('sys/types.h')) + config_h.set( + 'HAVE_SYS_TYPES_H', 1, + description : 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('sys/dir.h')) + config_h.set( + 'HAVE_DIR_H', 1, + description : 'Define to 1 if you have the header file, and it defines `DIR`') +endif + +if (cpp.has_header('sys/ndir.h')) + config_h.set( + 'HAVE_NDIR_H', 1, + description : 'Define to 1 if you have the header file, and it defines `DIR`') +endif + +has_dirent_h = cpp.has_header('dirent.h') +if (has_dirent_h) + config_h.set( + 'HAVE_DIRENT_H', 1, + description : 'Define to 1 if you have the header file, and it defines `DIR`') +endif + +if (cpp.has_header('locale.h')) + config_h.set( + 'HAVE_LOCALE', 1, + description : 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('unistd.h')) + config_h.set( + 'HAVE_UNISTD_H', 1, + description: 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('stdint.h')) + config_h.set( + 'HAVE_STDINT_H', 1, + description: 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('stdlib.h')) + config_h.set( + 'HAVE_STDLIB_H', 1, + description: 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('strings.h')) + config_h.set( + 'HAVE_STRINGS_H', 1, + description: 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('string.h')) + config_h.set( + 'HAVE_STRING_H', 1, + description: 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('bzlib.h')) + config_h.set( + 'HAVE_BZLIB_H', 1, + description : 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('inttypes.h')) + config_h.set( + 'HAVE_INTTYPES_H', 1, + description : 'Define to 1 if you have the header file.') +endif + +if (cpp.has_header('memory.h')) + config_h.set( + 'HAVE_MEMORY_H', 1, + description : 'Define to 1 if you have the header file.') +endif + +dirent_h_prefix = ''' + #include + #include +''' + +check_struct_dirent = meson.get_compiler('cpp').has_member( + 'struct dirent', 'd_type', prefix: dirent_h_prefix) + +if ((has_dirent_h) and (check_struct_dirent)) + config_h.set('HAVE_STRUCT_DIRENT_D_TYPE', 1) +endif diff --git a/dependencies/lowdown/meson.build b/dependencies/lowdown/meson.build new file mode 100644 index 000000000000..a30ff2760c1b --- /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 = cpp.find_library('lowdown') \ No newline at end of file diff --git a/dependencies/lzma/meson.build b/dependencies/lzma/meson.build new file mode 100644 index 000000000000..a066e3315d04 --- /dev/null +++ b/dependencies/lzma/meson.build @@ -0,0 +1,21 @@ +# LibLzma Dependency File +#============================================================================ + + +# Look for liblzma, a required dependency +#-------------------------------------------------- +liblzma_dep = dependency('liblzma') + + +check_lzma_mt = cpp.has_function( + 'lzma_stream_encoder_mt', + dependencies : liblzma_dep) + +config_h.set( + 'HAVE_LZMA', 1, + description : 'Define if the lzma library is available.') + +config_h.set( + 'HAVE_LZMA_MT', + check_lzma_mt.to_int(), + description : 'Define if lzma_stream_encoder_mt is available.') diff --git a/dependencies/meson.build b/dependencies/meson.build new file mode 100644 index 000000000000..9edfcb7b50ff --- /dev/null +++ b/dependencies/meson.build @@ -0,0 +1,48 @@ +# nix dependencies build file +#============================================================================ + + +# declare dependency types +#--------------------------------------------------- +required_dep_dirs = [ + 'archive', + 'boost', + 'brotli', + 'bz2', + 'cpuid', + 'curl', + 'dl', + 'editline', + 'lzma', + 'lowdown', + 'nlohmann', + 'openssl', + 'seccomp', + 'sqlite', + 'pthread', + 'zlib'] + +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/meson.build b/dependencies/nlohmann/meson.build new file mode 100644 index 000000000000..e2b1cf8ebf63 --- /dev/null +++ b/dependencies/nlohmann/meson.build @@ -0,0 +1,8 @@ +# nlohmann Dependency File +#============================================================================ + + +# Look for nlohmann, 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 000000000000..b2b12af6eb12 --- /dev/null +++ b/dependencies/openssl/meson.build @@ -0,0 +1,12 @@ +# OpenSSL Dependency File +#============================================================================ + + +# Look for OpenSSL, a required dependency +#-------------------------------------------------- +openssl_dep = dependency('openssl') + + +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 000000000000..7b4f7b6c849c --- /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/seccomp/meson.build b/dependencies/seccomp/meson.build new file mode 100644 index 000000000000..e6f514236fc5 --- /dev/null +++ b/dependencies/seccomp/meson.build @@ -0,0 +1,20 @@ +# 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 + + +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 000000000000..4edc0e06fd62 --- /dev/null +++ b/dependencies/sodium/meson.build @@ -0,0 +1,15 @@ +# 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. + +# look for libsodium, an required dependency +#-------------------------------------------------- +libsodium_dep = cpp.find_library('sodium') + + +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 000000000000..9d0df7c52365 --- /dev/null +++ b/dependencies/sqlite/meson.build @@ -0,0 +1,14 @@ +# SQLite Dependency File +#============================================================================ + + +# Look for sqlite3, a required dependency +#-------------------------------------------------- +sqlite3_dep = declare_dependency( + dependencies: cpp.find_library('sqlite3'), + version : '>= 3.6.19') + + +config_h.set( + 'HAVE_SQLITE', 1, + description : 'Define if the SQLite3 is available.') diff --git a/dependencies/zlib/meson.build b/dependencies/zlib/meson.build new file mode 100644 index 000000000000..a25b4ee1af73 --- /dev/null +++ b/dependencies/zlib/meson.build @@ -0,0 +1,10 @@ +# ZLib Dependency File +#============================================================================ + +# Look for zlib, a required dependency +#---------------------------------------------------- +zlib_dep = dependency('zlib') + +config_h.set( + 'HAVE_ZLIB', 1, + description : 'Define if the Zlib library is available.') diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/include/config_h/meson.build b/include/config_h/meson.build new file mode 100644 index 000000000000..d50b5a5b8891 --- /dev/null +++ b/include/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('.') \ No newline at end of file diff --git a/include/macros/meson.build b/include/macros/meson.build new file mode 100644 index 000000000000..fc98a71a8e1b --- /dev/null +++ b/include/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/include/meson.build b/include/meson.build new file mode 100644 index 000000000000..b15ec3ac1646 --- /dev/null +++ b/include/meson.build @@ -0,0 +1,18 @@ +# include build file +#======================================================================== + +include_dir = meson.current_source_dir() +proj_inc += include_directories('.') + +# include directories +#======================================================================== + + +include_dirs = [ + 'config_h', + 'macros'] + + +foreach dir : include_dirs + subdir(dir) +endforeach diff --git a/meson.build b/meson.build new file mode 100644 index 000000000000..9cc8d0247257 --- /dev/null +++ b/meson.build @@ -0,0 +1,220 @@ +# Nix project build file +#============================================================================ + + +# init +#============================================================================ + + +# init project +#------------------------------------------------- +project( + 'nix', + ['cpp', 'rust'], + meson_version : '>= 0.57.0', + default_options : [ + 'cpp_std=c++17', + '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') + + +cmake = import('cmake') +pkg = import('pkgconfig') + + +# 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')) +includedir = join_paths(prefix, get_option('includedir')) +proj_inc = [] + +# 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) +xmllint = find_program('xmllint', 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.path()).stdout().strip() + + +# 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 +#============================================================================ +if sys_name == 'freebsd' + add_project_arguments('-D_GNU_SOURCE', language : 'cpp') + config_h.set('_GNU_SOURCE', 1) +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', + 'include', + 'src', + 'scripts', + #'misc', + #'doc', + #'tests' + ] + + +foreach dir : project_dirs + subdir(dir) +endforeach diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000000..791420653792 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,91 @@ +# Nix project build options +#============================================================================ + +# dirs +#============================================================================ + +option( + 'nixstoredir', + type : 'string', + value : '/nix/store', + description : 'path of the Nix store (defaults to /nix/store)') + + +# 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') + + +# optional dependencies +#============================================================================ + +option( + 'with_gc', + type : 'boolean', + value : 'true', + description : 'Build nix with Boehm garbage collector') + +option( + 'with_libsodium', + type : 'feature', + value : 'auto', + description : 'Build nix with libsodium') + +option( + 'with_s3', + type : 'boolean', + value : 'false', + description : 'Build nix with s3') + +option( + 'with_coreutils_bin', + type : 'string', + description : 'path of cat, mkdir, etc.') + + +# misc +#============================================================================ +option( + 'disable_doc_gen', + type : 'boolean', + value : 'false', + description : 'disable documentation generation') + +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`.') diff --git a/misc/meson.build b/misc/meson.build new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/scripts/meson.build b/scripts/meson.build new file mode 100644 index 000000000000..1820ae4b9caf --- /dev/null +++ b/scripts/meson.build @@ -0,0 +1,74 @@ +# Nix corepkgs build file +#============================================================================ + +scripts_dir = meson.current_source_dir() +scripts_inc = [include_directories('.')] + + +# src files +#============================================================================ + +scripts_data = files( + join_paths(scripts_dir, 'install-darwin-multi-user.sh'), + join_paths(scripts_dir, 'install-multi-user.sh')) + + +# targets +#============================================================================ + +nix_profile_sh = configuration_data() +nix_profile_sh.set('localstatedir', localstatedir) +nix_profile_sh.set('coreutils', coreutils) + +nix_http_export_cgi = configuration_data() +nix_http_export_cgi.set('bindir', bindir) +nix_http_export_cgi.set('localstatedir', localstatedir) +nix_http_export_cgi.set('coreutils', coreutils) +nix_http_export_cgi.set('gzip', gzip.path()) + +nix_reduce_build = configuration_data() +nix_reduce_build.set('bash', bash.path()) +nix_reduce_build.set('bindir', bindir) +nix_reduce_build.set('localstatedir', localstatedir) + + +# TODO: make these work +nix_install = configuration_data() +nix_install.set('nixVersion', package_version) +nix_install.set('binaryTarball_x86_64-linux', '') +nix_install.set('binaryTarball_i686-linux', '') +nix_install.set('binaryTarball_aarch64-linux', '') +nix_install.set('binaryTarball_x86_64-darwin', '') + + +# build +#============================================================================ + +# configure scripts +#--------------------------------------------------- +scripts_data += configure_file( + input : 'nix-profile.sh.in', + output : 'nix.sh', + configuration : nix_profile_sh) + +scripts_data += configure_file( + input : 'nix-profile-daemon.sh.in', + output : 'nix-daemon.sh', + configuration : nix_profile_sh) + +scripts_data += configure_file( + input : 'nix-http-export.cgi.in', + output : 'nix-http-export.cgi', + configuration : nix_http_export_cgi) + +scripts_data += configure_file( + input : 'nix-reduce-build.in', + output : 'nix-reduce-build', + configuration : nix_reduce_build) + +# install scripts +#--------------------------------------------------- +install_data( + scripts_data, + install_mode : 'rwxr-xr-x', + install_dir : profiledir) diff --git a/src/build-remote/meson.build b/src/build-remote/meson.build new file mode 100644 index 000000000000..93ce1608bbf9 --- /dev/null +++ b/src/build-remote/meson.build @@ -0,0 +1,15 @@ +# build-remote build file +#============================================================================ + +build_remote_dir = meson.current_source_dir() +build_remote_inc = [include_directories('.')] + + +# src files +#============================================================================ + +build_remote_src = files( + join_paths(build_remote_dir, 'build-remote.cc')) + + +build_remote_headers = files() diff --git a/src/cpptoml/meson.build b/src/cpptoml/meson.build new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build new file mode 100644 index 000000000000..1f5bee02affe --- /dev/null +++ b/src/libcmd/meson.build @@ -0,0 +1,81 @@ +# libmain build file +#============================================================================ + +libcmd_dir = meson.current_source_dir() +libcmd_inc = [include_directories('.')] + + +# dependencies +#============================================================================ + +libcmd_dep_list = [ + gc_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( + join_paths(libcmd_dir, 'command.cc'), + join_paths(libcmd_dir, 'installables.cc'), + join_paths(libcmd_dir, 'legacy.cc'), + join_paths(libcmd_dir, 'markdown.cc')) + + +libcmd_headers = files( + join_paths(libcmd_dir, 'command.hh'), + join_paths(libcmd_dir, 'installables.hh'), + join_paths(libcmd_dir, 'legacy.hh'), + join_paths(libcmd_dir, 'markdown.hh')) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libcmd_cxx_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) + \ No newline at end of file diff --git a/src/libexpr/flake/meson.build b/src/libexpr/flake/meson.build new file mode 100644 index 000000000000..3d6e8daf90da --- /dev/null +++ b/src/libexpr/flake/meson.build @@ -0,0 +1,31 @@ +# Nix lib expr build file +#============================================================================ + + +libexpr_priomops_dir = meson.current_source_dir() + +# src files +#============================================================================ + +libexpr_inc += include_directories('.') + +libexpr_src += files( + join_paths(libexpr_priomops_dir, 'config.cc'), + join_paths(libexpr_priomops_dir, 'flake.cc'), + join_paths(libexpr_priomops_dir, 'flakeref.cc'), + join_paths(libexpr_priomops_dir, 'lockfile.cc')) + +libexpr_headers += files( + join_paths(libexpr_priomops_dir, 'flake.hh'), + join_paths(libexpr_priomops_dir, 'flakeref.hh'), + join_paths(libexpr_priomops_dir, '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/src/libexpr/meson.build b/src/libexpr/meson.build new file mode 100644 index 000000000000..73751c81462d --- /dev/null +++ b/src/libexpr/meson.build @@ -0,0 +1,168 @@ +# Nix lib expr build file +#============================================================================ + +libexpr_dir = meson.current_source_dir() +libexpr_inc = proj_inc + + +# dependencies +#============================================================================ + +libexpr_dep_list = [ + boost_dep, + libdl_dep, + libsodium_dep, + gc_dep, + + libutil_dep, + libstore_dep, + libmain_dep, + libfetchers_dep] + + +# src files +#============================================================================ + +libexpr_src = files( + join_paths(libexpr_dir, 'attr-path.cc'), + join_paths(libexpr_dir, 'attr-set.cc'), + join_paths(libexpr_dir, 'common-eval-args.cc'), + join_paths(libexpr_dir, 'eval-cache.cc'), + join_paths(libexpr_dir, 'eval.cc'), + join_paths(libexpr_dir, 'function-trace.cc'), + join_paths(libexpr_dir, 'get-drvs.cc'), + join_paths(libexpr_dir, 'json-to-value.cc'), + join_paths(libexpr_dir, 'nixexpr.cc'), + join_paths(libexpr_dir, 'primops.cc'), + join_paths(libexpr_dir, 'value-to-json.cc'), + join_paths(libexpr_dir, 'value-to-xml.cc')) + + +libexpr_headers = files( + join_paths(libexpr_dir, 'attr-path.hh'), + join_paths(libexpr_dir, 'attr-set.hh'), + join_paths(libexpr_dir, 'common-eval-args.hh'), + join_paths(libexpr_dir, 'eval-cache.hh'), + join_paths(libexpr_dir, 'eval.hh'), + join_paths(libexpr_dir, 'eval-inline.hh'), + join_paths(libexpr_dir, 'function-trace.hh'), + join_paths(libexpr_dir, 'get-drvs.hh'), + join_paths(libexpr_dir, 'json-to-value.hh'), + join_paths(libexpr_dir, 'nixexpr.hh'), + join_paths(libexpr_dir, 'primops.hh'), + join_paths(libexpr_dir, 'symbol-table.hh'), + join_paths(libexpr_dir, 'value.hh'), + join_paths(libexpr_dir, 'value-to-json.hh'), + join_paths(libexpr_dir, 'value-to-xml.hh')) + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libexpr_inc += include_directories('.') + + +# add subdirectories +#--------------------------------------------------- +libexpr_dirs = [ + 'flake', + 'primops'] + +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 += 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@']) + + +libexpr_src += custom_target( + 'fetchurl.nix.gen.hh', + output : 'fetchurl.nix.gen.hh', + input : 'fetchurl.nix', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libexpr_cxx_args = [] + +libexpr_link_args = [] + + +# build library +#--------------------------------------------------- +libexpr_lib = library( + 'nixexpr', + sources : libexpr_src, + 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 = pkg.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/src/libexpr/primops/meson.build b/src/libexpr/primops/meson.build new file mode 100644 index 000000000000..0423bc6093a4 --- /dev/null +++ b/src/libexpr/primops/meson.build @@ -0,0 +1,26 @@ +# Nix lib expr build file +#============================================================================ + + +libexpr_priomops_dir = meson.current_source_dir() + +# src files +#============================================================================ + +libexpr_inc += include_directories('.') + +libexpr_src += files( + join_paths(libexpr_priomops_dir, 'context.cc'), + join_paths(libexpr_priomops_dir, 'fetchMercurial.cc'), + join_paths(libexpr_priomops_dir, 'fetchTree.cc'), + join_paths(libexpr_priomops_dir, '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/src/libfetchers/meson.build b/src/libfetchers/meson.build new file mode 100644 index 000000000000..a259325457c9 --- /dev/null +++ b/src/libfetchers/meson.build @@ -0,0 +1,109 @@ +# libfetchers build file +#============================================================================ + +libfetchers_dir = meson.current_source_dir() +libfetchers_inc = [] + +# dependencies +#============================================================================ + +libfetchers_dep_list = [ + libbz2_dep, + libcurl_dep, + libdl_dep, + libseccomp_dep, + libsodium_dep, + #nlohmann_dep, + pthread_dep, + sqlite3_dep, + + libutil_dep, + libstore_dep] + + +# src files +#============================================================================ + +libfetchers_src = files( + join_paths(libfetchers_dir, 'attrs.cc'), + join_paths(libfetchers_dir, 'cache.cc'), + join_paths(libfetchers_dir, 'fetchers.cc'), + join_paths(libfetchers_dir, 'git.cc'), + join_paths(libfetchers_dir, 'github.cc'), + join_paths(libfetchers_dir, 'indirect.cc'), + join_paths(libfetchers_dir, 'mercurial.cc'), + join_paths(libfetchers_dir, 'path.cc'), + join_paths(libfetchers_dir, 'registry.cc'), + join_paths(libfetchers_dir, 'tarball.cc')) + +libfetchers_headers = files( + join_paths(libfetchers_dir, 'attrs.hh'), + join_paths(libfetchers_dir, 'cache.hh'), + join_paths(libfetchers_dir, 'fetchers.hh'), + join_paths(libfetchers_dir, 'registry.hh')) + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libfetchers_inc += include_directories('.') + + +# targets +#============================================================================ + + +# 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 = pkg.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/src/libmain/meson.build b/src/libmain/meson.build new file mode 100644 index 000000000000..9c8e03a35974 --- /dev/null +++ b/src/libmain/meson.build @@ -0,0 +1,86 @@ +# libmain build file +#============================================================================ + +libmain_dir = meson.current_source_dir() +libmain_inc = [] + + +# dependencies +#============================================================================ + +libmain_dep_list = [ + pthread_dep, + openssl_dep, + libsodium_dep, + + libutil_dep, + libstore_dep] + + +# src files +#============================================================================ + +libmain_src = files( + join_paths(libmain_dir, 'common-args.cc'), + join_paths(libmain_dir, 'loggers.cc'), + join_paths(libmain_dir, 'progress-bar.cc'), + join_paths(libmain_dir, 'shared.cc'), + join_paths(libmain_dir, 'stack.cc')) + + +libmain_headers = files( + join_paths(libmain_dir, 'common-args.hh'), + join_paths(libmain_dir, 'loggers.hh'), + join_paths(libmain_dir, 'progress-bar.hh'), + join_paths(libmain_dir, 'shared.hh')) + + +# include directories +#======================================================================== + +# include current dir +#--------------------------------------------------- +libmain_inc += include_directories('.') + + +# 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/src/libstore/build/meson.build b/src/libstore/build/meson.build new file mode 100644 index 000000000000..a5a255e88211 --- /dev/null +++ b/src/libstore/build/meson.build @@ -0,0 +1,27 @@ +# libstore.build build file +#============================================================================ + +libutil_build_dir = meson.current_source_dir() +libstore_inc += include_directories('.') + + +# src files +#============================================================================ + +libstore_src += files( + join_paths(libutil_build_dir, 'derivation-goal.cc'), + join_paths(libutil_build_dir, 'entry-points.cc'), + join_paths(libutil_build_dir, 'goal.cc'), + join_paths(libutil_build_dir, 'hook-instance.cc'), + join_paths(libutil_build_dir, 'local-derivation-goal.cc'), + join_paths(libutil_build_dir, 'substitution-goal.cc'), + join_paths(libutil_build_dir, 'worker.cc')) + + +libstore_headers += files( + join_paths(libutil_build_dir, 'derivation-goal.hh'), + join_paths(libutil_build_dir, 'goal.hh'), + join_paths(libutil_build_dir, 'hook-instance.hh'), + join_paths(libutil_build_dir, 'local-derivation-goal.hh'), + join_paths(libutil_build_dir, 'substitution-goal.hh'), + join_paths(libutil_build_dir, 'worker.hh')) \ No newline at end of file diff --git a/src/libstore/builtins/meson.build b/src/libstore/builtins/meson.build new file mode 100644 index 000000000000..b551e12d3dc6 --- /dev/null +++ b/src/libstore/builtins/meson.build @@ -0,0 +1,18 @@ +# libstore.builtins build file +#============================================================================ + +libutil_builtins_dir = meson.current_source_dir() +libstore_inc += include_directories('.') + + +# src files +#============================================================================ + +libstore_src += files( + join_paths(libutil_builtins_dir, 'buildenv.cc'), + join_paths(libutil_builtins_dir, 'fetchurl.cc'), + join_paths(libutil_builtins_dir, 'unpack-channel.cc')) + + +libstore_headers += files( + join_paths(libutil_builtins_dir, 'buildenv.hh')) diff --git a/src/libstore/meson.build b/src/libstore/meson.build new file mode 100644 index 000000000000..ec2e40616df3 --- /dev/null +++ b/src/libstore/meson.build @@ -0,0 +1,202 @@ +# libstore build file +#============================================================================ + +libstore_dir = meson.current_source_dir() +libstore_inc = [include_directories('.')] + +# dependencies +#============================================================================ + +libstore_dep_list = [ + aws_sdk_cpp_dep, + libbz2_dep, + libcurl_dep, + libdl_dep, + libseccomp_dep, + libsodium_dep, + nlohmann_dep, + pthread_dep, + sqlite3_dep, + + libutil_dep] + + +# src files +#============================================================================ + +libstore_src = files( + join_paths(libstore_dir, 'binary-cache-store.cc'), + join_paths(libstore_dir, 'content-address.cc'), + join_paths(libstore_dir, 'crypto.cc'), + join_paths(libstore_dir, 'daemon.cc'), + join_paths(libstore_dir, 'derivations.cc'), + join_paths(libstore_dir, 'dummy-store.cc'), + join_paths(libstore_dir, 'export-import.cc'), + join_paths(libstore_dir, 'filetransfer.cc'), + join_paths(libstore_dir, 'gc.cc'), + join_paths(libstore_dir, 'globals.cc'), + join_paths(libstore_dir, 'http-binary-cache-store.cc'), + join_paths(libstore_dir, 'legacy-ssh-store.cc'), + join_paths(libstore_dir, 'local-binary-cache-store.cc'), + join_paths(libstore_dir, 'local-fs-store.cc'), + join_paths(libstore_dir, 'local-store.cc'), + join_paths(libstore_dir, 'lock.cc'), + join_paths(libstore_dir, 'machines.cc'), + join_paths(libstore_dir, 'misc.cc'), + join_paths(libstore_dir, 'names.cc'), + join_paths(libstore_dir, 'nar-accessor.cc'), + join_paths(libstore_dir, 'nar-info.cc'), + join_paths(libstore_dir, 'nar-info-disk-cache.cc'), + join_paths(libstore_dir, 'optimise-store.cc'), + join_paths(libstore_dir, 'parsed-derivations.cc'), + join_paths(libstore_dir, 'path.cc'), + join_paths(libstore_dir, 'pathlocks.cc'), + join_paths(libstore_dir, 'profiles.cc'), + join_paths(libstore_dir, 'realisation.cc'), + join_paths(libstore_dir, 'references.cc'), + join_paths(libstore_dir, 'remote-fs-accessor.cc'), + join_paths(libstore_dir, 'remote-store.cc'), + join_paths(libstore_dir, 's3-binary-cache-store.cc'), + join_paths(libstore_dir, 'sqlite.cc'), + join_paths(libstore_dir, 'ssh.cc'), + join_paths(libstore_dir, 'ssh-store.cc'), + join_paths(libstore_dir, 'store-api.cc'), + join_paths(libstore_dir, 'uds-remote-store.cc')) + +libstore_headers = files( + join_paths(libstore_dir, 'binary-cache-store.hh'), + join_paths(libstore_dir, 'builtins.hh'), + join_paths(libstore_dir, 'crypto.hh'), + join_paths(libstore_dir, 'daemon.hh'), + join_paths(libstore_dir, 'derivations.hh'), + join_paths(libstore_dir, 'filetransfer.hh'), + join_paths(libstore_dir, 'fs-accessor.hh'), + join_paths(libstore_dir, 'globals.hh'), + join_paths(libstore_dir, 'local-store.hh'), + join_paths(libstore_dir, 'machines.hh'), + join_paths(libstore_dir, 'names.hh'), + join_paths(libstore_dir, 'nar-accessor.hh'), + join_paths(libstore_dir, 'nar-info-disk-cache.hh'), + join_paths(libstore_dir, 'nar-info.hh'), + join_paths(libstore_dir, 'parsed-derivations.hh'), + join_paths(libstore_dir, 'path.hh'), + join_paths(libstore_dir, 'pathlocks.hh'), + join_paths(libstore_dir, 'profiles.hh'), + join_paths(libstore_dir, 'references.hh'), + join_paths(libstore_dir, 'remote-fs-accessor.hh'), + join_paths(libstore_dir, 'remote-store.hh'), + join_paths(libstore_dir, 's3-binary-cache-store.hh'), + join_paths(libstore_dir, 's3.hh'), + join_paths(libstore_dir, 'serve-protocol.hh'), + join_paths(libstore_dir, 'sqlite.hh'), + join_paths(libstore_dir, 'ssh.hh'), + join_paths(libstore_dir, 'store-api.hh'), + join_paths(libstore_dir, 'worker-protocol.hh')) + + +libstore_data = files( + join_paths(libstore_dir, 'sandbox-defaults.sb'), + join_paths(libstore_dir, 'sandbox-minimal.sb'), + join_paths(libstore_dir, 'sandbox-network.sb')) + + +# 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)] + +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 = pkg.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/src/libutil/meson.build b/src/libutil/meson.build new file mode 100644 index 000000000000..901d05101822 --- /dev/null +++ b/src/libutil/meson.build @@ -0,0 +1,131 @@ +# libutil build file +#============================================================================ + +libutil_dir = meson.current_source_dir() +libutil_inc = [include_directories('.')] + + +# dependencies +#============================================================================ + +libutil_dep_list = [ + aws_sdk_cpp_dep, + boost_dep, + libarchive_dep, + libbz2_dep, + libbrotli_dep, + libcpuid_dep, + liblzma_dep, + libsodium_dep, + nlohmann_dep, + openssl_dep, + pthread_dep, + zlib_dep + ] + + +# src files +#============================================================================ + +libutil_src = files( + join_paths(libutil_dir, 'affinity.cc'), + join_paths(libutil_dir, 'archive.cc'), + join_paths(libutil_dir, 'args.cc'), + join_paths(libutil_dir, 'compression.cc'), + join_paths(libutil_dir, 'compute-levels.cc'), + join_paths(libutil_dir, 'config.cc'), + join_paths(libutil_dir, 'error.cc'), + join_paths(libutil_dir, 'hash.cc'), + join_paths(libutil_dir, 'json.cc'), + join_paths(libutil_dir, 'logging.cc'), + join_paths(libutil_dir, 'rust-ffi.cc'), + join_paths(libutil_dir, 'serialise.cc'), + join_paths(libutil_dir, 'tarfile.cc'), + join_paths(libutil_dir, 'thread-pool.cc'), + join_paths(libutil_dir, 'url.cc'), + join_paths(libutil_dir, 'util.cc'), + join_paths(libutil_dir, 'xml-writer.cc')) + +libutil_headers = files( + join_paths(libutil_dir, 'abstract-setting-to-json.hh'), + join_paths(libutil_dir, 'affinity.hh'), + join_paths(libutil_dir, 'ansicolor.hh'), + join_paths(libutil_dir, 'archive.hh'), + join_paths(libutil_dir, 'args.hh'), + join_paths(libutil_dir, 'callback.hh'), + join_paths(libutil_dir, 'comparator.hh'), + join_paths(libutil_dir, 'compression.hh'), + join_paths(libutil_dir, 'compute-levels.hh'), + join_paths(libutil_dir, 'config.hh'), + join_paths(libutil_dir, 'error.hh'), + join_paths(libutil_dir, 'finally.hh'), + join_paths(libutil_dir, 'fmt.hh'), + join_paths(libutil_dir, 'hash.hh'), + join_paths(libutil_dir, 'json.hh'), + join_paths(libutil_dir, 'logging.hh'), + join_paths(libutil_dir, 'lru-cache.hh'), + join_paths(libutil_dir, 'monitor-fd.hh'), + join_paths(libutil_dir, 'pool.hh'), + join_paths(libutil_dir, 'ref.hh'), + join_paths(libutil_dir, 'rust-ffi.hh'), + join_paths(libutil_dir, 'serialise.hh'), + join_paths(libutil_dir, 'split.hh'), + join_paths(libutil_dir, 'sync.hh'), + join_paths(libutil_dir, 'tarfile.hh'), + join_paths(libutil_dir, 'thread-pool.hh'), + join_paths(libutil_dir, 'topo-sort.hh'), + join_paths(libutil_dir, 'types.hh'), + join_paths(libutil_dir, 'url.hh'), + join_paths(libutil_dir, 'url-parts.hh'), + join_paths(libutil_dir, 'util.hh'), + join_paths(libutil_dir, 'xml-writer.hh')) + + +# 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 : [ + libutil_inc, + 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) + + +# FIXME!!! tests should not be declared inside the +# build directory, but should be moved to a seperate test +# directory. for now, we just include it here. + + +# add test dir +#--------------------------------------------------- +subdir('tests') diff --git a/src/libutil/tests/main.cc b/src/libutil/tests/main.cc new file mode 100644 index 000000000000..0aa2fdad8789 --- /dev/null +++ b/src/libutil/tests/main.cc @@ -0,0 +1,12 @@ +#pragma once + +#include + +using namespace std; + +int main(int argc, char * * argv) +{ + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/src/libutil/tests/meson.build b/src/libutil/tests/meson.build new file mode 100644 index 000000000000..5f0607fd8ac6 --- /dev/null +++ b/src/libutil/tests/meson.build @@ -0,0 +1,54 @@ +# libutil.tests build file +#============================================================================ + +libutil_tests_dir = meson.current_source_dir() +libutil_tests_inc = [include_directories('.')] + +# dependancies +#============================================================================ + +libutil_tests_dep_list = [ + gtest_dep, + + libutil_dep] + + +# src files +#============================================================================ + +libutil_tests_src = files( + join_paths(libutil_tests_dir, 'compression.cc'), + join_paths(libutil_tests_dir, 'config.cc'), + join_paths(libutil_tests_dir, 'hash.cc'), + join_paths(libutil_tests_dir, 'json.cc'), + join_paths(libutil_tests_dir, 'logging.cc'), + join_paths(libutil_tests_dir, 'lru-cache.cc'), + join_paths(libutil_tests_dir, 'main.cc'), + join_paths(libutil_tests_dir, 'pool.cc'), + join_paths(libutil_tests_dir, 'tests.cc'), + join_paths(libutil_tests_dir, 'url.cc'), + join_paths(libutil_tests_dir, 'xml-writer.cc')) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +libutil_tests_cxx_args = [] + +libutil_tests_link_args = [] + + +# build executable +#--------------------------------------------------- +libutil_tests_bin = executable( + 'libutil-tests', + sources : libutil_tests_src, + install : false, + include_directories : proj_inc, + cpp_args : libutil_tests_cxx_args, + link_args : libutil_tests_link_args, + dependencies : libutil_tests_dep_list) + +test('libutil-tests', libutil_tests_bin) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000000..7ceddfa08b76 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,51 @@ +# nix src build file +#============================================================================ + +src_dirs = [ + 'libutil', + 'libstore', + 'libmain', + 'libfetchers', + 'libexpr', + 'libcmd', + + 'build-remote', + 'nix-build', + 'nix-channel', + 'nix-collect-garbage', + 'nix-copy-closure', + 'nix-env', + 'nix-instantiate', + 'nix-store', + 'nix'] + +if sys_name == 'Darwin' + src_dirs += 'resolve-system-dependencies' +endif + +foreach dir : src_dirs + subdir(dir) +endforeach + + +# libstore_config = pkg.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.') + +# libmain_config = pkg.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/src/nix-build/meson.build b/src/nix-build/meson.build new file mode 100644 index 000000000000..303e45741b6f --- /dev/null +++ b/src/nix-build/meson.build @@ -0,0 +1,12 @@ +# nix-build build file +#============================================================================ + +nix_build_dir = meson.current_source_dir() +nix_build_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_build_src = files( + join_paths(nix_build_dir, 'nix-build.cc')) diff --git a/src/nix-channel/meson.build b/src/nix-channel/meson.build new file mode 100644 index 000000000000..0e072c585d4e --- /dev/null +++ b/src/nix-channel/meson.build @@ -0,0 +1,21 @@ +# nix-channel channel file +#============================================================================ + +nix_channel_dir = meson.current_source_dir() +nix_channel_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_channel_src = files( + join_paths(nix_channel_dir, '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/src/nix-collect-garbage/meson.build b/src/nix-collect-garbage/meson.build new file mode 100644 index 000000000000..9aa31dda8dd9 --- /dev/null +++ b/src/nix-collect-garbage/meson.build @@ -0,0 +1,12 @@ +# build-remote build file +#============================================================================ + +nix_collect_garbage_dir = meson.current_source_dir() +nix_collect_garbage_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_collect_garbage_src = files( + join_paths(nix_collect_garbage_dir, 'nix-collect-garbage.cc')) diff --git a/src/nix-copy-closure/meson.build b/src/nix-copy-closure/meson.build new file mode 100644 index 000000000000..0df4a6faba4e --- /dev/null +++ b/src/nix-copy-closure/meson.build @@ -0,0 +1,12 @@ +# nix-copy-closure build file +#============================================================================ + +nix_copy_closure_dir = meson.current_source_dir() +nix_copy_closure_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_copy_closure_src = files( + join_paths(nix_copy_closure_dir, 'nix-copy-closure.cc')) diff --git a/src/nix-env/meson.build b/src/nix-env/meson.build new file mode 100644 index 000000000000..502b58724748 --- /dev/null +++ b/src/nix-env/meson.build @@ -0,0 +1,21 @@ +# nix-env build file +#============================================================================ + +nix_env_dir = meson.current_source_dir() +nix_env_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_env_src = files( + join_paths(nix_env_dir, 'nix-env.cc'), + join_paths(nix_env_dir, '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/src/nix-instantiate/meson.build b/src/nix-instantiate/meson.build new file mode 100644 index 000000000000..a394a82835a3 --- /dev/null +++ b/src/nix-instantiate/meson.build @@ -0,0 +1,12 @@ +# nix-instantiate build file +#============================================================================ + +nix_instantiate_dir = meson.current_source_dir() +nix_instantiate_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_instantiate_src = files( + join_paths(nix_instantiate_dir, 'nix-instantiate.cc')) diff --git a/src/nix-store/meson.build b/src/nix-store/meson.build new file mode 100644 index 000000000000..0b0797dc87b5 --- /dev/null +++ b/src/nix-store/meson.build @@ -0,0 +1,14 @@ +# nix-store build file +#============================================================================ + +nix_store_dir = meson.current_source_dir() +nix_store_inc = [include_directories('.')] + + +# src files +#============================================================================ + +nix_store_src = files( + join_paths(nix_store_dir, 'dotgraph.cc'), + join_paths(nix_store_dir, 'graphml.cc'), + join_paths(nix_store_dir, 'nix-store.cc')) diff --git a/src/nix/meson.build b/src/nix/meson.build new file mode 100644 index 000000000000..c9ed807138de --- /dev/null +++ b/src/nix/meson.build @@ -0,0 +1,126 @@ +# Nix binary build file +#============================================================================ + + +nix_dir = meson.current_source_dir() +nix_inc = [include_directories('.')] + +# dependancies +#============================================================================ + +nix_dep_list = [ + pthread_dep, + libdl_dep, + boost_dep, + editline_dep, + libsodium_dep, + gc_dep, + + libutil_dep, + libstore_dep, + libmain_dep, + libexpr_dep, + libfetchers_dep, + libcmd_dep] + + +# src files +#============================================================================ + +nix_src = files( + join_paths(nix_dir, 'add-to-store.cc'), + join_paths(nix_dir, 'app.cc'), + join_paths(nix_dir, 'build.cc'), + join_paths(nix_dir, 'bundle.cc'), + join_paths(nix_dir, 'cat.cc'), + join_paths(nix_dir, 'copy.cc'), + join_paths(nix_dir, 'daemon.cc'), + join_paths(nix_dir, 'describe-stores.cc'), + join_paths(nix_dir, 'develop.cc'), + join_paths(nix_dir, 'diff-closures.cc'), + join_paths(nix_dir, 'doctor.cc'), + join_paths(nix_dir, 'dump-path.cc'), + join_paths(nix_dir, 'edit.cc'), + join_paths(nix_dir, 'eval.cc'), + join_paths(nix_dir, 'flake.cc'), + join_paths(nix_dir, 'hash.cc'), + join_paths(nix_dir, 'log.cc'), + join_paths(nix_dir, 'ls.cc'), + join_paths(nix_dir, 'main.cc'), + join_paths(nix_dir, 'make-content-addressable.cc'), + join_paths(nix_dir, 'nar.cc'), + join_paths(nix_dir, 'optimise-store.cc'), + join_paths(nix_dir, 'path-info.cc'), + join_paths(nix_dir, 'ping-store.cc'), + join_paths(nix_dir, 'prefetch.cc'), + join_paths(nix_dir, 'profile.cc'), + join_paths(nix_dir, 'registry.cc'), + join_paths(nix_dir, 'repl.cc'), + join_paths(nix_dir, 'run.cc'), + join_paths(nix_dir, 'search.cc'), + join_paths(nix_dir, 'show-config.cc'), + join_paths(nix_dir, 'show-derivation.cc'), + join_paths(nix_dir, 'sigs.cc'), + join_paths(nix_dir, 'store.cc'), + join_paths(nix_dir, 'store-delete.cc'), + join_paths(nix_dir, 'store-gc.cc'), + join_paths(nix_dir, 'store-repair.cc'), + join_paths(nix_dir, 'upgrade-nix.cc'), + join_paths(nix_dir, 'verify.cc'), + join_paths(nix_dir, 'why-depends.cc')) + +# nix_ln_src = [ +# [ bindir, 'nix-build' ], +# [ bindir, 'nix-channel' ], +# [ bindir, 'nix-collect-garbage' ], +# [ bindir, 'nix-copy-closure' ], +# [ bindir, 'nix-daemon' ], +# [ bindir, 'nix-env' ], +# [ bindir, 'nix-hash' ], +# [ bindir, 'nix-instantiate' ], +# [ bindir, 'nix-prefetch-url' ], +# [ bindir, 'nix-shell' ], +# [ bindir, 'nix-store' ], +# [ join_paths(libexecdir, 'nix'), 'build-remote' ]] + + +# targets +#============================================================================ +nix_src += custom_target( + 'get-env.sh.gen.hh', + output : 'get-env.sh.gen.hh', + input : 'get-env.sh', + command : [bash, '-c', gen_rheader, 'sh', '@OUTPUT@']) + + +# build +#============================================================================ + +# set build args +#--------------------------------------------------- +nix_cxx_args = [] + +nix_link_args = [] + +# build executable +#--------------------------------------------------- +nix_bin = executable( + 'nix', + sources : [ + 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], + install : true, + install_mode : 'rwxr-xr-x', + install_dir : bindir, + include_directories : proj_inc, + cpp_args : nix_cxx_args, + link_args : nix_link_args, + dependencies : nix_dep_list) diff --git a/src/resolve-system-dependencies/meson.build b/src/resolve-system-dependencies/meson.build new file mode 100644 index 000000000000..6fe9d6477711 --- /dev/null +++ b/src/resolve-system-dependencies/meson.build @@ -0,0 +1,40 @@ +# resolve-system-dependencies build file +#============================================================================ + +resolvesysdeps_dir = meson.current_source_dir() +resolvesysdeps_inc = [include_directories('.')] + +# dependancies +#============================================================================ + +resolvesysdeps_dep_list = [] + + +# src files +#============================================================================ + +resolvesysdeps_src = files( + join_paths(resolvesysdeps_dir, '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)