-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfigure
executable file
·170 lines (143 loc) · 3.79 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
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
#!/bin/bash -e
#
# (C) Copyright 2015, actions Limited
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
unset MENU_CHOICES_ARRAY
notice_info(){
echo -e "\nNOTE:"
echo -e "<1> You'd better run 'make update' before compilation, this will update all subproject."
echo -e "<2> If you need to compile another board type, run 'make clean' first, and then use './configure' to choose board type."
}
add_item(){
local new_item=$1
local c
for c in ${MENU_CHOICES_ARRAY[@]} ; do
if [ "$new_item" = "$c" ] ; then
return
fi
done
MENU_CHOICES_ARRAY=(${MENU_CHOICES_ARRAY[@]} $new_item)
}
build_ic_list() {
unset MENU_CHOICES_ARRAY
if [ -d "owl-actions/s500" ]
then
add_item "s500"
fi
if [ -d "owl-actions/s700" ]
then
add_item "s700"
fi
if [ -d "owl-actions/s900" ]
then
add_item "s900"
fi
}
build_list() {
unset MENU_CHOICES_ARRAY
local file
for file in ` ls -1 owl-actions/$1`
do
if [ -d owl-actions/$1"/"$file ]
then
add_item $file
fi
done
}
print_menu(){
local i=1
local choice
for choice in ${MENU_CHOICES_ARRAY[@]}
do
echo " $i. $choice"
i=$(($i+1))
done
echo
}
read_choice(){
####################################### select ic type
local answer
build_ic_list
if [ ${#MENU_CHOICES_ARRAY[@]} -eq 0 ]
then
echo "error: no ic."
return
elif [ ${#MENU_CHOICES_ARRAY[@]} -eq 1 ]
then
selected_ic=${MENU_CHOICES_ARRAY[0]}
else
echo "Select IC name:"
print_menu
echo -n "Which would you like? [${MENU_CHOICES_ARRAY[0]}] "
read answer
local selected_ic=
if [ -z "$answer" ]
then
selected_ic=${MENU_CHOICES_ARRAY[0]}
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
then
if [ $answer -le ${#MENU_CHOICES_ARRAY[@]} ]
then
selected_ic=${MENU_CHOICES_ARRAY[$(($answer-1))]}
fi
elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
then
selected_ic=$answer
fi
if [ -z "$selected_ic" ]
then
echo
echo "Invalid lunch combo: $answer"
return 1
fi
echo
fi
############################select board type
build_list $selected_ic/boards/$selected_os/
echo "Select board type:"
print_menu
echo -n "Which would you like? [${MENU_CHOICES_ARRAY[0]}] "
read answer
local selected_board=
if [ -z "$answer" ]
then
selected_board=${MENU_CHOICES_ARRAY[0]}
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
then
if [ $answer -le ${#MENU_CHOICES_ARRAY[@]} ]
then
selected_board=${MENU_CHOICES_ARRAY[$(($answer-1))]}
fi
elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
then
selected_board=$answer
fi
if [ -z "$selected_board" ]
then
echo
echo "Invalid lunch combo: $answer"
return 1
fi
##############################################################
cat owl-actions/$selected_ic/boards/$selected_board/config > .config
echo IC_NAME=$selected_ic >> .config
echo BOARD_NAME=$selected_board >> .config
echo "$selected_ic $selected_board configured. Now run \`make\`"
}
if [ ! -f "owl-actions/.git" ]; then
git submodule init
git submodule update owl-actions
fi
if [ $# -eq 2 ] && [ -d "owl-actions/$1" ] && [ -d "owl-actions/$1/boards/$2" ];then
cat $1/boards/$2/config > .config
echo IC_NAME=$1 >> .config
echo BOARD_NAME=$2 >> .config
echo "$1 $2 configured. Now run \`make\`"
else
read_choice
fi
notice_info