fix(build): Impove yaml generator libclang compatibility (from PR#2631) (#3402)

This commit is contained in:
philmoz
2023-03-26 19:06:15 +10:00
committed by GitHub
parent 4f5061438f
commit 044344f18f
2 changed files with 20 additions and 11 deletions
+15 -6
View File
@@ -267,8 +267,8 @@ def parse_union(ast, node):
return old_st
for c in node.get_children():
parse_field(st,c)
if c.kind == CursorKind.FIELD_DECL:
parse_field(st,c)
ann = get_annotations(node)
if len(ann) > 0:
@@ -383,10 +383,11 @@ def parse_field(ast,node):
ann = get_annotations(node)
if len(ann) > 0:
is_cust = False
is_enum = False
for a in ann:
if a['type'] == 'enum':
if not hasattr(f,'f_read'):
f.type = 'enum'
is_enum = True
enum_name = 'enum_' + a['val']
f.var_type = enum_name
if not RootAST.has_enum(enum_name):
@@ -397,8 +398,10 @@ def parse_field(ast,node):
f.name = a['val']
elif a['type'] == 'read':
f.f_read = a['val']
is_cust = True
elif a['type'] == 'write':
f.f_write = a['val']
is_cust = True
elif a['type'] == 'array':
array_attrs = a['val'].split('|')
elmt_size = int(array_attrs[0])
@@ -409,8 +412,13 @@ def parse_field(ast,node):
elif a['type'] == 'skip':
f.skip = True
if is_enum and not is_cust:
f.type = 'enum'
if len(f.name) == 0:
print_error("in '{}', field of type '{}' does not have a name".format(ast.name,f.var_type))
print_error("in '{}', field of type '{}' does not have a name"
.format(ast.name,f.var_type))
return
ast.append(f)
@@ -487,7 +495,8 @@ CLANG_LIB_LOCATIONS = [
'/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib',
'/Library/Developer/CommandLineTools/usr/lib/libclang.dylib',
'/usr/lib/x86_64-linux-gnu/libclang-6.0.so.1'
'/usr/lib/x86_64-linux-gnu/libclang-6.0.so.1',
'/usr/lib/aarch64-linux-gnu/libclang-6.0.so.1'
]
# set clang lib file
+5 -5
View File
@@ -1,8 +1,7 @@
#!/bin/bash
# Stops on first error, echo on
# Stops on first error
set -e
set -x
# Add GCC_ARM to PATH
if [[ -n ${GCC_ARM} ]] ; then
@@ -12,7 +11,7 @@ fi
: ${FLAVOR:="t12;t8;tlite;tpro;lr3pro;tx12;tx12mk2;boxer;zorro;tx16s;x12s;nv14;x7;x9d;x9dp;x9e;x9lite;x9lites;xlite;xlites"}
: ${SRCDIR:=$(dirname "$(pwd)/$0")/..}
: ${COMMON_OPTIONS:="-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_RULE_MESSAGES=OFF -Wno-dev -DYAML_STORAGE=YES "}
: ${COMMON_OPTIONS:="-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_RULE_MESSAGES=OFF -Wno-dev -DDISABLE_COMPANION=YES -DCMAKE_MESSAGE_LOG_LEVEL=WARNING"}
# wipe build directory clean
rm -rf build && mkdir -p build && cd build
@@ -22,6 +21,7 @@ target_names=$(echo "$FLAVOR" | tr '[:upper:]' '[:lower:]' | tr ';' '\n')
for target_name in $target_names
do
BUILD_OPTIONS=${COMMON_OPTIONS}
BUILD_OPTIONS+=" $EXTRA_OPTIONS "
echo "Generating YAML structures for ${target_name}"
case $target_name in
@@ -110,8 +110,8 @@ do
esac
cmake ${BUILD_OPTIONS} "${SRCDIR}"
make arm-none-eabi-configure
make -C arm-none-eabi yaml_data
make native-configure
make -C native yaml_data
rm -f CMakeCache.txt arm-none-eabi/CMakeCache.txt
done