diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index d40c646c3..94ce0afd5 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -2,14 +2,11 @@ # Explicitly link curl so it binds to Nix-store libcurl, not /usr/lib/libcurl. if is_darwin plugin_deps = [ - liblixutil.partial_dependency(includes : true, compile_args : true), - liblixstore.partial_dependency(includes : true, compile_args : true), - liblixexpr.partial_dependency(includes : true, compile_args : true), - liblixfetchers.partial_dependency(includes : true, compile_args : true), + liblix.partial_dependency(includes : true, compile_args : true), curl, ] else - plugin_deps = [liblixutil, liblixstore, liblixexpr, liblixfetchers, curl] + plugin_deps = [liblix, curl] endif plugin_mtls_store = shared_module( diff --git a/lix/libcmd/meson.build b/lix/libcmd/meson.build index 3ba822fcd..20804cb0a 100644 --- a/lix/libcmd/meson.build +++ b/lix/libcmd/meson.build @@ -1,4 +1,4 @@ -libcmd_sources = files( +liblix_sources += files( 'built-path.cc', 'cmd-profiles.cc', 'command.cc', @@ -32,44 +32,8 @@ libcmd_headers = files( 'repl.hh', ) -libcmd_generated_headers = [ +liblix_generated_headers += [ gen_header.process('repl-overlays.nix', preserve_path_from: meson.current_source_dir()), ] -libcmd = library( - 'lixcmd', - libcmd_generated_headers, - libcmd_sources, - dependencies : [ - liblixutil, - liblixstore, - liblixfetchers, - liblixexpr, - liblixmain, - liblix_doc, - boehm, - editline, - kj, - lowdown, - ncurses, - nlohmann_json, - ], - # '../..' for self references like "lix/libcmd/*.hh" - include_directories : [ '../..' ], - cpp_pch : cpp_pch, - install : true, - # FIXME(Qyriad): is this right? - install_rpath : libdir, -) - install_headers(libcmd_headers, subdir : 'lix/libcmd', preserve_path : true) - -liblixcmd = declare_dependency( - include_directories : include_directories('../..'), - dependencies : [ - liblixutil, - liblixstore, - kj, - ], - link_with : libcmd, -) diff --git a/lix/libexpr/flake/meson.build b/lix/libexpr/flake/meson.build index cce1b0c75..ee4702767 100644 --- a/lix/libexpr/flake/meson.build +++ b/lix/libexpr/flake/meson.build @@ -1,4 +1,4 @@ -libexpr_generated_headers += custom_target( +liblix_generated_headers += custom_target( command : [ 'bash', '-c', 'echo \'R"__NIX_STR(\' | cat - @INPUT@ && echo \')__NIX_STR"\'' ], input : 'call-flake.nix', output : '@PLAINNAME@.gen.hh', diff --git a/lix/libexpr/meson.build b/lix/libexpr/meson.build index 0a66ec83d..0552dff2c 100644 --- a/lix/libexpr/meson.build +++ b/lix/libexpr/meson.build @@ -1,8 +1,8 @@ -libexpr_generated_headers = [ +liblix_generated_headers += [ gen_header.process('primops/derivation.nix', preserve_path_from : meson.current_source_dir()), ] foreach header : [ 'imported-drv-to-derivation.nix', 'fetchurl.nix' ] - libexpr_generated_headers += custom_target( + liblix_generated_headers += custom_target( command : [ 'bash', '-c', 'echo \'R"__NIX_STR(\' | cat - @INPUT@ && echo \')__NIX_STR"\'' ], input : header, output : '@PLAINNAME@.gen.hh', @@ -33,7 +33,7 @@ libexpr_setting_definitions = files( 'settings/trace-verbose.md', # keep-sorted end ) -libexpr_settings_header = custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -173,7 +173,7 @@ builtins_gen = custom_target( 'builtins.md', ], ) -register_builtins_header = builtins_gen[0] +liblix_generated_headers += builtins_gen[0] builtins_md = builtins_gen[1] builtin_constant_definitions = files( @@ -204,10 +204,10 @@ builtin_constants_gen = custom_target( 'builtin-constants.md', ], ) -register_builtin_constants_header = builtin_constants_gen[0] +liblix_generated_headers += builtin_constants_gen[0] builtin_constants_md = builtin_constants_gen[1] -libexpr_sources = files( +liblix_sources += files( # keep-sorted start 'attr-path.cc', 'attr-set.cc', @@ -278,49 +278,8 @@ libexpr_headers = files( # keep-sorted end ) -dependencies = [ - liblixutil, - liblixstore, - liblixfetchers, - boehm, - boost, - kj, - nlohmann_json, - toml11, -] - -libexpr = library( - 'lixexpr', - libexpr_sources, - libexpr_settings_header, - libexpr_generated_headers, - register_builtins_header, - register_builtin_constants_header, - dependencies : dependencies, - # for shared.hh - include_directories : [ - '../libmain', - ], - cpp_pch : cpp_pch, - install : true, - # FIXME(Qyriad): is this right? - install_rpath : libdir, -) - install_headers( libexpr_headers, subdir : 'lix/libexpr', preserve_path : true, ) - -liblixexpr = declare_dependency( - include_directories : include_directories('../..'), - sources : libexpr_settings_header, - dependencies : [ - liblixutil, - liblixfetchers, - boehm, - boost, - ], - link_with : libexpr, -) diff --git a/lix/libfetchers/meson.build b/lix/libfetchers/meson.build index 39d66d177..13601766d 100644 --- a/lix/libfetchers/meson.build +++ b/lix/libfetchers/meson.build @@ -1,4 +1,4 @@ -libfetchers_sources = files( +liblix_sources += files( 'attrs.cc', 'cache.cc', 'fetch-settings.cc', @@ -31,7 +31,7 @@ libfetchers_setting_definitions = files( 'settings/use-registries.md', 'settings/warn-dirty.md', ) -libfetchers_settings_header = custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -46,34 +46,4 @@ libfetchers_settings_header = custom_target( install_dir : includedir / 'lix/libfetchers', ) -dependencies = [ - liblixstore, - liblixutil, - kj, - nlohmann_json, -] - -libfetchers = library( - 'lixfetchers', - libfetchers_settings_header, - libfetchers_sources, - dependencies : dependencies, - include_directories : [ '../..' ], - cpp_pch : cpp_pch, - install : true, - # FIXME(Qyriad): is this right? - install_rpath : libdir, -) - install_headers(libfetchers_headers, subdir : 'lix/libfetchers', preserve_path : true) - -liblixfetchers = declare_dependency( - include_directories : include_directories('../..'), - sources : libfetchers_settings_header, - dependencies : [ - liblixutil, - liblixstore, - kj, - ], - link_with : libfetchers, -) diff --git a/lix/libmain/meson.build b/lix/libmain/meson.build index 8d64ac9a9..9242204e1 100644 --- a/lix/libmain/meson.build +++ b/lix/libmain/meson.build @@ -1,4 +1,4 @@ -libmain_sources = files( +liblix_sources += files( 'common-args.cc', 'crash-handler.cc', 'loggers.cc', @@ -15,29 +15,4 @@ libmain_headers = files( 'shared.hh', ) -libmain = library( - 'lixmain', - libmain_sources, - dependencies : [ - liblixutil, - liblixstore, - liblixexpr, - boost, - kj, - ], - include_directories : [ '../..' ], - cpp_pch : cpp_pch, - install : true, - # FIXME(Qyriad): is this right? - install_rpath : libdir, -) - install_headers(libmain_headers, subdir : 'lix/libmain', preserve_path : true) - -liblixmain = declare_dependency( - include_directories : include_directories('../..'), - dependencies : [ - liblixutil, - ], - link_with : libmain, -) diff --git a/lix/libstore/meson.build b/lix/libstore/meson.build index 9172d2444..40eb42aba 100644 --- a/lix/libstore/meson.build +++ b/lix/libstore/meson.build @@ -1,7 +1,5 @@ -libstore_generated_headers = [] -libstore_generated_sources = [] foreach header : [ 'schema.sql' ] - libstore_generated_headers += custom_target( + liblix_generated_headers += custom_target( command : [ 'bash', '-c', 'echo \'R"__NIX_STR(\' | cat - @INPUT@ && echo \')__NIX_STR"\'' ], input : header, output : '@PLAINNAME@.gen.hh', @@ -41,15 +39,13 @@ subdir('build') foreach i : libstore_rpc foreach rpc_src : i.to_list() if rpc_src.full_path().endswith('.h') - libstore_generated_headers += [ rpc_src ] + liblix_generated_headers += [ rpc_src ] else - libstore_generated_sources += [ rpc_src ] + liblix_sources += [ rpc_src ] endif endforeach endforeach -libstore_settings_headers = [] - file_transfer_setting_definitions = files( # keep-sorted start 'file-transfer-settings/download-attempts.md', @@ -62,7 +58,7 @@ file_transfer_setting_definitions = files( 'file-transfer-settings/user-agent-suffix.md', # keep-sorted end ) -libstore_settings_headers += custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -155,7 +151,7 @@ libstore_setting_definitions = files( 'settings/use-xdg-base-directories.md', # keep-sorted end ) -libstore_settings_headers += custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -170,13 +166,12 @@ libstore_settings_headers += custom_target( install_dir : includedir / 'lix/libstore', ) -libstore_extra_objects = [] if dtrace_feature.enabled() - libstore_settings_headers += dtrace_header_gen.process('trace-probes.d') - libstore_extra_objects += dtrace_object_gen.process('trace-probes.d') + liblix_generated_headers += dtrace_header_gen.process('trace-probes.d') + liblix_sources += dtrace_object_gen.process('trace-probes.d') endif -libstore_sources = files( +liblix_sources += files( # keep-sorted start 'binary-cache-store.cc', 'build-result.cc', @@ -317,66 +312,17 @@ libstore_headers = files( ) if host_machine.system() == 'linux' - libstore_sources += files('platform/linux.cc') + liblix_sources += files('platform/linux.cc') libstore_headers += files('platform/linux.hh') elif host_machine.system() == 'darwin' - libstore_sources += files('platform/darwin.cc') + liblix_sources += files('platform/darwin.cc') libstore_headers += files('platform/darwin.hh') elif host_machine.system() == 'freebsd' - libstore_sources += files('platform/freebsd.cc') + liblix_sources += files('platform/freebsd.cc') libstore_headers += files('platform/freebsd.hh') else - libstore_sources += files('platform/fallback.cc') + liblix_sources += files('platform/fallback.cc') libstore_headers += files('platform/fallback.hh') endif -libstore_generated_headers += embedded_sandbox_headers - -dependencies = [ - liblixutil, # Internal. - aws_s3, - aws_sdk, - aws_sdk_transfer, - boost, - capnp_rpc, - curl, - kj, - libarchive, - nlohmann_json, - openssl, - seccomp, - sqlite, -] - -if host_machine.system() == 'freebsd' - dependencies += [ libprocstat ] -endif - -libstore = library( - 'lixstore', - libstore_sources, - libstore_generated_sources, - libstore_settings_headers, - libstore_generated_headers, - libstore_extra_objects, - include_directories : [ '../..' ], - dependencies : dependencies, - cpp_args : cpp_args, - cpp_pch : cpp_pch, - install : true, - # FIXME(Qyriad): is this right? - install_rpath : libdir, -) - install_headers(libstore_headers, subdir : 'lix/libstore', preserve_path : true) - -# Used by libfetchers. -liblixstore = declare_dependency( - include_directories : include_directories('../..'), - sources : libstore_settings_headers, - dependencies : [ - liblixutil, - kj, - ], - link_with : libstore, -) diff --git a/lix/libstore/platform/darwin.cc b/lix/libstore/platform/darwin.cc index dacf73023..6b7c3a152 100644 --- a/lix/libstore/platform/darwin.cc +++ b/lix/libstore/platform/darwin.cc @@ -5,7 +5,7 @@ #include "lix/libstore/platform/darwin.hh" #include "lix/libutil/regex.hh" #include "lix/libutil/strings.hh" -#include "temporary-dir.hh" +#include "lix/libstore/temporary-dir.hh" #include #include diff --git a/lix/libstore/platform/linux.cc b/lix/libstore/platform/linux.cc index e96afb43b..f6b1fe8ce 100644 --- a/lix/libstore/platform/linux.cc +++ b/lix/libstore/platform/linux.cc @@ -1,4 +1,4 @@ -#include "build/personality.hh" +#include "lix/libstore/build/personality.hh" #include "lix/libstore/build/worker.hh" #include "lix/libutil/c-calls.hh" #include "lix/libutil/cgroup.hh" diff --git a/lix/libutil/meson.build b/lix/libutil/meson.build index f0af2a941..aa2f47ae3 100644 --- a/lix/libutil/meson.build +++ b/lix/libutil/meson.build @@ -1,4 +1,4 @@ -libutil_sources = files( +liblix_sources += files( # keep-sorted start 'abstract-config.cc', 'archive.cc', @@ -209,8 +209,10 @@ experimental_features_gen = custom_target( false, ], ) -experimental_features_header = experimental_features_gen[0] -experimental_features_impl_header = experimental_features_gen[1] +liblix_generated_headers += [ + experimental_features_gen[0], + experimental_features_gen[1], +] experimental_features_shortlist_md = experimental_features_gen[2] experimental_feature_descriptions_md = experimental_features_gen[3] @@ -240,18 +242,18 @@ deprecated_features_gen = custom_target( false ], ) -deprecated_features_header = deprecated_features_gen[0] -deprecated_features_impl_header = deprecated_features_gen[1] +liblix_generated_headers += [ + deprecated_features_gen[0], + deprecated_features_gen[1], +] deprecated_features_shortlist_md = deprecated_features_gen[2] deprecated_feature_descriptions_md = deprecated_features_gen[3] -libutil_settings_headers = [] - archive_setting_definitions = files( 'archive-settings/preallocate-contents.md', 'archive-settings/use-case-hack.md', ) -libutil_settings_headers += custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -268,7 +270,7 @@ feature_setting_definitions = files( 'feature-settings/deprecated-features.md', 'feature-settings/experimental-features.md', ) -libutil_settings_headers += custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -289,7 +291,7 @@ logging_setting_definitions = files( 'logging-settings/show-trace.md', # keep-sorted end ) -libutil_settings_headers += custom_target( +liblix_generated_headers += custom_target( command : [ python.full_path(), '@SOURCE_ROOT@/lix/code-generation/build_settings.py', @@ -304,9 +306,6 @@ libutil_settings_headers += custom_target( install_dir : includedir / 'lix/libutil', ) -libutil_rpc_headers = [] -libutil_rpc_sources = [] - libutil_rpc_schemas = files( # keep-sorted start 'logging.capnp', @@ -335,65 +334,8 @@ foreach rpc : libutil_rpc_schemas depfile : '@PLAINNAME@.d', ) - libutil_rpc_headers += rpc[0] - libutil_rpc_sources += rpc[1] + liblix_generated_headers += rpc[0] + liblix_sources += rpc[1] endforeach -dependencies = [ - boost, - brotli, - cpuid, - kj, - capnp_rpc, - libarchive, - nlohmann_json, - openssl, - libatomic, - - # NOTE: this is secretly rust-monocrate in a trenchcoat. - # See that directory's README for more details. - liblixutil_rs, -] - -libutil = library( - 'lixutil', - libutil_sources, - libutil_rpc_sources, - libutil_rpc_headers, - experimental_features_header, - experimental_features_impl_header, - deprecated_features_header, - deprecated_features_impl_header, - libutil_settings_headers, - dependencies : dependencies, - include_directories : [ '../..' ], - cpp_pch : cpp_pch, - implicit_include_directories : true, - install : true, -) - install_headers(libutil_headers, subdir : 'lix/libutil', preserve_path : true) - -# Used by libstore and libfetchers. -liblixutil = declare_dependency( - include_directories : include_directories('../..'), - sources : [ - experimental_features_header, - deprecated_features_header, - libutil_settings_headers, - libutil_rpc_headers, - ], - dependencies: [ - boost, - # Everything has to link to kj if it uses libutil internally (ensured by - # lix-base pkg-config externally) - kj, - capnp_rpc, - libarchive, - nlohmann_json, - libatomic, - # This is secretly rust-monocrate + the generated header. - liblixutil_rs, - ], - link_with : libutil -) diff --git a/lix/lix.pc.in b/lix/lix.pc.in index be89d6dc7..04ec1705d 100644 --- a/lix/lix.pc.in +++ b/lix/lix.pc.in @@ -9,4 +9,4 @@ Version: @PACKAGE_VERSION@ Requires: lix-base kj-async @BOEHM_IF_FOUND@ Requires.private: @AWS_SDK_IF_FOUND@ @BOEHM_IF_FOUND@ libeditline lowdown ncurses libbrotlidec libbrotlienc libcpuid libarchive libcrypto capnp-rpc libcurl libseccomp sqlite3 Cflags: -I${includedir} -Libs: -L${libdir} -lrust_monocrate -llixutil -llixstore -llixfetchers -llixexpr -llixmain -llixcmd +Libs: -L${libdir} -lrust_monocrate -llix diff --git a/lix/meson.build b/lix/meson.build index 44dc05fbf..31b06b6c5 100644 --- a/lix/meson.build +++ b/lix/meson.build @@ -140,21 +140,16 @@ liblixutil_rs = declare_dependency( sources : [libutil_rs_gen_h], ) -# liblix_doc is actually rust-monocrate in a trenchcoat. -liblix_doc = declare_dependency( - link_with : rust_monocrate, -) +# we only collect sources and generated headers here. real headers are collected and +# installed by each subdir due to how meson generates paths for headers it installs. +liblix_sources = [] +liblix_generated_headers = embedded_sandbox_headers subdir('libutil') -# Load-bearing order. libstore depends on libutil. subdir('libstore') -# libfetchers depends on libstore subdir('libfetchers') -# libexpr depends on all of the above subdir('libexpr') -# libmain depends on libutil and libstore subdir('libmain') -# libcmd depends on everything subdir('libcmd') # libexec utilities should depend only on libutil, but meh. @@ -176,15 +171,55 @@ foreach lib : [ 'util', 'store', 'fetchers', 'expr', 'main', 'cmd' ] ) endforeach +dependencies = [ + aws_s3, + aws_sdk, + aws_sdk_transfer, + boehm, + boost, + brotli, + capnp_rpc, + cpuid, + curl, + editline, + kj, + libarchive, + libatomic, + lowdown, + ncurses, + nlohmann_json, + openssl, + seccomp, + sqlite, + toml11, + # NOTE: this is secretly rust-monocrate in a trenchcoat. + # See that directory's README for more details. + liblixutil_rs, +] + +if host_machine.system() == 'freebsd' + dependencies += [ libprocstat ] +endif + +liblix_all = library( + 'lix', + liblix_sources, + liblix_generated_headers, + dependencies : dependencies, + # `..` makes the `lix/` subtree of the repo available for includes, + # mirroring our header directory structure once they are installed. + include_directories : [ '..' ], + cpp_args : cpp_args, + cpp_pch : cpp_pch, + install : true, + # FIXME(Qyriad): is this right? + install_rpath : libdir, +) + liblix = declare_dependency( - dependencies : [ - liblixutil, - liblixstore, - liblixfetchers, - liblixexpr, - liblixmain, - liblixcmd, - ], + include_directories : include_directories('..'), + dependencies : dependencies, + link_with : liblix_all, ) meson.override_dependency('lix', liblix)