forked from tuya/tuyaopen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·123 lines (104 loc) · 4.18 KB
/
configure
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
#!/usr/bin/env bash
ROOT_DIR=`pwd`
CACHE_DIR=$ROOT_DIR/cache
LISTMENU=$ROOT_DIR/tools/listmenu.sh
. $ROOT_DIR/tools/util_tools.sh
########################################
# Check command and version
########################################
show "" "Check command and version ..."
check_command_version "python3" "3.6.0" "python3 --version"
check_command_version "git" "2.0.0" "git --version"
check_command_version "cmake" "3.16.0" "cmake --version"
check_command_version "ccmake" "3.16.0" "ccmake --version"
check_command_version "lcov" "1.14" "lcov --version"
show "${fore[write]};${back[green]}" "[DONE] Check command and version"
show "" ""
########################################
# Choice board
########################################
show "" "Choice board ..."
BOARDS_DIR=$ROOT_DIR/board
BOARD_YAML=$BOARDS_DIR/board_config.yaml
BOARD_NAMES=$(cat $BOARD_YAML | grep -oP '(?<=^- name: ).*(?=$)')
BOARD_NAME=$(echo "$BOARD_NAMES" | bash $LISTMENU "Boards" 20 60 13)
BOARD_INFO=$(cat $BOARD_YAML | grep -A 3 "^- name: $BOARD_NAME\s*$")
BOARD_LOCATER=$(echo "$BOARD_INFO" | grep -oP '(?<=locater: ).*(?=$)')
BOARD_PATH="${BOARDS_DIR}/${BOARD_LOCATER}"
BOARD_REPO=$(echo "$BOARD_INFO" | grep -oP '(?<=repo: ).*(?=$)')
BOARD_COMMIT=$(echo "$BOARD_INFO" | grep -oP '(?<=commit: ).*(?=$)')
assert_non_null "$BOARD_NAME" "Can't find the [board name]."
assert_non_null "$BOARD_LOCATER" "Can't find the [board locater]."
assert_non_null "$BOARD_REPO" "Can't find the [board repo]."
assert_non_null "$BOARD_COMMIT" "Can't find the [board commit]."
BOARD_STR="board: $BOARD_NAME
locater: $BOARD_LOCATER
repo: $BOARD_REPO
commit: $BOARD_COMMIT" # end BOARD_STR
show "" "$BOARD_STR"
show "${fore[write]};${back[green]}" "[DONE] Choice board: $BOARD_NAME"
show "" ""
########################################
# Choice Pre-config
########################################
show "" "Choice Pre-config ..."
PRE_CONFIG_DIR=$ROOT_DIR/pre_config
PRE_CONFIG_NAME=$(ls -p $PRE_CONFIG_DIR | grep -E "^[^/]*\.config$" | bash $LISTMENU "Pre-config" 20 60 13)
assert_non_null "$PRE_CONFIG_NAME" "Have no [pre-config]."
KCONFIG_TOOLS=$ROOT_DIR/tools/kconfiglib
KCONFIG_CATALOG=$CACHE_DIR/CatalogKconfig
python3 $KCONFIG_TOOLS/set_catalog_config.py -b $BOARD_PATH -s $ROOT_DIR/src -o $KCONFIG_CATALOG
show "${fore[write]};${back[green]}" "[DONE] Choice Pre-config: $PRE_CONFIG_NAME"
show "" ""
########################################
# Choice example
########################################
show "" "Choice example ..."
EXAMPLE_DIR=$ROOT_DIR/examples
EXAMPLE_NAME=$(ls $EXAMPLE_DIR | bash $LISTMENU "Examples" 20 60 13)
assert_non_null "$EXAMPLE_NAME" "Have no [example]."
show "${fore[write]};${back[green]}" "[DONE] Choice example: $EXAMPLE_NAME"
show "" ""
########################################
# Generate cmake file
########################################
show "" "Genreate cmake file ..."
CONFIG_CMAKE=$CACHE_DIR/config.cmake
FILE_INFO="
set(BOARD_NAME \"${BOARD_NAME}\")
set(BOARD_PATH \"${BOARD_PATH}\")
set(EXAMPLE_NAME \"${EXAMPLE_NAME}\")
set(EXAMPLE_DIR \"${EXAMPLE_DIR}\")
set(PRE_CONFIG_NAME \"${PRE_CONFIG_NAME}\")
set(PRE_CONFIG_DIR \"${PRE_CONFIG_DIR}\")
set(KCONFIG_CATALOG \"${KCONFIG_CATALOG}\")
" # end FILE_INFO
echo "$FILE_INFO" > $CONFIG_CMAKE
show "${fore[write]};${back[green]}" "[DONE] Genreate cmake file: $CONFIG_CMAKE"
show "" ""
########################################
# Download board
########################################
show "" "Download board ..."
if [ -d "$BOARD_PATH" ]; then
show "" "Skip download, exist [$BOARD_PATH]."
show "${fore[yellow]}" "If you want to download it again, please remove it."
else
git clone "$BOARD_REPO" "$BOARD_PATH"
cd "$BOARD_PATH"; git checkout -q "$BOARD_COMMIT"
fi
if [ -f "$BOARD_PATH/board_prepare.sh" ]; then
show "" "Run [$BOARD_PATH/board_prepare.sh]."
cd "$BOARD_PATH"; sh "board_prepare.sh"
fi
show "${fore[write]};${back[green]}" "[DONE] Download board: $BOARD_PATH"
show "" ""
########################################
# Next prompt
########################################
HELP_STR="If something goes well, So congratulations.
You can execute the following command:
\033[36m[mkdir build; cd build; cmake ..]\033[0m"
show "${fore[green]}" "$HELP_STR"
show "" ""
show "" "DONE."