-
Notifications
You must be signed in to change notification settings - Fork 25
/
environment-genavb
165 lines (147 loc) · 3.59 KB
/
environment-genavb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#
# To be sourced in build shell, AFTER toolchain environment
#
#
_make_genavb_complete()
{
COMPREPLY=()
local curr_word="${COMP_WORDS[COMP_CWORD]}"
case $COMP_CWORD in
1)
local first_arg=("freertos_imx8mm_ca53" "freertos_imx8mn_ca53" \
"freertos_imx8mp_ca53" "freertos_rt1052" "freertos_rt1176" \
"freertos_rt1187_cm33" "freertos_rt1187_cm7" "freertos_rt1189_cm33" "freertos_rt1189_cm7" \
"linux_imx6" "linux_imx6ull" "linux_imx8" "linux_ls1028")
if [ $1 = "clean_genavb" ]; then
first_arg+=("all")
fi
COMPREPLY=( $(compgen -W "${first_arg[*]}" $curr_word) )
;;
*)
if [ ${COMP_WORDS[1]} != "all" ]; then
proc_args "${COMP_WORDS[1]}"
COMPREPLY=( $(compgen -W "${CONFIG_ARR[*]}" $curr_word) )
fi
;;
esac
}
complete -F _make_genavb_complete make_genavb
complete -F _make_genavb_complete make_genavb_doc
complete -F _make_genavb_complete make_genavb_doc_test
complete -F _make_genavb_complete clean_genavb
proc_args()
{
TARGET=$1
shift
local config_arr=("$@")
if [ -z "$TARGET" ]; then
TARGET=linux_imx6
fi
if [ ${#config_arr[@]} -eq 0 ]; then
case $TARGET in
"linux_imx6")
CONFIG_ARR=("endpoint_avb")
;;
"linux_imx6ull")
CONFIG_ARR=("endpoint_avb")
;;
"linux_imx8")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn" "endpoint_avb_tsn" "endpoint_avb_tsn_bridge" "hybrid_avb" "endpoint_avb_tsn_hybrid")
;;
"linux_ls1028")
CONFIG_ARR=("bridge")
;;
"freertos_rt1052")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn")
;;
"freertos_rt1176")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn")
;;
"freertos_imx8mm_ca53")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn")
;;
"freertos_imx8mn_ca53")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn")
;;
"freertos_imx8mp_ca53")
CONFIG_ARR=("endpoint_avb" "endpoint_tsn")
;;
"freertos_rt1187_cm33")
CONFIG_ARR=("hybrid_tsn")
;;
"freertos_rt1187_cm7")
CONFIG_ARR=("endpoint_tsn_no_gptp")
;;
"freertos_rt1189_cm33")
CONFIG_ARR=("hybrid_tsn")
;;
"freertos_rt1189_cm7")
CONFIG_ARR=("endpoint_tsn_no_gptp")
;;
*)
echo "unknown target"
return -1
;;
esac
else
CONFIG_ARR=("${config_arr[@]}")
fi
}
# Usage: _make_genavb <make target> [target] [config_list]
_make_genavb()
{
MAKE_TARGET=$1
shift
proc_args $@
local cmake_doc_options
if [ $MAKE_TARGET = "doc_doxygen" ]; then
cmake_doc_options=-DBUILD_DOC=ON
elif [ $MAKE_TARGET = "doc_doxygen_test" ]; then
MAKE_TARGET="doc_doxygen"
cmake_doc_options=-DBUILD_DOC_STRICT=ON
fi
if [ -z "$SDKTARGETSYSROOT" ]; then
CMAKE_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE=./config_armgcc.cmake
fi
for config in "${CONFIG_ARR[@]}"
do
local BUILD_PATH=build/$TARGET/$config
cmake . -B$BUILD_PATH -DCONFIG=$config -DTARGET=$TARGET $cmake_doc_options $CMAKE_TOOLCHAIN || return -1
make -j`nproc` -C $BUILD_PATH $MAKE_TARGET || return -1
done
}
# Usage: make_genavb [target] [config_list]
make_genavb()
{
_make_genavb "install" $@
}
# Usage: make_genavb_doc [target] [config_list]
make_genavb_doc()
{
_make_genavb "doc_doxygen" $@
}
# Usage: make_genavb_doc_test [target] [config_list]
make_genavb_doc_test()
{
_make_genavb "doc_doxygen_test" $@
}
# Usage: clean_genavb [target] [config_list] or clean_genavb all
clean_genavb()
{
if [ $# -eq 0 ] || [ $1 = "all" ]; then
if [ -d ./build ]; then
rm ./common/version.h
rm -r ./build
echo "Deleted $(pwd)/build"
fi
else
proc_args $@
for config in "${CONFIG_ARR[@]}"
do
if [ -d ./build/$TARGET/$config ]; then
rm -r ./build/$TARGET/$config
echo "Deleted $(pwd)/build/$TARGET/$config"
fi
done
fi
}