-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenuconfig.sh
executable file
·223 lines (182 loc) · 5.25 KB
/
menuconfig.sh
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
usage ()
{
echo "menuconfig.sh [options]"
echo " -x [config file path name]"
exit 1
}
while getopts "x:" opt
do
case $opt in
x)
wamr_config_cmake_file=$OPTARG
;;
?)
echo "Unknown arg: $arg"
usage
exit 1
;;
esac
done
if [ -z $wamr_config_cmake_file ]; then
usage
exit
fi
function set_build_target () {
target=$1
if [[ "${target}" = "X86_64" ]]; then
echo -e "set (WAMR_BUILD_TARGET \"X86_64\")" >> ${wamr_config_cmake_file}
elif [[ "${target}" = "X86_32" ]]; then
echo -e "set (WAMR_BUILD_TARGET \"X86_32\")" >> ${wamr_config_cmake_file}
else
echo "unknown build target."
exit 1
fi
}
function set_build_platform () {
platform=$1
if [[ "${platform}" = "linux" ]]; then
echo -e "set (WAMR_BUILD_PLATFORM \"linux\")" >> ${wamr_config_cmake_file}
# TODO: add other platforms
else
echo "${platform} platform currently not supported"
exit 1
fi
}
# input: array of selected exec modes [aot jit interp]
function set_exec_mode () {
modes=($1)
for mode in ${modes[@]}
do
if [[ "$mode" = "aot" ]]; then
echo "set (WAMR_BUILD_AOT 1)" >> ${wamr_config_cmake_file}
elif [[ "$mode" = "jit" ]]; then
echo "set (WAMR_BUILD_JIT 1)" >> ${wamr_config_cmake_file}
BUILD_LLVM="TRUE"
elif [[ "$mode" = "interp" ]]; then
echo "set (WAMR_BUILD_INTERP 1)" >> ${wamr_config_cmake_file}
else
echo "unknown execute mode."
exit 1
fi
done
}
function set_libc_support () {
libc=$1
if [ "$libc" = "WASI" ]; then
echo "set (WAMR_BUILD_LIBC_WASI 1)" >> ${wamr_config_cmake_file}
else
echo "set (WAMR_BUILD_LIBC_BUILTIN 1)" >> ${wamr_config_cmake_file}
fi
}
function set_app_framework () {
app_support=$1
if [ "$app_support" = "TRUE" ]; then
echo "set (WAMR_BUILD_APP_FRAMEWORK 1)" >> ${wamr_config_cmake_file}
fi
}
# input: array of selected app modules
function set_app_module () {
modules=($1)
for module in ${modules[*]}
do
if [ "${module}" = "all" ]; then
cmake_app_list="WAMR_APP_BUILD_ALL"
break
fi
cmake_app_list="${cmake_app_list} WAMR_APP_BUILD_${module^^}"
done
# APP module list
if [ -n "${cmake_app_list}" ]; then
echo "set (WAMR_BUILD_APP_LIST ${cmake_app_list# })" >> ${wamr_config_cmake_file}
fi
}
sdk_root=$(cd "$(dirname "$0")/" && pwd)
wamr_root=${sdk_root}/..
if [ ! `command -v menuconfig` ]; then
echo "Can't find kconfiglib python lib on this computer"
echo "Downloading it through pip"
echo "If this fails, you can try `pip install kconfiglib` to install it manually"
echo "Or download the repo from https://github.com/ulfalizer/Kconfiglib"
pip install kconfiglib
fi
if [ -f ".wamr_modules" ]; then
rm -f .wamr_modules
fi
# get all modules under core/app-framework
for module in `ls ${wamr_root}/core/app-framework -F | grep "/$" | grep -v "base" | grep -v "app-native-shared" | grep -v "template"`
do
module=${module%*/}
echo "config APP_BUILD_${module^^}" >> .wamr_modules
echo " bool \"enable ${module}\"" >> .wamr_modules
done
menuconfig Kconfig
[ $? -eq 0 ] || exit $?
if [ ! -e ".config" ]; then
exit 0
fi
# parse platform
platform=`cat .config | grep "^CONFIG_PLATFORM"`
platform=${platform%*=y}
platform=${platform,,}
platform=${platform#config_platform_}
# parse target
target=`cat .config | grep "^CONFIG_TARGET"`
target=${target%*=y}
target=${target#CONFIG_TARGET_}
# parse execution mode
modes=`cat .config | grep "^CONFIG_EXEC"`
mode_list=""
for mode in ${modes}
do
mode=${mode%*=y}
mode=${mode#CONFIG_EXEC_}
mode_list="${mode_list} ${mode,,}"
done
if [ -z "${mode_list}" ]; then
echo "execution mode are not selected"
exit 1
fi
# parse libc support
libc=`cat .config | grep "^CONFIG_LIBC"`
libc=${libc%*=y}
if [ "${libc}" = "CONFIG_LIBC_WASI" ]; then
libc_support="WASI"
else
libc_support="BUILTIN"
fi
# parse application framework options
app_option=`cat .config | grep "^CONFIG_APP_FRAMEWORK"`
app_option=${app_option%*=y}
app_option=${app_option#CONFIG_APP_FRAMEWORK_}
if [ "${app_option}" != "DISABLE" ]; then
app_enable="TRUE"
# Default components
if [ "${app_option}" = "DEFAULT" ]; then
app_list="base connection sensor"
# All components
elif [ "${app_option}" = "ALL" ]; then
app_list="all"
# Customize
elif [ "${app_option}" = "CUSTOM" ]; then
app_option=`cat .config | grep "^CONFIG_APP_BUILD"`
app_list="base"
for app in ${app_option}
do
app=${app%*=y}
app=${app#CONFIG_APP_BUILD_}
app_list="${app_list} ${app,,}"
done
fi
fi
if [[ -f $wamr_config_cmake_file ]]; then
rm $wamr_config_cmake_file
fi
set_build_target ${target}
set_build_platform ${platform}
set_exec_mode "${mode_list[*]}"
set_libc_support ${libc_support}
set_app_module "${app_list[*]}"
set_app_framework ${app_enable}