From: Daan De Meyer Date: Thu, 22 May 2025 08:32:32 +0000 (+0200) Subject: meson: Use .inc for generated code meant to be included in other files X-Git-Tag: v258-rc1~521^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ea01af24086ac7c4042dd03ea368392309e0390;p=thirdparty%2Fsystemd.git meson: Use .inc for generated code meant to be included in other files These files use the .h extension but are not standalone so let's not make it appear like they are proper headers and instead use the .inc extension. --- diff --git a/src/basic/af-list.c b/src/basic/af-list.c index 60da592e3f8..421a16d73f3 100644 --- a/src/basic/af-list.c +++ b/src/basic/af-list.c @@ -10,8 +10,8 @@ static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len); -#include "af-from-name.h" -#include "af-to-name.h" +#include "af-from-name.inc" +#include "af-to-name.inc" const char* af_to_name(int id) { diff --git a/src/basic/arphrd-util.c b/src/basic/arphrd-util.c index 2aa48182fcc..063aede5e72 100644 --- a/src/basic/arphrd-util.c +++ b/src/basic/arphrd-util.c @@ -12,8 +12,8 @@ static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len); -#include "arphrd-from-name.h" -#include "arphrd-to-name.h" +#include "arphrd-from-name.inc" +#include "arphrd-to-name.inc" int arphrd_from_name(const char *name) { const struct arphrd_name *sc; diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c index c2b374c8fcf..9ae679330ac 100644 --- a/src/basic/cap-list.c +++ b/src/basic/cap-list.c @@ -17,8 +17,8 @@ static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len); -#include "cap-from-name.h" -#include "cap-to-name.h" +#include "cap-from-name.inc" +#include "cap-to-name.inc" const char* capability_to_name(int id) { if (id < 0) diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c index 677b906cc54..396879c8f2c 100644 --- a/src/basic/errno-list.c +++ b/src/basic/errno-list.c @@ -10,10 +10,10 @@ static const struct errno_name* lookup_errno(register const char *str, register GPERF_LEN_TYPE len); -#include "errno-from-name.h" +#include "errno-from-name.inc" #if !HAVE_STRERRORNAME_NP -#include "errno-to-name.h" +#include "errno-to-name.inc" const char* errno_to_name(int id) { diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 05ff75cd5d4..45f56fdf5aa 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -6,7 +6,7 @@ const char* fs_type_to_string(statfs_f_type_t magic) { switch (magic) { -#include "filesystem-switch-case.h" +#include "filesystem-switch-case.inc" } return NULL; @@ -158,7 +158,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { .name = "@known", .help = "All known filesystems declared in the kernel", .value = -#include "filesystem-list.h" +#include "filesystem-list.inc" }, }; diff --git a/src/basic/meson.build b/src/basic/meson.build index df363f6048e..2de53df9356 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -168,7 +168,7 @@ foreach item : [['af', af_list_txt, 'af', ''], command : [generate_gperfs, item[2], item[3], '@INPUT@'], capture : true) - fname = '@0@-from-name.h'.format(item[0]) + fname = '@0@-from-name.inc'.format(item[0]) target1 = custom_target( fname, input : gperf_file, @@ -181,7 +181,7 @@ foreach item : [['af', af_list_txt, 'af', ''], '@INPUT@'], capture : true) - fname = '@0@-to-name.h'.format(item[0]) + fname = '@0@-to-name.inc'.format(item[0]) awkscript = '@0@-to-name.awk'.format(item[0]) target2 = custom_target( fname, @@ -266,8 +266,8 @@ filesystems_gperf_h = custom_target( command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) generate_filesystem_list = find_program('generate-filesystem-list.py') -fname = 'filesystem-list.h' -filesystem_list_h = custom_target( +fname = 'filesystem-list.inc' +filesystem_list_inc = custom_target( fname, input : 'filesystems-gperf.gperf', output : fname, @@ -275,18 +275,18 @@ filesystem_list_h = custom_target( '@INPUT@'], capture : true) -generate_filesystem_switch_case_h = find_program('generate-filesystem-switch-case.py') -fname = 'filesystem-switch-case.h' -filesystem_switch_case_h = custom_target( +generate_filesystem_switch_case_inc = find_program('generate-filesystem-switch-case.py') +fname = 'filesystem-switch-case.inc' +filesystem_switch_case_inc = custom_target( fname, input : 'filesystems-gperf.gperf', - output : 'filesystem-switch-case.h', - command : [generate_filesystem_switch_case_h, + output : fname, + command : [generate_filesystem_switch_case_inc, '@INPUT@'], capture : true) -generated_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h] -basic_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h] +generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h] +basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h] libbasic_static = static_library( 'basic', diff --git a/src/libsystemd/sd-journal/audit-type.c b/src/libsystemd/sd-journal/audit-type.c index 122cdf5d3f6..1995e3fa180 100644 --- a/src/libsystemd/sd-journal/audit-type.c +++ b/src/libsystemd/sd-journal/audit-type.c @@ -3,4 +3,4 @@ #include "audit-type.h" #include "missing_audit.h" -#include "audit_type-to-name.h" +#include "audit_type-to-name.inc" diff --git a/src/libsystemd/sd-journal/meson.build b/src/libsystemd/sd-journal/meson.build index 5b8b582f27d..f49b59a7c12 100644 --- a/src/libsystemd/sd-journal/meson.build +++ b/src/libsystemd/sd-journal/meson.build @@ -27,8 +27,8 @@ audit_type_list_txt = custom_target( capture : true) audit_type_to_name = custom_target( - 'audit_type-to-name.h', + 'audit_type-to-name.inc', input : ['audit_type-to-name.awk', audit_type_list_txt], - output : 'audit_type-to-name.h', + output : 'audit_type-to-name.inc', command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c index 57fd915c691..0cf5926f81e 100644 --- a/src/resolve/dns-type.c +++ b/src/resolve/dns-type.c @@ -14,8 +14,8 @@ typedef const struct { static const struct dns_type_name * lookup_dns_type (register const char *str, register GPERF_LEN_TYPE len); -#include "dns_type-from-name.h" -#include "dns_type-to-name.h" +#include "dns_type-from-name.inc" +#include "dns_type-to-name.inc" int dns_type_from_string(const char *s) { const struct dns_type_name *sc; diff --git a/src/resolve/meson.build b/src/resolve/meson.build index b47dfd27249..5312eaece96 100644 --- a/src/resolve/meson.build +++ b/src/resolve/meson.build @@ -61,10 +61,10 @@ gperf_file = custom_target( command : [generate_dns_type_gperf, 'dns_type', 'DNS_TYPE_', '@INPUT@'], capture : true) -dns_type_from_name_h = custom_target( - 'dns_type-from-name.h', +dns_type_from_name_inc = custom_target( + 'dns_type-from-name.inc', input : gperf_file, - output : 'dns_type-from-name.h', + output : 'dns_type-from-name.inc', command : [gperf, '-L', 'ANSI-C', '-t', '--ignore-case', '-N', 'lookup_dns_type', @@ -73,10 +73,10 @@ dns_type_from_name_h = custom_target( '@INPUT@'], capture : true) -dns_type_to_name_h = custom_target( - 'dns_type-to-name.h', +dns_type_to_name_inc = custom_target( + 'dns_type-to-name.inc', input : ['dns_type-to-name.awk', dns_type_list_txt], - output : 'dns_type-to-name.h', + output : 'dns_type-to-name.inc', command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) @@ -98,8 +98,8 @@ resolved_dns_delegate_gperf_c = custom_target( output : 'resolved-dns-delegate-gperf.c', command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) -generated_sources += [dns_type_from_name_h, dns_type_to_name_h, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c] -systemd_resolved_extract_sources += [dns_type_from_name_h, dns_type_to_name_h, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c] +generated_sources += [dns_type_from_name_inc, dns_type_to_name_inc, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c] +systemd_resolved_extract_sources += [dns_type_from_name_inc, dns_type_to_name_inc, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c] if conf.get('ENABLE_DNS_OVER_TLS') == 1 systemd_resolved_extract_sources += files( diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index c807aceefdc..85fd2a09734 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -154,7 +154,7 @@ static const char* const netdev_feature_table[_NET_DEV_FEAT_MAX] = { }; static const char* const ethtool_link_mode_bit_table[] = { -# include "ethtool-link-mode.h" +# include "ethtool-link-mode.inc" }; /* Make sure the array is large enough to fit all bits */ assert_cc((ELEMENTSOF(ethtool_link_mode_bit_table)-1) / 32 < N_ADVERTISE); diff --git a/src/shared/ip-protocol-list.c b/src/shared/ip-protocol-list.c index 923d60abba2..606d2b2dbee 100644 --- a/src/shared/ip-protocol-list.c +++ b/src/shared/ip-protocol-list.c @@ -11,8 +11,8 @@ static const struct ip_protocol_name* lookup_ip_protocol(register const char *str, register GPERF_LEN_TYPE len); -#include "ip-protocol-from-name.h" -#include "ip-protocol-to-name.h" +#include "ip-protocol-from-name.inc" +#include "ip-protocol-to-name.inc" const char* ip_protocol_to_name(int id) { diff --git a/src/shared/meson.build b/src/shared/meson.build index 3f70ddbfd52..3039e5e29e4 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -227,8 +227,8 @@ if get_option('tests') != 'false' endif generate_syscall_list = find_program('generate-syscall-list.py') -fname = 'syscall-list.h' -syscall_list_h = custom_target( +fname = 'syscall-list.inc' +syscall_list_inc = custom_target( fname, input : syscall_list_txt, output : fname, @@ -236,7 +236,7 @@ syscall_list_h = custom_target( '@INPUT@'], capture : true) -generated_sources += syscall_list_h +generated_sources += syscall_list_inc if conf.get('ENABLE_UTMP') == 1 shared_sources += files('utmp-wtmp.c') @@ -244,7 +244,7 @@ endif if conf.get('HAVE_SECCOMP') == 1 shared_sources += files('seccomp-util.c') - shared_sources += syscall_list_h + shared_sources += syscall_list_inc endif if conf.get('HAVE_LIBIPTC') == 1 @@ -282,7 +282,7 @@ gperf_file = custom_target( command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', ''], capture : true) -fname = 'ip-protocol-from-name.h' +fname = 'ip-protocol-from-name.inc' target1 = custom_target( fname, input : gperf_file, @@ -295,7 +295,7 @@ target1 = custom_target( '@INPUT@'], capture : true) -fname = 'ip-protocol-to-name.h' +fname = 'ip-protocol-to-name.inc' awkscript = 'ip-protocol-to-name.awk' target2 = custom_target( fname, @@ -307,16 +307,16 @@ target2 = custom_target( generated_sources += [target1, target2] shared_sources += [target1, target2] -fname = 'ethtool-link-mode.h' -ethtool_link_mode_h = custom_target( +fname = 'ethtool-link-mode.inc' +ethtool_link_mode_inc = custom_target( fname, input : ['ethtool-link-mode.py', '../basic/include/linux/ethtool.h'], output : fname, command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'], capture : true) -generated_sources += ethtool_link_mode_h -shared_sources += ethtool_link_mode_h +generated_sources += ethtool_link_mode_inc +shared_sources += ethtool_link_mode_inc sources += shared_sources fname = 'ethtool-link-mode.xml' diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index 416e6292070..07a59830545 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -989,7 +989,7 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = { .help = "All known syscalls declared in the kernel", .value = "@obsolete\0" -#include "syscall-list.h" +#include "syscall-list.inc" }, }; diff --git a/src/test/test-af-list.c b/src/test/test-af-list.c index 2dbb3097d9e..59ee1758d16 100644 --- a/src/test/test-af-list.c +++ b/src/test/test-af-list.c @@ -1,13 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "af-list.h" #include "tests.h" _unused_ static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len); -#include "af-from-name.h" -#include "af-list.h" -#include "af-to-name.h" +#include "af-from-name.inc" +#include "af-to-name.inc" TEST(af_list) { for (unsigned i = 0; i < ELEMENTSOF(af_names); i++) { diff --git a/src/test/test-errno-list.c b/src/test/test-errno-list.c index fb921802794..3bd9ee232ca 100644 --- a/src/test/test-errno-list.c +++ b/src/test/test-errno-list.c @@ -1,9 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "errno-list.h" -#include "errno-to-name.h" #include "tests.h" +#include "errno-to-name.inc" + TEST(errno_list) { ASSERT_NULL(errno_names[0]); ASSERT_NULL(errno_to_name(0)); diff --git a/src/udev/meson.build b/src/udev/meson.build index ccf630919f5..7d994ad5d0c 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -78,8 +78,8 @@ gperf_file = custom_target( command : [generate_keyboard_keys_gperf, '@INPUT@'], capture : true) -fname = 'keyboard-keys-from-name.h' -keyboard_keys_from_name_h = custom_target( +fname = 'keyboard-keys-from-name.inc' +keyboard_keys_from_name_inc = custom_target( fname, input : gperf_file, output : fname, @@ -91,7 +91,7 @@ keyboard_keys_from_name_h = custom_target( '@INPUT@'], capture : true) -generated_sources += keyboard_keys_from_name_h +generated_sources += keyboard_keys_from_name_inc ############################################################ @@ -151,7 +151,7 @@ udev_binaries_dict = [ 'public' : true, 'sources' : udevadm_sources + udevadm_extract_sources + - keyboard_keys_from_name_h, + keyboard_keys_from_name_inc, 'include_directories' : [ libexec_template['include_directories'], include_directories('.', 'net'), diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index a48a5500d14..e30d3cd9763 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -14,7 +14,7 @@ #include "udev-builtin.h" static const struct key_name *keyboard_lookup_key(const char *str, GPERF_LEN_TYPE len); -#include "keyboard-keys-from-name.h" +#include "keyboard-keys-from-name.inc" static int install_force_release(sd_device *dev, const unsigned *release, unsigned release_count) { sd_device *atkbd;