Skip to content

Commit 26d6a82

Browse files
Add utils script for type generation (#93)
* Refs #21183: Add type support regeneration script Signed-off-by: eduponz <[email protected]> * Refs #2124: Adjust script Signed-off-by: JesusPoderoso <[email protected]> * Refs #21244: Apply rev suggestions Signed-off-by: JesusPoderoso <[email protected]> --------- Signed-off-by: eduponz <[email protected]> Signed-off-by: JesusPoderoso <[email protected]> Co-authored-by: eduponz <[email protected]>
1 parent e712b3b commit 26d6a82

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
3+
files_to_exclude=(
4+
)
5+
6+
files_not_needing_typeobject=(
7+
'./examples/HelloWorldExampleDS/HelloWorld.idl'
8+
'./resources/static_types/HelloWorld.idl'
9+
)
10+
11+
files_needing_case_sensitive=(
12+
)
13+
14+
files_needing_output_dir=(
15+
)
16+
17+
files_needing_no_typesupport=(
18+
)
19+
20+
red='\E[1;31m'
21+
yellow='\E[1;33m'
22+
textreset='\E[1;0m'
23+
24+
current_dir=$(git rev-parse --show-toplevel)
25+
26+
if [[ ! "$(pwd -P)" -ef "$current_dir" ]]; then
27+
echo -e "${red}This script must be executed in the repository root directory.${textreset}"
28+
exit -1
29+
fi
30+
31+
if [[ -z "$(which fastddsgen)" ]]; then
32+
echo "Cannot find fastddsgen. Please, include it in PATH environment variable"
33+
exit -1
34+
fi
35+
36+
readarray -d '' idl_files < <(find . -iname \*.idl -print0)
37+
38+
for del in ${files_to_exclude[@]}
39+
do
40+
idl_files=("${idl_files[@]/$del}")
41+
done
42+
43+
idl_files=(${idl_files[@]/$files_to_exclude})
44+
45+
ret_value=0
46+
47+
# CDR option check
48+
if [[ $1 == "cdr-v1" ]]; then
49+
cdr_arg="-cdr v1"
50+
elif [[ $1 == "cdr-v2" ]]; then
51+
cdr_arg="-cdr v2"
52+
elif [[ $1 == "cdr-both" ]]; then
53+
cdr_arg="-cdr both"
54+
else
55+
cdr_arg=""
56+
fi
57+
58+
for idl_file in "${idl_files[@]}"; do
59+
idl_dir=$(dirname "$idl_file")
60+
file_from_gen=$(basename "$idl_file")
61+
62+
echo -e "Processing ${yellow}$idl_file${textreset}"
63+
64+
cd "${idl_dir}"
65+
66+
# Detect if needs case sensitive.
67+
[[ ${files_needing_case_sensitive[*]} =~ $idl_file ]] && cs_arg='-cs' || cs_arg=''
68+
69+
# Detect if needs output directories.
70+
not_processed=true
71+
for od_entry in ${files_needing_output_dir[@]}; do
72+
if [[ $od_entry = $idl_file\|* ]]; then
73+
not_processed=false;
74+
od_entry_split=(${od_entry//\|/ })
75+
for od_entry_split_element in ${od_entry_split[@]:1}; do
76+
od_arg="-d ${od_entry_split_element}"
77+
fastddsgen -replace $cdr_arg $cs_arg $od_arg "$file_from_gen"
78+
done
79+
break
80+
fi
81+
done
82+
83+
if $not_processed ; then
84+
fastddsgen -replace $cdr_arg $cs_arg "$file_from_gen"
85+
fi
86+
87+
if [[ $? != 0 ]]; then
88+
ret_value=-1
89+
fi
90+
91+
cd -
92+
done
93+
94+
exit $ret_value

0 commit comments

Comments
 (0)