meson: migrate generated headers to a generator() object

Change-Id: Ie7b9cab4189825e8f02dfb39d298302bc36fcb61
This commit is contained in:
Qyriad 2024-03-15 18:55:59 -06:00
parent 75f823f2e4
commit f150b3f7f8
4 changed files with 29 additions and 69 deletions

View file

@ -116,6 +116,18 @@ deps += lowdown
bash = find_program('bash') bash = find_program('bash')
lsof = find_program('lsof') lsof = find_program('lsof')
# This is how Nix does generated headers...
# FIXME(Qyriad): do we really need to use the shell for this?
gen_header = generator(
bash,
arguments : [
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
output : '@PLAINNAME@.gen.hh',
)
# #
# Configuration # Configuration
# #

View file

@ -1,24 +1,5 @@
schema_sql_gen = custom_target( schema_sql_gen = gen_header.process('schema.sql')
input : 'schema.sql', ca_specific_schema_gen = gen_header.process('ca-specific-schema.sql')
output : 'schema.sql.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
ca_specific_schema = custom_target(
input : 'ca-specific-schema.sql',
output : 'ca-specific-schema.sql.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
libstore_sources = files( libstore_sources = files(
'binary-cache-store.cc', 'binary-cache-store.cc',
@ -117,7 +98,7 @@ endforeach
libstore = library( libstore = library(
'nixstore', 'nixstore',
schema_sql_gen, schema_sql_gen,
ca_specific_schema, ca_specific_schema_gen,
libstore_sources, libstore_sources,
dependencies : [ dependencies : [
libarchive, libarchive,

View file

@ -25,43 +25,27 @@ nix_build_sources = files(
nix_channel_sources = files( nix_channel_sources = files(
'nix-channel/nix-channel.cc', 'nix-channel/nix-channel.cc',
) )
unpack_channel_gen = custom_target( unpack_channel_gen = gen_header.process('nix-channel/unpack-channel.nix')
input : 'nix-channel/unpack-channel.nix',
output : 'unpack-channel.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_collect_garbage_sources = files( nix_collect_garbage_sources = files(
'nix-collect-garbage/nix-collect-garbage.cc', 'nix-collect-garbage/nix-collect-garbage.cc',
) )
nix_copy_closure_sources = files( nix_copy_closure_sources = files(
'nix-copy-closure/nix-copy-closure.cc', 'nix-copy-closure/nix-copy-closure.cc',
) )
nix_env_buildenv_gen = gen_header.process('nix-env/buildenv.nix')
nix_env_sources = files(
'nix-env/nix-env.cc',
'nix-env/user-env.cc',
)
nix_instantiate_sources = files(
'nix-instantiate/nix-instantiate.cc',
)
nix_store_sources = files( nix_store_sources = files(
'nix-store/dotgraph.cc', 'nix-store/dotgraph.cc',
'nix-store/graphml.cc', 'nix-store/graphml.cc',
'nix-store/nix-store.cc', 'nix-store/nix-store.cc',
) )
nix_env_buildenv = custom_target(
input : 'nix-env/buildenv.nix',
output : 'buildenv.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_env_sources = files(
'nix-env/nix-env.cc',
'nix-env/user-env.cc',
)
# Hurray for Meson list flattening! # Hurray for Meson list flattening!
nix2_commands_sources = [ nix2_commands_sources = [
build_remote_sources, build_remote_sources,
@ -70,9 +54,10 @@ nix2_commands_sources = [
unpack_channel_gen, unpack_channel_gen,
nix_collect_garbage_sources, nix_collect_garbage_sources,
nix_copy_closure_sources, nix_copy_closure_sources,
nix_store_sources, nix_env_buildenv_gen,
nix_env_buildenv,
nix_env_sources, nix_env_sources,
nix_instantiate_sources,
nix_store_sources,
] ]
# Finally, the nix command itself, which all of the other commands are implmented in terms of # Finally, the nix command itself, which all of the other commands are implmented in terms of

View file

@ -1,24 +1,6 @@
generate_manpage_gen = custom_target( generate_manpage_gen = gen_header.process(meson.project_source_root() / 'doc/manual/generate-manpage.nix')
input : meson.project_source_root() / 'doc/manual/generate-manpage.nix',
output : 'generate-manpage.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
utils_gen = custom_target( utils_gen = gen_header.process(meson.project_source_root() / 'doc/manual/utils.nix')
input : meson.project_source_root() / 'doc/manual/utils.nix',
output : 'utils.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_sources = files( nix_sources = files(
'add-to-store.cc', 'add-to-store.cc',