From 56f32b3eb4c9270147d474a046823e5ed1c85218 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 5 Jan 2019 12:30:48 -0500 Subject: [PATCH 01/27] WIP rewrite build system in Meson --- meson.build | 294 +++++++++++++++++++++++++++++++++++++++ meson_options.txt | 68 +++++++++ src/libstore/meson.build | 54 +++++++ src/libutil/meson.build | 31 +++++ 4 files changed, 447 insertions(+) create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/libstore/meson.build create mode 100644 src/libutil/meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 00000000000..c8fba7a0719 --- /dev/null +++ b/meson.build @@ -0,0 +1,294 @@ +# +# Old configure.ac +# + +project( + 'nix', + 'cpp', + default_options : [ + 'cpp_std=c++14', + #'localstatedir=/nix/var', + ], +) + +sed = find_program('sed') + +conf_data = configuration_data() + +system = get_option('with-system') +if system == '' + system = host_machine.cpu() + '-' + host_machine.system() +endif +# platform identifier (`cpu-os') +conf_data.set('SYSTEM', system) + +# State should be stored in /nix/var, unless the user overrides it explicitly. +if get_option('normal-var') + nixstatedir = '/nix/var' +else + nixstatedir = get_option('localstatedir') +endif + +global_libs = [] +# Solaris-specific stuff. +if host_machine.cpu() == 'sunos' + global_libs += [ + dependency('socket'), + dependency('nsl'), + ] +endif + +# Use 64-bit file system calls so that we can support files > 2 GiB. + +# Note vs configure.ac: Meson always does large file support. + +# Check for pubsetbuf. +want_pubsetbuf = get_option('have-pubsetbuf') +if want_pubsetbuf.disabled() + have_pubsetbuf = false +else + have_pubsetbuf = meson.get_compiler('cpp').compiles( + ''' + #include + using namespace std; + static char buf[1024]; + void func() { + cerr.rdbuf()->pubsetbuf(buf, sizeof(buf)); + } + ''', + name : 'pubsetbuf' + ) + if want_pubsetbuf.enabled() and not have_pubsetbuf + error('you required the `pubsetbuf` function, but we do not have it.') + endif +endif +# Whether pubsetbuf is available. +conf_data.set('HAVE_PUBSETBUF', have_pubsetbuf) + +foreach f : [ + 'statvfs', + 'pipe2', + # Check for lutimes, optionally used for changing the mtime of symlinks. + 'lutimes', +] + conf_data.set( + 'HAVE_' + f.to_upper(), + meson.get_compiler('cpp').has_function(f), + ) +endforeach + +# Check whether the store optimiser can optimise symlinks. +want_link_symlink = get_option('can-link-symlink') +if want_link_symlink.disabled() + can_link_symlink = true +else + link_text_script = ''' + ln -s bla tmp_link; + ln tmp_link tmp_link2 2> /dev/null; + rm -f tmp_link tmp_link2 + ''' + can_link_symlink = run_command('sh', '-c', link_text_script).returncode() == 0 + if want_link_symlink.enabled() and not can_link_symlink + error('you required that we hard link symlinks, but we cannot.') + endif +endif +# Whether link() works on symlinks. +conf_data.set('CAN_LINK_SYMLINK', can_link_symlink) + +# Check for . +meson.get_compiler('cpp').check_header('locale') + +foreach prog : [ + 'bash', + 'patch', + 'sed', + 'tar', + 'bzip2', + 'gzip', + 'xz', + 'cat', + 'tr', +] + conf_data.set(prog, find_program(prog).path()) +endforeach + +false_ = find_program('false') +foreach prog : [ + 'xmllint', + 'xsltproc', + 'flex', + 'bison', +] + progItem = find_program(prog, required: false) + conf_data.set(prog, progItem.found() ? progItem.path() : false_.path()) +endforeach + +progItem = find_program('dot', required: false) +if progItem.found() + conf_data.set('dot', progItem.path()) +endif +progItem = find_program('pv', required: false) +conf_data.set('pv', progItem.found() ? progItem.path() : 'pv') +progItem = find_program(['brotli', 'bro'], required: false) +conf_data.set('brotli', progItem.found() ? progItem.path() : 'bro') +progItem = find_program(['lsof'], required: false) +conf_data.set('lsof', progItem.found() ? progItem.path() : 'lsof') + +conf_data.set('coreutils', get_option('with-coreutils-bin')) +conf_data.set('storedir', get_option('with-store-dir')) + +# Special case +pthread = dependency('threads') + +# Look for OpenSSL, a required dependency. +openssl = [ + dependency('openssl'), + dependency('libcrypto'), +] + +# Look for libbz2, a required dependency. +bz2 = meson.get_compiler('cpp').find_library('bz2') + +# Look for SQLite, a required dependency. +sqlite3 = dependency('sqlite3', version : '>= 3.6.19') + +# Look for libcurl, a required dependency. +libcurl = dependency('libcurl') + +# Look for editline, a required dependency. +editline = dependency('libeditline') + +# Look for libsodium, an optional dependency. +libsodium = dependency('sodium', required : false) +# Whether to use libsodium for cryptography. +conf_data.set('HAVE_SODIUM', libsodium.found()) + +# Look for libbrotli{enc,dec}. +libbrotli = [ + dependency('libbrotlienc'), + dependency('libbrotlidec'), +] + +# Look for liblzma, a required dependency. +liblzma = dependency('liblzma') +# xz multithreaded compression support +conf_data.set( + 'HAVE_LSMA_MT', + meson.get_compiler('cpp') + .has_function('lzma_stream_encoder_mt', dependencies : liblzma), +) + +# Look for libseccomp, required for Linux sandboxing. +want_seccomp = get_option('enable-seccomp-sandboxing') +if want_seccomp.disabled() or (want_seccomp.auto() and host_machine.system() != 'linux') + seccomp = dependency('') +else # enabled or auto on linux + seccomp = dependency('libseccomp') + if want_seccomp.enabled() and not seccomp.found() + error('you required `libseccomp`, but we do not have it.') + endif +endif +# Whether seccomp is available and should be used for sandboxing. +conf_data.set('HAVE_SECCOMP', seccomp.found()) + +# Look for aws-cpp-sdk-s3. +want_aws = get_option('have-aws') +if want_aws.disabled() + have_aws = false +else + have_aws = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') +endif +# Whether to enable S3 support via aws-sdk-cpp. +conf_data.set('HAVE_S3', have_aws) + +if have_aws + aws_version = meson.get_compiler('cpp').get_define( + 'AWS_SDK_VERSION_STRING', + prefix : '#include ' + ).split('.') + # Major version of aws-sdk-cpp. + conf_data.set('AWS_VERSION_MAJOR', aws_version[0]) + # Minor version of aws-sdk-cpp. + conf_data.set('AWS_VERSION_MINOR', aws_version[1]) +endif + +# Whether to use the Boehm garbage collector. +want_gc = get_option('enable-gc') +if want_gc.disabled() + bdw_gc = false +else + bdw_gc = dependency('bdw-gc', required : false) + if want_gc.enabled() and not bdw_gc.found() + error('you required garbage collection, but we do not have the library to support it.') + endif +endif +# Whether to use the Boehm garbage collector. +conf_data.set('HAVE_BOEHMGC', libsodium.found()) + +# documentation generation switch +conf_data.set('doc_generate', not get_option('disable-doc-gen')) + + +foreach f : [ + # Setuid installations. + 'setresuid', + 'setreuid', + 'lchown', + # Nice to have, but not essential. + 'strsignal', + 'posix_fallocate', + 'sysconf', +] + conf_data.set( + 'HAVE_' + f.to_upper(), + meson.get_compiler('cpp').has_function(f), + ) +endforeach + +# This is needed if bzip2 is a static library, and the Nix libraries +# are dynamic. +if bz2.found() and host_machine.system() == 'darwin' + add_project_link_arguments('-all_load') +endif + +# Do we have GNU tar? +tar_script = ''' + if @t0@ --version 2> /dev/null | grep -q GNU && tar cvf /dev/null --warning=no-timestamp ./config.log > /dev/null +'''.format(find_program('tar').path()) +tar_flags = '' +if run_command('sh', '-c', link_text_script).returncode() == 0 + tar_flags += '--warning=no-timestamp' +endif +conf_data.set('tarFlags', tar_flags) + +conf_data.set('sandbox_shell', get_option('with-sandbox-shell')) + +configure_file( + output : 'config.h', + configuration : conf_data +) + +# +# Extra Configure +# + +boost_context = dependency('boost', modules : ['context']) + +# +# Old Makefile +# + +global_subdirs = include_directories([ + '.', + 'src', + 'src/libutil', + 'src/libstore', + 'src/libmain', + 'src/libexpr', + 'src/nix', +]) + +libraries = [] + +subdir('src/libutil') +subdir('src/libstore') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000000..41d1c54b0c5 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,68 @@ +# +# Original +# + +option( + 'with-system', + type : 'string', + description : ''' + The identifier for the type of machine this build of Nix will try to perform builds for. + Typically a two-component config like that produced by `uname`. + ''', +) +option( + 'normal-var', + type : 'boolean', + value : 'true', + description : 'Whether to use `/nix/var` or the user-overridable `localstatedir`.' +) + +option( + 'with-coreutils-bin', + type : 'string', + description : 'path of cat, mkdir, etc.' +) + +option( + 'with-store-dir', + type : 'string', + value : '/nix/store', + description : 'path of the Nix store (defaults to /nix/store)' +) + +option( + 'enable-seccomp-sandboxing', + type : 'feature', + description : ''' + Don't build support for seccomp sandboxing (only recommended if your arch doesn't support libseccomp yet! + ''', +) + +option( + 'enable-gc', + type : 'feature', + description : ''' + enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=no] + ''', +) + +option( + 'disable-doc-gen', + type : 'boolean', + value : false, + description : 'disable documentation generation', +) + +option( + 'with-sandbox-shell', + type : 'string', + description : 'path of a statically-linked shell to use as /bin/sh in sandboxes', +) + +# +# New for declarative config +# + +option('have-pubsetbuf', type : 'feature') +option('can-link-symlink', type : 'feature') +option('have-aws', type : 'feature') diff --git a/src/libstore/meson.build b/src/libstore/meson.build new file mode 100644 index 00000000000..a87db944f4a --- /dev/null +++ b/src/libstore/meson.build @@ -0,0 +1,54 @@ +libstore = library( + 'libnixstore', + [ + 'binary-cache-store.cc', + 'build.cc', + 'crypto.cc', + 'derivations.cc', + 'download.cc', + 'export-import.cc', + 'gc.cc', + 'globals.cc', + 'http-binary-cache-store.cc', + 'legacy-ssh-store.cc', + 'local-binary-cache-store.cc', + 'local-fs-store.cc', + 'local-store.cc', + 'machines.cc', + 'misc.cc', + 'nar-accessor.cc', + 'nar-info.cc', + 'nar-info-disk-cache.cc', + 'optimise-store.cc', + 'parsed-derivations.cc', + 'pathlocks.cc', + 'profiles.cc', + 'references.cc', + 'remote-fs-accessor.cc', + 'remote-store.cc', + 's3-binary-cache-store.cc', + 'sqlite.cc', + 'ssh.cc', + 'ssh-store.cc', + 'store-api.cc', + + 'builtins/buildenv.cc', + 'builtins/fetchurl.cc', + ], + install : true, + include_directories : global_subdirs, + dependencies : [ + global_libs, + + sqlite3, + bz2, + libcurl, + libsodium, + pthread, + ], + link_with : [ + libutil, + ], +) + +libraries += [ libstore ] diff --git a/src/libutil/meson.build b/src/libutil/meson.build new file mode 100644 index 00000000000..836d40be541 --- /dev/null +++ b/src/libutil/meson.build @@ -0,0 +1,31 @@ +libutil = library( + 'libnixutil', + [ + 'affinity.cc', + 'archive.cc', + 'args.cc', + 'compression.cc', + 'config.cc', + 'hash.cc', + 'json.cc', + 'logging.cc', + 'serialise.cc', + 'thread-pool.cc', + 'util.cc', + 'xml-writer.cc', + ], + install : true, + include_directories : global_subdirs, + dependencies : [ + global_libs, + + liblzma, + bz2, + pthread, + openssl, + libbrotli, + boost_context, + ], +) + +libraries += [ libutil ] From 240bd0e47b68d600f868dfb023fec1794877155b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 6 Jan 2019 14:32:08 -0500 Subject: [PATCH 02/27] meson: Don't search for brotli executables The library is always used directly now --- meson.build | 2 -- 1 file changed, 2 deletions(-) diff --git a/meson.build b/meson.build index c8fba7a0719..397cae1536f 100644 --- a/meson.build +++ b/meson.build @@ -129,8 +129,6 @@ if progItem.found() endif progItem = find_program('pv', required: false) conf_data.set('pv', progItem.found() ? progItem.path() : 'pv') -progItem = find_program(['brotli', 'bro'], required: false) -conf_data.set('brotli', progItem.found() ? progItem.path() : 'bro') progItem = find_program(['lsof'], required: false) conf_data.set('lsof', progItem.found() ? progItem.path() : 'lsof') From 34549f022c759736c1db1ec995bdd153d66cb2de Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 6 Jan 2019 14:53:04 -0500 Subject: [PATCH 03/27] meson: Add global C++ flags from top-level Makefile --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index 397cae1536f..b34caafb65c 100644 --- a/meson.build +++ b/meson.build @@ -286,6 +286,8 @@ global_subdirs = include_directories([ 'src/nix', ]) +add_project_arguments('-g', '-Wall', '-include', 'config.h', language : 'cpp') + libraries = [] subdir('src/libutil') From 7972e8286c753b7603c50ca44603e1f38d78fa41 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 00:28:20 -0500 Subject: [PATCH 04/27] meson: Add libmain --- meson.build | 1 + src/libmain/meson.build | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/libmain/meson.build diff --git a/meson.build b/meson.build index b34caafb65c..6180067cb83 100644 --- a/meson.build +++ b/meson.build @@ -292,3 +292,4 @@ libraries = [] subdir('src/libutil') subdir('src/libstore') +subdir('src/libmain') diff --git a/src/libmain/meson.build b/src/libmain/meson.build new file mode 100644 index 00000000000..06f8e8631c1 --- /dev/null +++ b/src/libmain/meson.build @@ -0,0 +1,21 @@ +libmain = library( + 'libnixmain', + [ + 'common-args.cc', + 'shared.cc', + 'stack.cc', + ], + install : true, + include_directories : global_subdirs, + dependencies : [ + global_libs, + + openssl, + ], + link_with : [ + libstore, + libutil, + ], +) + +libraries += [ libmain ] From 029c9d09da9c06b2c29a33033dec16466c9d62c7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 10:10:42 -0500 Subject: [PATCH 05/27] meson: Add libexpr --- meson.build | 1 + src/libexpr/meson.build | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/libexpr/meson.build diff --git a/meson.build b/meson.build index 6180067cb83..f06545fe815 100644 --- a/meson.build +++ b/meson.build @@ -293,3 +293,4 @@ libraries = [] subdir('src/libutil') subdir('src/libstore') subdir('src/libmain') +subdir('src/libexpr') diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build new file mode 100644 index 00000000000..77e7a920ff1 --- /dev/null +++ b/src/libexpr/meson.build @@ -0,0 +1,53 @@ +flex = find_program('flex', required: false) +bison = find_program('bison', required: false) + +parser_tab_cchh = custom_target( + 'parser_tab.[cchh]', + output : ['parser_tab.cc', 'parser_tab.hh'], + input : 'parser.y', + command : [bison, '-v', '-o', '@OUTPUT0@', '@INPUT@', '-d'] +) + +lexer_tab_cchh = custom_target( + 'lexer_tab.[cchh]', + output : ['lexer_tab.cc', 'lexer_tab.hh'], + input : 'lexer.l', + command : [ + flex, + '--outfile', '@OUTPUT0@', + '--headerfile', '@OUTPUT1@', + '@INPUT@' + ] +) + +libexpr = library( + 'libnixexpr', + [ + 'attr-path.cc', + 'attr-set.cc', + 'common-eval-args.cc', + 'eval.cc', + 'get-drvs.cc', + 'json-to-value.cc', + 'names.cc', + 'nixexpr.cc', + 'primops.cc', + 'value-to-json.cc', + 'value-to-xml.cc', + + lexer_tab_cchh[0], + parser_tab_cchh[0], + ], + install : true, + include_directories : global_subdirs, + dependencies : [ + global_libs, + ], + link_with : [ + libstore, + libutil, + ], + link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] +) + +libraries += [ libexpr ] From a1baef8dccb5a8d7b5b46ea085271f9695771d54 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 14:28:46 -0500 Subject: [PATCH 06/27] meson: should be `ENABLE_S3`, not `HAVE_S3` --- meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index f06545fe815..dc932c951bd 100644 --- a/meson.build +++ b/meson.build @@ -190,16 +190,16 @@ endif conf_data.set('HAVE_SECCOMP', seccomp.found()) # Look for aws-cpp-sdk-s3. -want_aws = get_option('have-aws') -if want_aws.disabled() - have_aws = false +want_s3 = get_option('enable-s3') +if want_s3.disabled() + enable_s3 = false else - have_aws = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') + enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') endif # Whether to enable S3 support via aws-sdk-cpp. -conf_data.set('HAVE_S3', have_aws) +conf_data.set('ENABLE_S3', enable_s3) -if have_aws +if enable_s3 aws_version = meson.get_compiler('cpp').get_define( 'AWS_SDK_VERSION_STRING', prefix : '#include ' From 87123f742f3a86bd9eadac3316d6e0588b16889a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 16:24:47 -0500 Subject: [PATCH 07/27] meson: Bison and Flex are required --- src/libexpr/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index 77e7a920ff1..c090e1cd3cc 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -1,5 +1,5 @@ -flex = find_program('flex', required: false) -bison = find_program('bison', required: false) +flex = find_program('flex') +bison = find_program('bison') parser_tab_cchh = custom_target( 'parser_tab.[cchh]', From a16bf2c68f8fe101755d6dfcbf63628cac078547 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 16:28:28 -0500 Subject: [PATCH 08/27] meson: Add some missing pieces to libstore's meson.build --- meson.build | 12 +++++++++++- src/libstore/meson.build | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index dc932c951bd..da4a09d0481 100644 --- a/meson.build +++ b/meson.build @@ -179,7 +179,7 @@ conf_data.set( # Look for libseccomp, required for Linux sandboxing. want_seccomp = get_option('enable-seccomp-sandboxing') if want_seccomp.disabled() or (want_seccomp.auto() and host_machine.system() != 'linux') - seccomp = dependency('') + seccomp = dependency('', required : false) else # enabled or auto on linux seccomp = dependency('libseccomp') if want_seccomp.enabled() and not seccomp.found() @@ -272,6 +272,16 @@ configure_file( boost_context = dependency('boost', modules : ['context']) +if enable_s3 + aws_cpp_sdk_transfer = meson.get_compiler('cpp').find_library('aws-cpp-sdk-transfer') + aws_cpp_sdk_s3 = meson.get_compiler('cpp').find_library('aws-cpp-sdk-s3') + aws_cpp_sdk_core = meson.get_compiler('cpp').find_library('aws-cpp-sdk-core') +else + aws_cpp_sdk_transfer = dependency('', required : false) + aws_cpp_sdk_s3 = dependency('', required : false) + aws_cpp_sdk_core = dependency('', required : false) +endif + # # Old Makefile # diff --git a/src/libstore/meson.build b/src/libstore/meson.build index a87db944f4a..d80b4483e59 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -1,3 +1,16 @@ +sql_header_script = ''' + echo 'R"foo(' >> @OUTPUT@ + cat @INPUT@ >> @OUTPUT@ + echo ')foo"' >> @OUTPUT@ +''' + +sql_header = custom_target( + 'schema.sql.gen.hh', + output : ['schema.sql.gen.hh'], + input : 'schema.sql', + command : ['sh', '-c', sql_header_script] +) + libstore = library( 'libnixstore', [ @@ -34,6 +47,8 @@ libstore = library( 'builtins/buildenv.cc', 'builtins/fetchurl.cc', + + sql_header, ], install : true, include_directories : global_subdirs, @@ -45,10 +60,16 @@ libstore = library( libcurl, libsodium, pthread, + + aws_cpp_sdk_transfer, + aws_cpp_sdk_s3, + aws_cpp_sdk_core, + seccomp, ], link_with : [ libutil, ], + link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] ) libraries += [ libstore ] From a25dc6d0afc2efdefd10b9ef2f3bb15cd585285e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 16:36:34 -0500 Subject: [PATCH 09/27] meson: Fix options file to match main meson.build Forgot to include this when changing the AWS thing --- meson_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 41d1c54b0c5..51c6d137187 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -65,4 +65,4 @@ option( option('have-pubsetbuf', type : 'feature') option('can-link-symlink', type : 'feature') -option('have-aws', type : 'feature') +option('enable-s3', type : 'feature') From 1f1efcfc5711ceade05f096d750f2d3f646545ca Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 16:38:30 -0500 Subject: [PATCH 10/27] meson: Fix some quoting errors --- meson.build | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index da4a09d0481..c329cc74cd5 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ if system == '' system = host_machine.cpu() + '-' + host_machine.system() endif # platform identifier (`cpu-os') -conf_data.set('SYSTEM', system) +conf_data.set_quoted('SYSTEM', system) # State should be stored in /nix/var, unless the user overrides it explicitly. if get_option('normal-var') @@ -109,7 +109,7 @@ foreach prog : [ 'cat', 'tr', ] - conf_data.set(prog, find_program(prog).path()) + conf_data.set_quoted(prog, find_program(prog).path()) endforeach false_ = find_program('false') @@ -120,20 +120,20 @@ foreach prog : [ 'bison', ] progItem = find_program(prog, required: false) - conf_data.set(prog, progItem.found() ? progItem.path() : false_.path()) + conf_data.set_quoted(prog, progItem.found() ? progItem.path() : false_.path()) endforeach progItem = find_program('dot', required: false) if progItem.found() - conf_data.set('dot', progItem.path()) + conf_data.set_quoted('dot', progItem.path()) endif progItem = find_program('pv', required: false) -conf_data.set('pv', progItem.found() ? progItem.path() : 'pv') +conf_data.set_quoted('pv', progItem.found() ? progItem.path() : 'pv') progItem = find_program(['lsof'], required: false) -conf_data.set('lsof', progItem.found() ? progItem.path() : 'lsof') +conf_data.set_quoted('lsof', progItem.found() ? progItem.path() : 'lsof') -conf_data.set('coreutils', get_option('with-coreutils-bin')) -conf_data.set('storedir', get_option('with-store-dir')) +conf_data.set_quoted('coreutils', get_option('with-coreutils-bin')) +conf_data.set_quoted('storedir', get_option('with-store-dir')) # Special case pthread = dependency('threads') @@ -203,7 +203,7 @@ if enable_s3 aws_version = meson.get_compiler('cpp').get_define( 'AWS_SDK_VERSION_STRING', prefix : '#include ' - ).split('.') + ).strip('"').split('.') # Major version of aws-sdk-cpp. conf_data.set('AWS_VERSION_MAJOR', aws_version[0]) # Minor version of aws-sdk-cpp. @@ -259,7 +259,7 @@ if run_command('sh', '-c', link_text_script).returncode() == 0 endif conf_data.set('tarFlags', tar_flags) -conf_data.set('sandbox_shell', get_option('with-sandbox-shell')) +conf_data.set_quoted('sandbox_shell', get_option('with-sandbox-shell')) configure_file( output : 'config.h', From 7d0684666e3d9b36ae35420bcea2a2a862e6ac1a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 16:41:54 -0500 Subject: [PATCH 11/27] meson: Fix 1 more quoting issue --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index c329cc74cd5..b15bc37ecbe 100644 --- a/meson.build +++ b/meson.build @@ -127,8 +127,6 @@ progItem = find_program('dot', required: false) if progItem.found() conf_data.set_quoted('dot', progItem.path()) endif -progItem = find_program('pv', required: false) -conf_data.set_quoted('pv', progItem.found() ? progItem.path() : 'pv') progItem = find_program(['lsof'], required: false) conf_data.set_quoted('lsof', progItem.found() ? progItem.path() : 'lsof') @@ -257,7 +255,7 @@ tar_flags = '' if run_command('sh', '-c', link_text_script).returncode() == 0 tar_flags += '--warning=no-timestamp' endif -conf_data.set('tarFlags', tar_flags) +conf_data.set_quoted('tarFlags', tar_flags) conf_data.set_quoted('sandbox_shell', get_option('with-sandbox-shell')) From 040410a302123b5c90b5a0bb1a7d613ce73db2b3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 17:03:23 -0500 Subject: [PATCH 12/27] meson: Make HAVE_ macros work with `#if` rather than just `#ifdef` Hopefully I can revert this someday --- meson.build | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index b15bc37ecbe..67a23f22df5 100644 --- a/meson.build +++ b/meson.build @@ -62,8 +62,10 @@ else error('you required the `pubsetbuf` function, but we do not have it.') endif endif -# Whether pubsetbuf is available. -conf_data.set('HAVE_PUBSETBUF', have_pubsetbuf) +if have_pubsetbuf + # Whether pubsetbuf is available. + conf_data.set('HAVE_PUBSETBUF', 1) +endif foreach f : [ 'statvfs', @@ -71,10 +73,9 @@ foreach f : [ # Check for lutimes, optionally used for changing the mtime of symlinks. 'lutimes', ] - conf_data.set( - 'HAVE_' + f.to_upper(), - meson.get_compiler('cpp').has_function(f), - ) + if meson.get_compiler('cpp').has_function(f) + conf_data.set('HAVE_' + f.to_upper(), 1) + endif endforeach # Check whether the store optimiser can optimise symlinks. @@ -92,8 +93,10 @@ else error('you required that we hard link symlinks, but we cannot.') endif endif -# Whether link() works on symlinks. -conf_data.set('CAN_LINK_SYMLINK', can_link_symlink) +if can_link_symlink + # Whether link() works on symlinks. + conf_data.set('CAN_LINK_SYMLINK', 1) +endif # Check for . meson.get_compiler('cpp').check_header('locale') @@ -156,8 +159,10 @@ editline = dependency('libeditline') # Look for libsodium, an optional dependency. libsodium = dependency('sodium', required : false) -# Whether to use libsodium for cryptography. -conf_data.set('HAVE_SODIUM', libsodium.found()) +if libsodium.found() + # Whether to use libsodium for cryptography. + conf_data.set('HAVE_SODIUM', 1) +endif # Look for libbrotli{enc,dec}. libbrotli = [ @@ -168,11 +173,9 @@ libbrotli = [ # Look for liblzma, a required dependency. liblzma = dependency('liblzma') # xz multithreaded compression support -conf_data.set( - 'HAVE_LSMA_MT', - meson.get_compiler('cpp') - .has_function('lzma_stream_encoder_mt', dependencies : liblzma), -) +if meson.get_compiler('cpp').has_function('lzma_stream_encoder_mt', dependencies : liblzma) + conf_data.set('HAVE_LSMA_MT', 1) +endif # Look for libseccomp, required for Linux sandboxing. want_seccomp = get_option('enable-seccomp-sandboxing') @@ -185,7 +188,9 @@ else # enabled or auto on linux endif endif # Whether seccomp is available and should be used for sandboxing. -conf_data.set('HAVE_SECCOMP', seccomp.found()) +if seccomp.found() + conf_data.set('HAVE_SECCOMP', 1) +endif # Look for aws-cpp-sdk-s3. want_s3 = get_option('enable-s3') @@ -219,7 +224,9 @@ else endif endif # Whether to use the Boehm garbage collector. -conf_data.set('HAVE_BOEHMGC', libsodium.found()) +if libsodium.found() + conf_data.set('HAVE_BOEHMGC', 1) +endif # documentation generation switch conf_data.set('doc_generate', not get_option('disable-doc-gen')) @@ -235,10 +242,9 @@ foreach f : [ 'posix_fallocate', 'sysconf', ] - conf_data.set( - 'HAVE_' + f.to_upper(), - meson.get_compiler('cpp').has_function(f), - ) + if meson.get_compiler('cpp').has_function(f) + conf_data.set('HAVE_' + f.to_upper(), 1) + endif endforeach # This is needed if bzip2 is a static library, and the Nix libraries From e887ffe972381a8d83658bf7caadfc1040f87868 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 17:07:42 -0500 Subject: [PATCH 13/27] meson: Don't forget dependency on generated headers too --- src/libexpr/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index c090e1cd3cc..b6e9e00f328 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -35,8 +35,8 @@ libexpr = library( 'value-to-json.cc', 'value-to-xml.cc', - lexer_tab_cchh[0], - parser_tab_cchh[0], + lexer_tab_cchh, + parser_tab_cchh, ], install : true, include_directories : global_subdirs, From 751d3bcff2869b60edd8aeeca2af0a110b0c1892 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 17:21:26 -0500 Subject: [PATCH 14/27] meson: Do config.h comments Finally figured that out --- meson.build | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index 67a23f22df5..43a37bfb92b 100644 --- a/meson.build +++ b/meson.build @@ -19,8 +19,7 @@ system = get_option('with-system') if system == '' system = host_machine.cpu() + '-' + host_machine.system() endif -# platform identifier (`cpu-os') -conf_data.set_quoted('SYSTEM', system) +conf_data.set_quoted('SYSTEM', system, description : 'platform identifier (`cpu-os\')') # State should be stored in /nix/var, unless the user overrides it explicitly. if get_option('normal-var') @@ -63,8 +62,7 @@ else endif endif if have_pubsetbuf - # Whether pubsetbuf is available. - conf_data.set('HAVE_PUBSETBUF', 1) + conf_data.set('HAVE_PUBSETBUF', 1, description : 'Whether pubsetbuf is available.') endif foreach f : [ @@ -94,8 +92,7 @@ else endif endif if can_link_symlink - # Whether link() works on symlinks. - conf_data.set('CAN_LINK_SYMLINK', 1) + conf_data.set('CAN_LINK_SYMLINK', 1, description : 'Whether link() works on symlinks.') endif # Check for . @@ -160,8 +157,7 @@ editline = dependency('libeditline') # Look for libsodium, an optional dependency. libsodium = dependency('sodium', required : false) if libsodium.found() - # Whether to use libsodium for cryptography. - conf_data.set('HAVE_SODIUM', 1) + conf_data.set('HAVE_SODIUM', 1, description : 'Whether to use libsodium for cryptography.') endif # Look for libbrotli{enc,dec}. @@ -172,9 +168,8 @@ libbrotli = [ # Look for liblzma, a required dependency. liblzma = dependency('liblzma') -# xz multithreaded compression support if meson.get_compiler('cpp').has_function('lzma_stream_encoder_mt', dependencies : liblzma) - conf_data.set('HAVE_LSMA_MT', 1) + conf_data.set('HAVE_LSMA_MT', 1, description : 'xz multithreaded compression support') endif # Look for libseccomp, required for Linux sandboxing. @@ -187,9 +182,8 @@ else # enabled or auto on linux error('you required `libseccomp`, but we do not have it.') endif endif -# Whether seccomp is available and should be used for sandboxing. if seccomp.found() - conf_data.set('HAVE_SECCOMP', 1) + conf_data.set('HAVE_SECCOMP', 1, description : 'Whether seccomp is available and should be used for sandboxing.') endif # Look for aws-cpp-sdk-s3. @@ -199,18 +193,15 @@ if want_s3.disabled() else enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') endif -# Whether to enable S3 support via aws-sdk-cpp. -conf_data.set('ENABLE_S3', enable_s3) +conf_data.set('ENABLE_S3', enable_s3, description : 'Whether to enable S3 support via aws-sdk-cpp.') if enable_s3 aws_version = meson.get_compiler('cpp').get_define( 'AWS_SDK_VERSION_STRING', prefix : '#include ' ).strip('"').split('.') - # Major version of aws-sdk-cpp. - conf_data.set('AWS_VERSION_MAJOR', aws_version[0]) - # Minor version of aws-sdk-cpp. - conf_data.set('AWS_VERSION_MINOR', aws_version[1]) + conf_data.set('AWS_VERSION_MAJOR', aws_version[0], description : 'Major version of aws-sdk-cpp.') + conf_data.set('AWS_VERSION_MINOR', aws_version[1], description : 'Minor version of aws-sdk-cpp.') endif # Whether to use the Boehm garbage collector. @@ -223,9 +214,8 @@ else error('you required garbage collection, but we do not have the library to support it.') endif endif -# Whether to use the Boehm garbage collector. if libsodium.found() - conf_data.set('HAVE_BOEHMGC', 1) + conf_data.set('HAVE_BOEHMGC', 1, description : 'Whether to use the Boehm garbage collector.') endif # documentation generation switch From 00893e625c377f12497098da6479cac4c8b24bc9 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 18:44:16 -0500 Subject: [PATCH 15/27] meson: fix argument passing I was confusing `AC_SUBST` with `AC_CONFIG_HEADER`: these non-capitalized identifiers are just shell vars and should not become C preprocessor ifdefs. Also passed libstore its `-D` flags. --- meson.build | 17 ++++++----------- src/libstore/meson.build | 13 +++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 43a37bfb92b..26b12dd52d5 100644 --- a/meson.build +++ b/meson.build @@ -109,7 +109,7 @@ foreach prog : [ 'cat', 'tr', ] - conf_data.set_quoted(prog, find_program(prog).path()) + find_program(prog) endforeach false_ = find_program('false') @@ -119,19 +119,14 @@ foreach prog : [ 'flex', 'bison', ] - progItem = find_program(prog, required: false) - conf_data.set_quoted(prog, progItem.found() ? progItem.path() : false_.path()) + find_program(prog, required: false) endforeach -progItem = find_program('dot', required: false) -if progItem.found() - conf_data.set_quoted('dot', progItem.path()) -endif -progItem = find_program(['lsof'], required: false) -conf_data.set_quoted('lsof', progItem.found() ? progItem.path() : 'lsof') +find_program('dot', required: false) +lsof = find_program('lsof', required: false) conf_data.set_quoted('coreutils', get_option('with-coreutils-bin')) -conf_data.set_quoted('storedir', get_option('with-store-dir')) +storedir = get_option('with-store-dir') # Special case pthread = dependency('threads') @@ -253,7 +248,7 @@ if run_command('sh', '-c', link_text_script).returncode() == 0 endif conf_data.set_quoted('tarFlags', tar_flags) -conf_data.set_quoted('sandbox_shell', get_option('with-sandbox-shell')) +sandbox_shell = get_option('with-sandbox-shell') configure_file( output : 'config.h', diff --git a/src/libstore/meson.build b/src/libstore/meson.build index d80b4483e59..6c830d94773 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -69,6 +69,19 @@ libstore = library( link_with : [ libutil, ], + c_args : [ + '-DNIX_PREFIX=@0@'.format(get_option('prefix')), + '-DNIX_STORE_DIR=@0@'.format(storedir), + '-DNIX_DATA_DIR=@0@'.format(get_option('datadir')), + '-DNIX_STATE_DIR=@0@/nix'.format(get_option('localstatedir')), + '-DNIX_LOG_DIR=@0@/log/nix'.format(get_option('localstatedir')), + '-DNIX_CONF_DIR=@0@/nix'.format(get_option('sysconfdir')), + '-DNIX_LIBEXEC_DIR=@0@'.format(get_option('libexecdir')), + '-DNIX_BIN_DIR=@0@'.format(get_option('bindir')), + '-DNIX_MAN_DIR=@0@'.format(get_option('mandir')), + '-DSANDBOX_SHELL=@0@'.format(sandbox_shell), + '-DLSOF=@0@'.format(lsof), + ], link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] ) From f36810871a7225415bf59ed9253cc0ca6504e3d6 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 18:49:10 -0500 Subject: [PATCH 16/27] meson: Fix lex and bison typos --- src/libexpr/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index b6e9e00f328..30a37944608 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -3,19 +3,19 @@ bison = find_program('bison') parser_tab_cchh = custom_target( 'parser_tab.[cchh]', - output : ['parser_tab.cc', 'parser_tab.hh'], + output : ['parser-tab.cc', 'parser-tab.hh'], input : 'parser.y', command : [bison, '-v', '-o', '@OUTPUT0@', '@INPUT@', '-d'] ) lexer_tab_cchh = custom_target( 'lexer_tab.[cchh]', - output : ['lexer_tab.cc', 'lexer_tab.hh'], + output : ['lexer-tab.cc', 'lexer-tab.hh'], input : 'lexer.l', command : [ flex, '--outfile', '@OUTPUT0@', - '--headerfile', '@OUTPUT1@', + '--header-file', '@OUTPUT1@', '@INPUT@' ] ) From 7e5711556c5cad1e80c9118af5d844f8f62d34a5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 18:57:32 -0500 Subject: [PATCH 17/27] Fix another lex typo --- src/libexpr/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index 30a37944608..add9a48f095 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -15,7 +15,7 @@ lexer_tab_cchh = custom_target( command : [ flex, '--outfile', '@OUTPUT0@', - '--header-file', '@OUTPUT1@', + '--header-file=@OUTPUT1@', '@INPUT@' ] ) From 8b5b1a0752ac3ee97a4d4354b66a6fa2575163b0 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 22:19:04 -0500 Subject: [PATCH 18/27] meson: libstore's c_args should become cpp_args --- src/libstore/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 6c830d94773..49d1b2f7561 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -69,7 +69,7 @@ libstore = library( link_with : [ libutil, ], - c_args : [ + cpp_args : [ '-DNIX_PREFIX=@0@'.format(get_option('prefix')), '-DNIX_STORE_DIR=@0@'.format(storedir), '-DNIX_DATA_DIR=@0@'.format(get_option('datadir')), From 3c04f2e715dea6f207c4f2a4b7c9f9d55e04fe36 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 22:31:09 -0500 Subject: [PATCH 19/27] meson: Remove pointless list --- src/libstore/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 49d1b2f7561..a657605dda6 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -6,7 +6,7 @@ sql_header_script = ''' sql_header = custom_target( 'schema.sql.gen.hh', - output : ['schema.sql.gen.hh'], + output : 'schema.sql.gen.hh', input : 'schema.sql', command : ['sh', '-c', sql_header_script] ) From 4b5bb49ec0761dfc129ecaaf0658fcce2631eeff Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 22:31:42 -0500 Subject: [PATCH 20/27] meson: Fix ENABLE_S3 to work with `#if` --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 26b12dd52d5..2738b23e9d7 100644 --- a/meson.build +++ b/meson.build @@ -188,7 +188,9 @@ if want_s3.disabled() else enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h') endif -conf_data.set('ENABLE_S3', enable_s3, description : 'Whether to enable S3 support via aws-sdk-cpp.') +if enable_s3 + conf_data.set('ENABLE_S3', 1, description : 'Whether to enable S3 support via aws-sdk-cpp.') +endif if enable_s3 aws_version = meson.get_compiler('cpp').get_define( From 12ee8d325c3b91cd0375a99c813829bfc22eaaab Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 22:46:37 -0500 Subject: [PATCH 21/27] meson: Define PACKAGE_VERSION --- meson.build | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 2738b23e9d7..8758bb30e50 100644 --- a/meson.build +++ b/meson.build @@ -252,17 +252,15 @@ conf_data.set_quoted('tarFlags', tar_flags) sandbox_shell = get_option('with-sandbox-shell') -configure_file( - output : 'config.h', - configuration : conf_data -) - # # Extra Configure # boost_context = dependency('boost', modules : ['context']) +# Done by default by autoconf +conf_data.set_quoted('PACKAGE_VERSION', meson.project_version()) + if enable_s3 aws_cpp_sdk_transfer = meson.get_compiler('cpp').find_library('aws-cpp-sdk-transfer') aws_cpp_sdk_s3 = meson.get_compiler('cpp').find_library('aws-cpp-sdk-s3') @@ -273,6 +271,15 @@ else aws_cpp_sdk_core = dependency('', required : false) endif +# +# original Configure.ac, but much go last +# + +configure_file( + output : 'config.h', + configuration : conf_data +) + # # Old Makefile # From b2568dec8169d4579cfe04212a157ad906493ac8 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Jan 2019 22:50:35 -0500 Subject: [PATCH 22/27] meson: Fix quoting in manual `-D` --- src/libstore/meson.build | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index a657605dda6..372cfc91dee 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -70,17 +70,17 @@ libstore = library( libutil, ], cpp_args : [ - '-DNIX_PREFIX=@0@'.format(get_option('prefix')), - '-DNIX_STORE_DIR=@0@'.format(storedir), - '-DNIX_DATA_DIR=@0@'.format(get_option('datadir')), - '-DNIX_STATE_DIR=@0@/nix'.format(get_option('localstatedir')), - '-DNIX_LOG_DIR=@0@/log/nix'.format(get_option('localstatedir')), - '-DNIX_CONF_DIR=@0@/nix'.format(get_option('sysconfdir')), - '-DNIX_LIBEXEC_DIR=@0@'.format(get_option('libexecdir')), - '-DNIX_BIN_DIR=@0@'.format(get_option('bindir')), - '-DNIX_MAN_DIR=@0@'.format(get_option('mandir')), - '-DSANDBOX_SHELL=@0@'.format(sandbox_shell), - '-DLSOF=@0@'.format(lsof), + '-DNIX_PREFIX="@0@"'.format(get_option('prefix')), + '-DNIX_STORE_DIR="@0@"'.format(storedir), + '-DNIX_DATA_DIR="@0@"'.format(get_option('datadir')), + '-DNIX_STATE_DIR="@0@/nix"'.format(get_option('localstatedir')), + '-DNIX_LOG_DIR="@0@/log/nix"'.format(get_option('localstatedir')), + '-DNIX_CONF_DIR="@0@/nix"'.format(get_option('sysconfdir')), + '-DNIX_LIBEXEC_DIR="@0@"'.format(get_option('libexecdir')), + '-DNIX_BIN_DIR="@0@"'.format(get_option('bindir')), + '-DNIX_MAN_DIR="@0@"'.format(get_option('mandir')), + '-DSANDBOX_SHELL="@0@"'.format(sandbox_shell), + '-DLSOF="@0@"'.format(lsof), ], link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] ) From c255c8c837d7f2d0f5b06f86a2473775a4eb8ced Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Jan 2019 11:39:50 -0500 Subject: [PATCH 23/27] meson: Hack around bug in meson Each command piece can only have one @identifier@ so need to smuggle in @OUTPUT@ a different way. --- src/libstore/meson.build | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 372cfc91dee..c608834273a 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -1,14 +1,15 @@ +# TODO fix `@OUTPUT@` substitution so we don't need to do this workaround sql_header_script = ''' - echo 'R"foo(' >> @OUTPUT@ - cat @INPUT@ >> @OUTPUT@ - echo ')foo"' >> @OUTPUT@ + echo 'R"foo(' >> "$1" + cat @INPUT@ >> "$1" + echo ')foo"' >> "$1" ''' sql_header = custom_target( 'schema.sql.gen.hh', output : 'schema.sql.gen.hh', input : 'schema.sql', - command : ['sh', '-c', sql_header_script] + command : ['sh', '-c', sql_header_script, 'sh', '@OUTPUT@'] ) libstore = library( From 535cbf672e55b3bb257b1a7ba89a50afae156193 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Jan 2019 12:07:01 -0500 Subject: [PATCH 24/27] meson: Remove the libraries list It is pointless --- meson.build | 2 -- src/libexpr/meson.build | 2 -- src/libmain/meson.build | 2 -- src/libstore/meson.build | 2 -- src/libutil/meson.build | 2 -- 5 files changed, 10 deletions(-) diff --git a/meson.build b/meson.build index 8758bb30e50..8ae1b0de1d1 100644 --- a/meson.build +++ b/meson.build @@ -296,8 +296,6 @@ global_subdirs = include_directories([ add_project_arguments('-g', '-Wall', '-include', 'config.h', language : 'cpp') -libraries = [] - subdir('src/libutil') subdir('src/libstore') subdir('src/libmain') diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index add9a48f095..74c6289505f 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -49,5 +49,3 @@ libexpr = library( ], link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] ) - -libraries += [ libexpr ] diff --git a/src/libmain/meson.build b/src/libmain/meson.build index 06f8e8631c1..23ee0129274 100644 --- a/src/libmain/meson.build +++ b/src/libmain/meson.build @@ -17,5 +17,3 @@ libmain = library( libutil, ], ) - -libraries += [ libmain ] diff --git a/src/libstore/meson.build b/src/libstore/meson.build index c608834273a..9e5b00f1063 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -85,5 +85,3 @@ libstore = library( ], link_args : host_machine.system() == 'freebsd' ? ['-ldl'] : [] ) - -libraries += [ libstore ] diff --git a/src/libutil/meson.build b/src/libutil/meson.build index 836d40be541..2ca0f13b987 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -27,5 +27,3 @@ libutil = library( boost_context, ], ) - -libraries += [ libutil ] From 71f4b5eea4325b34c71ed5091c5169461950e3e4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Jan 2019 13:29:23 -0500 Subject: [PATCH 25/27] meson: Build binaries The symlinks needs more work, however --- meson.build | 1 + src/nix/meson.build | 85 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 src/nix/meson.build diff --git a/meson.build b/meson.build index 8ae1b0de1d1..4ac6fd052e6 100644 --- a/meson.build +++ b/meson.build @@ -300,3 +300,4 @@ subdir('src/libutil') subdir('src/libstore') subdir('src/libmain') subdir('src/libexpr') +subdir('src/nix') diff --git a/src/nix/meson.build b/src/nix/meson.build new file mode 100644 index 00000000000..29aa4a8ee66 --- /dev/null +++ b/src/nix/meson.build @@ -0,0 +1,85 @@ +nix = executable( + 'nix', + [ + 'add-to-store.cc', + 'build.cc', + 'cat.cc', + 'command.cc', + 'copy.cc', + 'doctor.cc', + 'dump-path.cc', + 'edit.cc', + 'eval.cc', + 'hash.cc', + 'installables.cc', + 'legacy.cc', + 'log.cc', + 'ls.cc', + 'main.cc', + 'optimise-store.cc', + 'path-info.cc', + 'ping-store.cc', + 'progress-bar.cc', + 'repl.cc', + 'run.cc', + 'search.cc', + 'show-config.cc', + 'show-derivation.cc', + 'sigs.cc', + 'upgrade-nix.cc', + 'verify.cc', + 'why-depends.cc', + + '../build-remote/build-remote.cc', + + '../nix-build/nix-build.cc', + '../nix-channel/nix-channel.cc', + '../nix-collect-garbage/nix-collect-garbage.cc', + '../nix-copy-closure/nix-copy-closure.cc', + '../nix-daemon/nix-daemon.cc', + '../nix-env/nix-env.cc', + '../nix-env/user-env.cc', + '../nix-instantiate/nix-instantiate.cc', + '../nix-prefetch-url/nix-prefetch-url.cc', + '../nix-store/dotgraph.cc', + '../nix-store/graphml.cc', + '../nix-store/nix-store.cc', + ], + include_directories : global_subdirs, + dependencies : [ + global_libs, + + pthread, + libsodium, + editline, + ], + link_with : [ + libexpr, + libmain, + libstore, + libutil, + ], +) + +foreach name : [ + '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', +] + custom_target( + name, + output : name, + input : nix, + command : ['ln', '-s', '@INPUT@', '@OUTPUT@'], + install : true, + install_dir : get_option('bindir') + ) +endforeach From c190b9b5dacce2eb9d3c29f41d95e005d5ff6d1d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Jan 2019 13:35:46 -0500 Subject: [PATCH 26/27] meson: Add resolve-system-dependencies Will test on Darwin later --- meson.build | 1 + src/resolve-system-dependencies/meson.build | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/resolve-system-dependencies/meson.build diff --git a/meson.build b/meson.build index 4ac6fd052e6..40c31f1d9ac 100644 --- a/meson.build +++ b/meson.build @@ -301,3 +301,4 @@ subdir('src/libstore') subdir('src/libmain') subdir('src/libexpr') subdir('src/nix') +subdir('src/resolve-system-dependencies') diff --git a/src/resolve-system-dependencies/meson.build b/src/resolve-system-dependencies/meson.build new file mode 100644 index 00000000000..a64073fcc01 --- /dev/null +++ b/src/resolve-system-dependencies/meson.build @@ -0,0 +1,10 @@ +if host_machine.system() == 'darwin' + executable( + 'resolve-system-dependencies', + [ + 'resolve-system-dependencies.cc' + ], + install : true, + install_dir : get_option('libexecdir'), + ) +endif From b71aa9d6b98a56a413c03f6c2d4f7c07d6ea45c6 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 25 Sep 2019 13:56:22 -0400 Subject: [PATCH 27/27] meson: Fix use of the nix state dir Thanks @tetdim for finding --- src/libstore/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 9e5b00f1063..4d9ceb05fc1 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -74,8 +74,8 @@ libstore = library( '-DNIX_PREFIX="@0@"'.format(get_option('prefix')), '-DNIX_STORE_DIR="@0@"'.format(storedir), '-DNIX_DATA_DIR="@0@"'.format(get_option('datadir')), - '-DNIX_STATE_DIR="@0@/nix"'.format(get_option('localstatedir')), - '-DNIX_LOG_DIR="@0@/log/nix"'.format(get_option('localstatedir')), + '-DNIX_STATE_DIR="@0@/nix"'.format(nixstatedir), + '-DNIX_LOG_DIR="@0@/log/nix"'.format(nixstatedir), '-DNIX_CONF_DIR="@0@/nix"'.format(get_option('sysconfdir')), '-DNIX_LIBEXEC_DIR="@0@"'.format(get_option('libexecdir')), '-DNIX_BIN_DIR="@0@"'.format(get_option('bindir')),