forked from ZengjfOS/anpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandroiddir.bash.template
276 lines (237 loc) · 7.01 KB
/
androiddir.bash.template
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/bash
##### ANPP CONFIG START #####
# default Workspace dir, all projects are here
export defaultPath=~/zengjf/
# android project
projects=(
M0-project
A00-project
M8-project
L00-project
)
# android product
products=(
M0
k61v1_64_bsp
k62v1_64
s138
)
# android product kernel dir name, relative to project dir
kernels=(
kernel-4.9
kernel-4.9
kernel-4.19
android/kernel/msm-4.14
)
# android product kernel dts dir name
dtss=(
arch/arm64/boot/dts/mediatek/
arch/arm64/boot/dts/mediatek/
arch/arm64/boot/dts/mediatek/
arch/arm64/boot/dts/qcom
)
# android product bootloader stage 1th dir name, relative to project dir
# 1. mtk: preloader
# 2. qcom: xbl
bootloaderStage1s=(
vendor/mediatek/proprietary/bootable/bootloader/preloader
vendor/mediatek/proprietary/bootable/bootloader/preloader
vendor/mediatek/proprietary/bootable/bootloader/preloader
android/fibo/bp_code/boot_images
)
# android product bootloader stage 2th dir name, relative to project dir
# 1. mtk: lk
# 2. qcom: edk2
bootloaderStage2s=(
vendor/mediatek/proprietary/bootable/bootloader/lk
vendor/mediatek/proprietary/bootable/bootloader/lk
vendor/mediatek/proprietary/bootable/bootloader/lk
android/bootable/bootloader/edk2
)
# android product out dir, relative to project dir
outs=(
out/target/product
out/target/product
out/target/product
android/out/target/product
)
# efuse sign dir, relative to project dir
efuses=(
vendor/mediatek/proprietary/scripts/sign-image_v2
vendor/mediatek/proprietary/scripts/sign-image_v2
vendor/mediatek/proprietary/scripts/sign-image_v2
sc13x_download_images_v2/qcm6125-la-2-0/common/sectools
)
##### ANPP CONFIG END #####
##### ANPP CUSTOM START #####
# 1. argv: refer to config.json "project_keys" array order
# ${1}: cmd
# ${2}: defaultPath
# ${3}: project
# ${4}: product
# ${5}: kernel
# ${6}: dts
# ${7}: bootloaderStage1
# ${8}: bootloaderStage2
# ${9}: out
# ${10}: efuse
# 2. return:
# 0: function run success
function project_product_custom() {
return 0
}
##### ANPP CUSTOM END #####
##### ANPP COMPONENT START #####
# for pp command alias
components=(
android
dts
kernel
out
bs2
bs1
efuse
)
##### ANPP COMPONENT END #####
# pp function
function project_product() {
project=
product=
kernel=
currentpath=`pwd`
# jump command
if [ $# -lt 1 ]; then
for i in "${!projects[@]}"
do
echo $i: ${projects[i]} -- ${products[i]} -- ${kernels[i]}
done
echo
cd $defaultPath
elif [ $1 == "workspace" ]; then
cd $defaultPath
else
# jump to project
for i in "${!projects[@]}"
do
project_lowercase=${projects[i]%%-*}
project_lowercase=${project_lowercase,,}
if [ ${1,,} == "${project_lowercase}" ]; then
project=${projects[i]}
product=${products[i]}
cd ${defaultPath}/${projects[i]}
if [ $# -eq 1 ]; then
pwd
return
else
shift
fi
break
fi
done
currentpath=`pwd`
# jump to component
for i in "${!projects[@]}"
do
if [[ ${currentpath} =~ "${projects[i]}" ]]; then
##### ANPP COMMAND START #####
project=${projects[i]}
product=${products[i]}
kernel=${kernels[i]}
dts=${dtss[i]}
bootloaderStage1=${bootloaderStage1s[i]}
bootloaderStage2=${bootloaderStage2s[i]}
out=${outs[i]}
efuse=${efuses[i]}
if [ $1 == "android" ]; then
cd ${defaultPath}/${project}
elif [ $1 == "kernel" ]; then
cd ${defaultPath}/${project}/${kernel}
elif [ $1 == "dts" ]; then
cd ${defaultPath}/${project}/${kernel}/${dts}
elif [ $1 == "bs1" ]; then
cd ${defaultPath}/${project}/${bootloaderStage1}
elif [ $1 == "bs2" ]; then
cd ${defaultPath}/${project}/${bootloaderStage2}
elif [ $1 == "out" ]; then
cd ${defaultPath}/${project}/${out}/${product}
elif [ $1 == "efuse" ]; then
cd ${defaultPath}/${project}/${efuse}
else
project_product_custom $1 ${defaultPath} ${project} ${product} ${kernel} ${dts} ${bootloaderStage1} ${bootloaderStage2} ${out} ${efuse}
returnData=$?
if [ ${returnData} -ne 0 ]; then
echo "error: $1 returned with value: ${returnData}"
return
fi
fi
##### ANPP COMMAND END #####
break
fi
done
if [ "${project}" == "" ]; then
echo "please jump to your android project at first"
cd ${defaultPath}
fi
fi
pwd
}
##### ANPP ALIAS START #####
# command alias
alias anpp="project_product" # just for project_product function alias
alias anppc="project_product_custom" # just for project_product_custom function alias
##### ANPP ALIAS END #####
# component alias
for i in "${!components[@]}"
do
component=${components[i]}
alias ${component}="project_product ${component}"
done
# project_product completion
projectStrings=""
componentStrings=""
function _project_product_completions()
{
# get project string
for i in "${!projects[@]}"
do
project_lowercase=${projects[i]%%-*}
project_lowercase=${project_lowercase,,}
projectStrings="${projectStrings} ${project_lowercase}"
done
# get project component string
for i in "${!components[@]}"
do
component=${components[i]}
componentStrings="${componentStrings} ${component}"
done
# completion
if [ "${#COMP_WORDS[@]}" == "2" ]; then
COMPREPLY=($(compgen -W "${projectStrings}" "${COMP_WORDS[1]}"))
elif [ "${#COMP_WORDS[@]}" == "3" ]; then
COMPREPLY=($(compgen -W "${componentStrings}" "${COMP_WORDS[2]}"))
fi
}
complete -F _project_product_completions anpp
# project completion
componentStrings=""
function _project_completions()
{
# get project component string
for i in "${!components[@]}"
do
component=${components[i]}
componentStrings="${componentStrings} ${component}"
done
# completion
if [ "${#COMP_WORDS[@]}" == "2" ]; then
COMPREPLY=($(compgen -W "${componentStrings}" "${COMP_WORDS[1]}"))
fi
}
# project alias and completion
for i in "${!projects[@]}"
do
project_lowercase=${projects[i]%%-*}
project_lowercase=${project_lowercase,,}
alias ${project_lowercase}="project_product ${project_lowercase}"
complete -F _project_completions ${project_lowercase}
done