From: Jeremy Kerr Date: Thu, 21 Oct 2021 08:08:01 +0000 (+0800) Subject: Revert "meson: revert to using the ccan configurator" X-Git-Tag: v1.0-rc0~71^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c07d7745b2e8611a68673699dca43a21f9e45bf7;p=users%2Fsagi%2Flibnvme.git Revert "meson: revert to using the ccan configurator" We have a fix queued for the issue that the original revert is working-around. This also includes adjustments to the examples/ & tests/ meson definitions to suit. This reverts commit b66a139f12357757c54adf7f38031f0f9105c501. Signed-off-by: Jeremy Kerr --- diff --git a/ccan/meson.build b/ccan/meson.build index c0143427..f24b94f5 100644 --- a/ccan/meson.build +++ b/ccan/meson.build @@ -11,7 +11,7 @@ configurator = executable( c_args: ['-D_GNU_SOURCE'], ) -ccan_config_h = custom_target( +config_h = custom_target( 'config.h', output: 'config.h', capture: true, diff --git a/examples/meson.build b/examples/meson.build index 54ebbdac..7c86c9d2 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -7,7 +7,7 @@ # executable( 'telemetry-listen', - ['telemetry-listen.c', ccan_config_h], + ['telemetry-listen.c', config_h], link_with: libnvme, include_directories: incdir) @@ -19,7 +19,7 @@ executable( executable( 'discover-loop', - ['discover-loop.c', ccan_config_h], + ['discover-loop.c', config_h], link_with: libnvme, include_directories: incdir) diff --git a/meson.build b/meson.build index b07497af..8251cf4f 100644 --- a/meson.build +++ b/meson.build @@ -108,8 +108,87 @@ conf.set('CONFIG_LIBUUID', libuuid.found(), description: 'Is libuuid required?') json_c = dependency('json-c', version: '>=0.13', fallback : ['json-c', 'json_c']) conf.set('CONFIG_JSONC', json_c.found(), description: 'Is json-c required?') -config_host_h = configure_file( - output: 'config-host.h', +# local (cross-compilable) implementations of ccan configure steps +conf.set10( + 'HAVE_BUILTIN_TYPES_COMPATIBLE_P', + cc.compiles( + '''int main(void) { + return __builtin_types_compatible_p(int, long); + } + ''', + name: '__builtin_type_compatible_p' + ), + description: 'Is __builtin_types_compatible_p available?' +) +conf.set10( + 'HAVE_TYPEOF', + cc.compiles( + '''int main(void) { + int a = 1; + typeof(a) b; + b = a; + } + ''', + name: 'typeof' + ), + description: 'Is typeof available?' +) +conf.set10( + 'HAVE_BYTESWAP_H', + cc.compiles( + '''#include ''', + name: 'byteswap.h' + ), + description: 'Is byteswap.h include-able?' +) +conf.set10( + 'HAVE_BSWAP64', + cc.links( + '''#include + int main(void) { + return bswap_64(0); + } + ''', + name: 'bswap64' + ), + description: 'Is bswap_64 available?' +) +conf.set10( + 'HAVE_LITTLE_ENDIAN', + build_machine.endian() == 'little', + description: 'Building for little-endian' +) +conf.set10( + 'HAVE_BIG_ENDIAN', + build_machine.endian() == 'big', + description: 'Building for big-endian' +) +conf.set10( + 'HAVE_STATEMENT_EXPR', + cc.compiles( + '''int main(int argc, char **argv) { + return ({ int x = argc; x == 1; }); + } + ''', + name: 'statement-expr' + ), + description: 'Can we use a statement as an expression?' +) +conf.set10( + 'HAVE_ISBLANK', + cc.links( + '''#include + int main(int argc, char **argv) { + return isblank(argv[0][0]); + } + ''', + name: 'isblank' + ), + description: 'Is isblank() available?' +) + +config_h = configure_file( + output: 'config.h', configuration: conf ) @@ -125,11 +204,10 @@ configure_file( ) ################################################################################ -add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE', '-include', 'config-host.h'], language : 'c') +add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE', '-include', 'config.h'], language : 'c') incdir = include_directories(['.', 'ccan', 'src']) ################################################################################ -subdir('ccan') subdir('src') subdir('pynvme') subdir('test') diff --git a/pynvme/meson.build b/pynvme/meson.build index 2955959f..bde1536b 100644 --- a/pynvme/meson.build +++ b/pynvme/meson.build @@ -19,7 +19,7 @@ endif if have_python_support pymod_swig = custom_target( 'nvme.py', - input: ['nvme.i', config_host_h, ccan_config_h], + input: ['nvme.i', config_h], output: ['nvme.py', 'nvme_wrap.c'], command: [swig, '-python', '-py3', '-o', '@OUTPUT1@', '@INPUT0@'], install: true, diff --git a/src/meson.build b/src/meson.build index 10acb15e..2a6069c6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -14,8 +14,7 @@ sources = [ 'nvme/log.c', 'nvme/tree.c', 'nvme/util.c', - ccan_config_h, - config_host_h, + config_h, ] if conf.get('CONFIG_JSONC') diff --git a/test/meson.build b/test/meson.build index 6b776aa4..7adb963f 100644 --- a/test/meson.build +++ b/test/meson.build @@ -7,7 +7,7 @@ # main = executable( 'main-test', - ['test.c', ccan_config_h], + ['test.c', config_h], dependencies: libuuid, link_with: libnvme, include_directories: incdir @@ -22,14 +22,14 @@ cpp = executable( register = executable( 'test-register', - ['register.c', ccan_config_h], + ['register.c', config_h], link_with: libnvme, include_directories: incdir ) zns = executable( 'test-zns', - ['zns.c', ccan_config_h], + ['zns.c', config_h], link_with: libnvme, include_directories: incdir )