--- /dev/null
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import os
+import sys
+
+
+def main() -> int:
+ build_root = os.environ['MESON_BUILD_ROOT']
+
+ sep = sys.argv.index('--')
+ sources = sys.argv[1:sep]
+ command = sys.argv[sep + 1:]
+
+ db_path = os.path.join(build_root, 'compile_commands.json')
+ try:
+ with open(db_path) as f:
+ db = json.load(f)
+ except FileNotFoundError:
+ db = []
+
+ sources_set = set(sources)
+ db = [entry for entry in db if entry['file'] not in sources_set]
+
+ for source in sources:
+ db.append({
+ 'directory': build_root,
+ 'file': source,
+ 'arguments': [source if a == '@INPUT@' else a for a in command],
+ })
+
+ with open(db_path, 'w') as f:
+ json.dump(db, f, indent=2)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
]
bpf_programs_by_name = {}
+bpf_sources = []
foreach program : bpf_programs
if conf.get(program['condition']) != 1
endif
source = program['source'][0]
+ # Strip .bpf.c extension
name = fs.stem(fs.stem(source))
bpf_o_unstripped = custom_target(
bpf_programs_by_name += { name : skel_h }
generated_sources += skel_h
+ bpf_sources += source
endforeach
+
+if bpf_sources.length() > 0
+ meson.add_postconf_script(
+ python,
+ files('merge-bpf-compdb.py'),
+ bpf_sources,
+ '--',
+ bpf_o_unstripped_cmd)
+endif