Fix #21375 - Generate .sdb files properly for syscalls with meson ##build

This commit is contained in:
pancake 2023-02-25 11:26:13 +01:00 committed by GitHub
parent ca9763f20d
commit 81d7a23df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 1 deletions

29
libr/syscall/d/gen.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python
# args [sdbpath] [input] [output]
import os
import sys
import subprocess
try:
sdb_exe = sys.argv[1]
_input = sys.argv[2]
_output = sys.argv[3]
_tmpfile = _input + ".tmp"
with open(_input) as lines:
res = ""
for line in lines:
kv = line.rstrip().split("=", 1)
if kv[0] == "_":
res += line
else:
vv = kv[1].split(",")
res += vv[0] + "." + vv[1] + "=" + kv[0] + "\n"
res += line
with open(_tmpfile, "w") as file:
file.write(res)
subprocess.call([sdb_exe, _output, "==", _tmpfile])
except Exception as e:
print(e)
print("Usage: gen.py [sdb_exe] [input] [output]")

View File

@ -35,7 +35,7 @@ foreach file : sdb_files
gen_cmd = sdb_gen_cmd_cgen
else
outfile = '@0@.sdb'.format(file)
gen_cmd = sdb_gen_cmd
gen_cmd = syscall_sdb_gen_cmd
endif
r_syscall_d_sources += custom_target(outfile,

View File

@ -1,6 +1,7 @@
project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.50', version : '5.8.3')
py3_exe = import('python').find_installation('python3')
gen_py = '@0@/libr/syscall/d/gen.py'.format(meson.current_source_dir())
git_exe = find_program('git', required: false)
pkgconfig_mod = import('pkgconfig')
@ -551,6 +552,15 @@ sdb_gen_cmd = [
'@INPUT@'
]
py_cmd = '__import__("os").readlink(r"@0@"))'.format(repo)
syscall_sdb_gen_cmd = [
py3_exe,
gen_py,
sdb_exe,
'@INPUT@',
'@OUTPUT@',
]
# handle spp dependency
spp_files = [
'shlr/spp/spp.c'

View File

@ -21,3 +21,6 @@ git grep 'free ((char' libr | wc -l
printf -- "f(void)\t"
git grep 'free ((void' libr | wc -l
printf -- "aPlugs\t"
ls libr/anal/p/*.c |wc -l