- uses: systemd/mkosi@184472f0f1f831ca29953546ec01fd941ff763a6
- name: Check that tabs are not used in Python code
- run: sh -c '! git grep -P "\\t" -- src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py'
+ run: sh -c '! git grep -P "\\t" -- src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py'
- name: Build tools tree
run: |
- name: Run mypy
run: |
mkosi box -- mypy --version
- mkosi box -- mypy src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
+ mkosi box -- mypy src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
- name: Run ruff check
run: |
mkosi box -- ruff --version
- mkosi box -- ruff check src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
+ mkosi box -- ruff check src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
- name: Run ruff format
run: |
mkosi box -- ruff --version
- if ! mkosi box -- ruff format --check src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
+ if ! mkosi box -- ruff format --check src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
then
echo "Please run 'ruff format' on the above files or apply the diffs below manually"
- mkosi box -- ruff format --check --quiet --diff src/basic/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
+ mkosi box -- ruff format --check --quiet --diff src/core/generate-bpf-delegate-configs.py src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
fi
- name: Configure meson
'--stringparam', 'man.copyright.section.enabled', '0',
'--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
'--path',
- '@0@:@1@:@2@'.format(meson.current_build_dir(),
+ '@0@:@1@:@2@:@3@'.format(meson.current_build_dir(),
meson.current_source_dir(),
- libshared_build_dir)]
+ libshared_build_dir,
+ libcore_build_dir)]
custom_man_xsl = files('custom-man.xsl')
custom_html_xsl = files('custom-html.xsl')
man_page_depends += custom_entities_ent
-generate_bpf_delegate_configs = find_program('../src/basic/generate-bpf-delegate-configs.py')
-
-bpf_delegate_xml = custom_target(
- input : files('../src/include/uapi/linux/bpf.h'),
- output : 'bpf-delegate.xml',
- command : [generate_bpf_delegate_configs,
- 'doc',
- '@INPUT@'],
- capture : true)
-man_page_depends += bpf_delegate_xml
-
man_pages = []
html_pages = []
source_xml_files = []
# A list of boot stubs. Required for testing of ukify.
boot_stubs = []
+# This is similar to system_includes below, but for passing custom_target().
+system_include_args = [
+ '-isystem', meson.project_build_root() / 'src/include/override',
+ '-isystem', meson.project_source_root() / 'src/include/override',
+ '-isystem', meson.project_build_root() / 'src/include/uapi',
+ '-isystem', meson.project_source_root() / 'src/include/uapi',
+]
+
system_includes = [
include_directories(
# gcc(1) says
subdir('po')
subdir('catalog')
+subdir('src/include')
subdir('src/fundamental')
subdir('src/basic')
subdir('src/libsystemd')
set -eu
set -o pipefail
-${1:?} -E -dM -include sys/socket.h -include "${2:?}" - </dev/null | \
+CC=${1:?}
+shift
+
+$CC -E -dM -include sys/socket.h "$@" - </dev/null | \
grep -Ev 'AF_UNSPEC|AF_MAX' | \
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
set -eu
set -o pipefail
-${1:?} -dM -include "${2:?}" - </dev/null | \
+CC=${1:?}
+shift
+
+$CC -dM -include linux/if_arp.h "$@" - </dev/null | \
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/ARPHRD_//'
set -eu
set -o pipefail
-${1:?} -dM -include "${2:?}" - </dev/null | \
+CC=${1:?}
+shift
+
+$CC -dM -include linux/capability.h "$@" - </dev/null | \
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
grep -v CAP_LAST_CAP
# In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and EREFUSED are defined as aliases of
# ECANCELED and ECONNREFUSED, respectively. Let's drop them.
-${1:?} -dM -include errno.h - </dev/null | \
+CC=${1:?}
+shift
+
+$CC -dM -include errno.h "$@" - </dev/null | \
grep -Ev '^#define[[:space:]]+(ECANCELLED|EREFUSED)' | \
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
missing_syscall_def_h = files('missing_syscall_def.h')
basic_sources += missing_syscall_def_h
-generate_af_list = find_program('generate-af-list.sh')
-af_list_txt = custom_target(
- output : 'af-list.txt',
- command : [generate_af_list, cpp, files('../include/override/sys/socket.h')],
- capture : true)
-
-generate_arphrd_list = find_program('generate-arphrd-list.sh')
-arphrd_list_txt = custom_target(
- output : 'arphrd-list.txt',
- command : [generate_arphrd_list, cpp, files('../include/uapi/linux/if_arp.h')],
- capture : true)
-
-generate_cap_list = find_program('generate-cap-list.sh')
-cap_list_txt = custom_target(
- output : 'cap-list.txt',
- command : [generate_cap_list, cpp, files('../include/uapi/linux/capability.h')],
- capture : true)
-
-generate_errno_list = find_program('generate-errno-list.sh')
-errno_list_txt = custom_target(
- output : 'errno-list.txt',
- command : [generate_errno_list, cpp],
- capture : true)
-
generated_gperf_headers = []
-foreach item : [['af', af_list_txt, 'af', '', ['<sys/socket.h>']],
- ['arphrd', arphrd_list_txt, 'arphrd', 'ARPHRD_', []],
- ['cap', cap_list_txt, 'capability', '', []],
- ['errno', errno_list_txt, 'errno', '', []]]
+foreach item : [
+ # name, source, struct name, prefix, headers
+ ['af', af_sources, 'af', '', ['<sys/socket.h>'], ],
+ ['arphrd', arphrd_sources, 'arphrd', 'ARPHRD_', ['<linux/if_arp.h>'], ],
+ ['cap', cap_sources, 'capability', '', ['<linux/capability.h>'], ],
+ ['errno', [], 'errno', '', ['<errno.h>'], ],
+]
+
+ fname = '@0@-list.txt'.format(item[0])
+ generate_list = files('generate-@0@-list.sh'.format(item[0]))
+ list_txt = custom_target(
+ input : [generate_list, item[1]],
+ output : fname,
+ command : [env, 'bash', generate_list, cpp, system_include_args],
+ capture : true)
fname = '@0@-from-name.gperf'.format(item[0])
gperf_file = custom_target(
- input : item[1],
+ input : list_txt,
output : fname,
command : [generate_gperfs, item[2], item[3], '@INPUT@'] + item[4],
capture : true)
fname = '@0@-to-name.inc'.format(item[0])
awkscript = '@0@-to-name.awk'.format(item[0])
target2 = custom_target(
- input : [awkscript, item[1]],
+ input : [awkscript, list_txt],
output : fname,
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
'@INPUT@'],
capture : true)
-generate_bpf_delegate_configs = find_program('generate-bpf-delegate-configs.py')
-bpf_delegate_configs_inc = custom_target(
- input : files('../include/uapi/linux/bpf.h'),
- output : 'bpf-delegate-configs.inc',
- command : [generate_bpf_delegate_configs,
- 'code',
- '@INPUT@'],
- capture : true)
-
-generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h, bpf_delegate_configs_inc]
-basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h, bpf_delegate_configs_inc]
+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',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
-generated_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c]
+generate_bpf_delegate_configs = files('generate-bpf-delegate-configs.py')
+bpf_delegate_configs_inc = custom_target(
+ input : [generate_bpf_delegate_configs, bpf_delegate_sources],
+ output : 'bpf-delegate-configs.inc',
+ command : [python,
+ generate_bpf_delegate_configs,
+ 'code',
+ bpf_delegate_sources],
+ capture : true)
+
+bpf_delegate_xml = custom_target(
+ input : [generate_bpf_delegate_configs, bpf_delegate_sources],
+ output : 'bpf-delegate.xml',
+ command : [python,
+ generate_bpf_delegate_configs,
+ 'doc',
+ bpf_delegate_sources],
+ capture : true)
+man_page_depends += bpf_delegate_xml
+generated_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
+libcore_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
+libcore_build_dir = meson.current_build_dir()
libcore_name = 'systemd-core-@0@'.format(shared_lib_tag)
libcore_static = static_library(
libcore_name,
libcore_sources,
- load_fragment_gperf_c,
- load_fragment_gperf_nulstr_c,
include_directories : [includes, include_directories('.')],
implicit_include_directories : false,
c_args : ['-fvisibility=default'],
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+# Source files that provides AF_XYZ
+af_sources = files(
+ 'override/sys/socket.h',
+)
+
+# Source files that provides ARPHRD_XYZ
+arphrd_sources = files(
+ 'uapi/linux/if_arp.h',
+)
+
+# Source files that provides CAP_XYZ
+cap_sources = files(
+ 'uapi/linux/capability.h',
+)
+
+# Source files that provides BPF delegate options
+bpf_delegate_sources = files(
+ 'uapi/linux/bpf.h',
+)
+
+# Source files that provides ETHTOOL_LINK_MODE_XYZ
+ethtool_link_mode_sources = files(
+ 'uapi/linux/ethtool.h',
+)
+
+# Source files that provides IPPROTO_XYZ
+ipproto_sources = files(
+ 'override/netinet/in.h',
+ 'uapi/linux/in.h',
+)
+
+# Source files that provides KEY_XYZ
+keyboard_sources = files(
+ 'uapi/linux/input.h',
+ 'uapi/linux/input-event-codes.h',
+)
set -eu
set -o pipefail
-cpp="${1:?}"
+CC="${1:?}"
shift
-includes=()
-for i in "$@"; do
- includes+=(-include "$i")
-done
+HEADER="${1:?}"
+shift
-$cpp -dM "${includes[@]}" - </dev/null | \
+$CC -dM -include "$HEADER" "$@" - </dev/null | \
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
sort -k2
# the custom_target() has to be defined here in src/libsystemd/sd-journal
# in the source directory.
-generate_audit_type_list = find_program('generate-audit_type-list.sh')
+generate_audit_type_list = files('generate-audit_type-list.sh')
audit_type_list_txt = custom_target(
+ input : [generate_audit_type_list, missing_audit_h],
output : 'audit_type-list.txt',
- command : [generate_audit_type_list, cpp, missing_audit_h],
+ command : [env, 'bash', generate_audit_type_list, cpp, missing_audit_h, system_include_args],
capture : true)
audit_type_to_name = custom_target(
'autoneg' : 'autonegotiation',
}
-mode, cpp, header = sys.argv[1:]
+mode = sys.argv[1]
+cpp = sys.argv[2]
+include_dirs = sys.argv[3:]
xml = mode == '--xml'
-command = [*shlex.split(cpp), '-include', header, '-']
+command = [*shlex.split(cpp), '-include', 'linux/ethtool.h'] + include_dirs + ['-']
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, universal_newlines=True)
lines = iter(out.splitlines())
set -eu
set -o pipefail
-${1:?} -dM -include netinet/in.h - </dev/null | \
+CC=${1:?}
+shift
+
+$CC -dM -include netinet/in.h "$@" - </dev/null | \
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/IPPROTO_//'
shared_sources += files('pam-util.c')
endif
-generate_ip_protocol_list = find_program('generate-ip-protocol-list.sh')
+generate_ip_protocol_list = files('generate-ip-protocol-list.sh')
ip_protocol_list_txt = custom_target(
+ input : [generate_ip_protocol_list, ipproto_sources],
output : 'ip-protocol-list.txt',
- command : [generate_ip_protocol_list, cpp],
+ command : [env, 'bash', generate_ip_protocol_list, cpp, system_include_args],
capture : true)
fname = 'ip-protocol-from-name.gperf'
generated_sources += [target1, target2]
shared_sources += [target1, target2]
+ethtool_link_mode_py = files('ethtool-link-mode.py')
fname = 'ethtool-link-mode.inc'
ethtool_link_mode_inc = custom_target(
- input : ['ethtool-link-mode.py', '../include/uapi/linux/ethtool.h'],
+ input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
- command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'],
+ command : [python, ethtool_link_mode_py, '--header', cpp, system_include_args],
capture : true)
generated_sources += ethtool_link_mode_inc
fname = 'ethtool-link-mode.xml'
ethtool_link_mode_xml = custom_target(
- input : ['ethtool-link-mode.py', '../include/uapi/linux/ethtool.h'],
+ input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
- command : [python, '@INPUT0@', '--xml', cpp, '@INPUT1@'],
+ command : [python, ethtool_link_mode_py, '--xml', cpp, system_include_args],
capture : true)
man_page_depends += ethtool_link_mode_xml
#if __GNUC__ >= 15\n\
_Pragma(\"GCC diagnostic ignored \\\"-Wzero-as-null-pointer-constant\\\"\")\n\
#endif\n\
+#include <linux/input.h>\n\
%}"
print "struct key_name { const char* name; unsigned short id; };"
print "%null-strings"
set -eu
set -o pipefail
-${1:?} -dM -include "${2:?}" - </dev/null | awk '
+CC=${1:?}
+shift
+
+$CC -dM -include linux/input.h "$@" - </dev/null | awk '
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
'
############################################################
-generate_keyboard_keys_list = find_program('generate-keyboard-keys-list.sh')
+generate_keyboard_keys_list = files('generate-keyboard-keys-list.sh')
keyboard_keys_list_txt = custom_target(
- input : files('../include/uapi/linux/input.h'),
+ input : [generate_keyboard_keys_list, keyboard_sources],
output : 'keyboard-keys-list.txt',
- command : [generate_keyboard_keys_list, cpp, '@INPUT@'],
+ command : [env, 'bash', generate_keyboard_keys_list, cpp, system_include_args],
capture : true)
-generate_keyboard_keys_gperf = find_program('generate-keyboard-keys-gperf.sh')
+generate_keyboard_keys_gperf = files('generate-keyboard-keys-gperf.sh')
fname = 'keyboard-keys-from-name.gperf'
gperf_file = custom_target(
- input : keyboard_keys_list_txt,
+ input : [generate_keyboard_keys_gperf, keyboard_keys_list_txt],
output : fname,
- command : [generate_keyboard_keys_gperf, '@INPUT@'],
+ command : [env, 'bash', '@INPUT@'],
capture : true)
fname = 'keyboard-keys-from-name.inc'
if 'ethtool-link-mode' in url:
return self.resolve_filename('src/shared/ethtool-link-mode.xml', context)
if 'bpf-delegate' in url:
- return self.resolve_filename('man/bpf-delegate.xml', context)
+ return self.resolve_filename('src/core/bpf-delegate.xml', context)
return None