Skip to content

Commit

Permalink
Merge pull request #11064 from obsidiansystems/header-generater
Browse files Browse the repository at this point in the history
Use a meson "generator" to deduplicate `.gen.hh` creation
  • Loading branch information
Ericson2314 authored Jul 8, 2024
2 parents 1439de8 + 6e5cec2 commit f1d88e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
7 changes: 7 additions & 0 deletions build-utils-meson/generate-header/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bash = find_program('bash', native: true)

gen_header = generator(
bash,
arguments : [ '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
output : '@PLAINNAME@.gen.hh',
)
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project('nix-dev-shell', 'cpp',
subproject_dir : 'src',
)

# Internal Libraries
subproject('libutil')
subproject('libstore')
subproject('libfetchers')
Expand All @@ -18,7 +19,7 @@ subproject('libcmd')
subproject('internal-api-docs')
subproject('external-api-docs')

# C wrappers
# External C wrapper libraries
subproject('libutil-c')
subproject('libstore-c')
subproject('libexpr-c')
Expand Down
9 changes: 3 additions & 6 deletions src/libexpr/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,17 @@ lexer_tab = custom_target(
install_dir : get_option('includedir') / 'nix',
)

subdir('build-utils-meson/generate-header')

generated_headers = []
foreach header : [
'imported-drv-to-derivation.nix',
'fetchurl.nix',
'call-flake.nix',
]
generated_headers += custom_target(
command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
input : header,
output : '@PLAINNAME@.gen.hh',
)
generated_headers += gen_header.process(header)
endforeach


sources = files(
'attr-path.cc',
'attr-set.cc',
Expand Down
11 changes: 3 additions & 8 deletions src/libexpr/primops/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
foreach header : [
generated_headers += gen_header.process(
'derivation.nix',
]
generated_headers += custom_target(
command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
input : header,
output : '@PLAINNAME@.gen.hh',
)
endforeach
preserve_path_from: meson.project_source_root(),
)

sources += files(
'context.cc',
Expand Down
10 changes: 3 additions & 7 deletions src/libstore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,14 @@ deps_public += nlohmann_json
sqlite = dependency('sqlite3', 'sqlite', version : '>=3.6.19')
deps_private += sqlite

subdir('build-utils-meson/generate-header')

generated_headers = []
foreach header : [
'schema.sql',
'ca-specific-schema.sql',
]
generated_headers += custom_target(
command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
input : header,
output : '@PLAINNAME@.gen.hh',
install : true,
install_dir : get_option('includedir') / 'nix',
)
generated_headers += gen_header.process(header)
endforeach

busybox = find_program(get_option('sandbox-shell'), required : false)
Expand Down

0 comments on commit f1d88e0

Please sign in to comment.