blob: 9ed334193216546f90c266880534bf48349e8eb9 [file] [log] [blame]
Anthony King0ac8e1a2015-05-01 00:00:37 +01001# bliss functions that extend build/envsetup.sh
xplodwild29ffed22013-08-24 17:40:37 +01002function __print_bliss_functions_help() {
3cat <<EOF
4Additional BlissRoms functions:
5- breakfast: Setup the build environment, but only list
6 devices we support.
7- brunch: Sets up build environment using breakfast(),
8 and then comiles using mka() against bacon target.
9- mka: Builds using SCHED_BATCH on all processors.
xplodwilde1943f22013-08-29 20:18:18 +020010- pushboot: Push a file from your OUT dir to your phone and
11 reboots it, using absolute path.
xplodwild29ffed22013-08-24 17:40:37 +010012EOF
13}
Anthony King0ac8e1a2015-05-01 00:00:37 +010014
15function bliss_device_combos()
16{
17 local T list_file variant device
18
19 T="$(gettop)"
20 list_file="${T}/vendor/bliss/bliss.devices"
21 variant="userdebug"
22
23 if [[ $1 ]]
24 then
25 if [[ $2 ]]
26 then
27 list_file="$1"
28 variant="$2"
29 else
30 if [[ ${VARIANT_CHOICES[@]} =~ (^| )$1($| ) ]]
31 then
32 variant="$1"
33 else
34 list_file="$1"
35 fi
36 fi
37 fi
38
39 if [[ ! -f "${list_file}" ]]
40 then
41 echo "unable to find device list: ${list_file}"
42 list_file="${T}/vendor/bliss/bliss.devices"
43 echo "defaulting device list file to: ${list_file}"
44 fi
45
46 while IFS= read -r device
47 do
48 add_lunch_combo "bliss_${device}-${variant}"
49 done < "${list_file}"
50}
51
52function bliss_rename_function()
53{
54 eval "original_bliss_$(declare -f ${1})"
55}
56
57function _bliss_build_hmm() #hidden
58{
59 printf "%-8s %s" "${1}:" "${2}"
60}
61
62function bliss_append_hmm()
63{
64 HMM_DESCRIPTIVE=("${HMM_DESCRIPTIVE[@]}" "$(_bliss_build_hmm "$1" "$2")")
65}
66
67function bliss_add_hmm_entry()
68{
69 for c in ${!HMM_DESCRIPTIVE[*]}
70 do
71 if [[ "${1}" == $(echo "${HMM_DESCRIPTIVE[$c]}" | cut -f1 -d":") ]]
72 then
73 HMM_DESCRIPTIVE[${c}]="$(_bliss_build_hmm "$1" "$2")"
74 return
75 fi
76 done
77 bliss_append_hmm "$1" "$2"
78}
79
80function blissremote()
81{
82 local proj pfx project
83
84 if ! git rev-parse &> /dev/null
85 then
86 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
87 return
88 fi
89 git remote rm bliss 2> /dev/null
90
91 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
92
93 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
94 pfx="android_"
95 fi
96
97 project="${proj//\//_}"
98
99 git remote add bliss "git@github.com:BlissRoms/$pfx$project"
100 echo "Remote 'bliss' created"
101}
102
103function losremote()
104{
105 local proj pfx project
106
107 if ! git rev-parse &> /dev/null
108 then
109 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
110 return
111 fi
112 git remote rm cm 2> /dev/null
113
114 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
115 pfx="android_"
116 project="${proj//\//_}"
117 git remote add los "git@github.com:LineageOS/$pfx$project"
118 echo "Remote 'los' created"
119}
120
121function aospremote()
122{
123 local pfx project
124
125 if ! git rev-parse &> /dev/null
126 then
127 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
128 return
129 fi
130 git remote rm aosp 2> /dev/null
131
132 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
133 if [[ "$project" != device* ]]
134 then
135 pfx="platform/"
136 fi
137 git remote add aosp "https://android.googlesource.com/$pfx$project"
138 echo "Remote 'aosp' created"
139}
140
141function cafremote()
142{
143 local pfx project
144
145 if ! git rev-parse &> /dev/null
146 then
147 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
148 fi
149 git remote rm caf 2> /dev/null
150
151 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
152 if [[ "$project" != device* ]]
153 then
154 pfx="platform/"
155 fi
156 git remote add caf "git://codeaurora.org/$pfx$project"
157 echo "Remote 'caf' created"
158}
159
160function bliss_push()
161{
162 local branch ssh_name path_opt proj
163 branch="lp5.1"
164 ssh_name="bliss_review"
165 path_opt=
166
167 if [[ "$1" ]]
168 then
169 proj="$ANDROID_BUILD_TOP/$(echo "$1" | sed "s#$ANDROID_BUILD_TOP/##g")"
170 path_opt="--git-dir=$(printf "%q/.git" "${proj}")"
171 else
172 proj="$(pwd -P)"
173 fi
174 proj="$(echo "$proj" | sed "s#$ANDROID_BUILD_TOP/##g")"
175 proj="$(echo "$proj" | sed 's#/$##')"
176 proj="${proj//\//_}"
177
178 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
179 proj="android_$proj"
180 fi
181
182 git $path_opt push "ssh://${ssh_name}/BlissRoms/$proj" "HEAD:refs/for/$branch"
183}
184
185
186bliss_rename_function hmm
187function hmm() #hidden
188{
189 local i T
190 T="$(gettop)"
191 original_bliss_hmm
192 echo
193
194 echo "vendor/bliss extended functions. The complete list is:"
195 for i in $(grep -P '^function .*$' "$T/vendor/bliss/build/envsetup.sh" | grep -v "#hidden" | sed 's/function \([a-z_]*\).*/\1/' | sort | uniq); do
196 echo "$i"
197 done |column
198}
199
xplodwild29ffed22013-08-24 17:40:37 +0100200function brunch()
201{
202 breakfast $*
203 if [ $? -eq 0 ]; then
204 time mka bacon
205 else
206 echo "No such item in brunch menu. Try 'breakfast'"
207 return 1
208 fi
209 return $?
210}
Anthony King0ac8e1a2015-05-01 00:00:37 +0100211
xplodwild29ffed22013-08-24 17:40:37 +0100212function breakfast()
213{
214 target=$1
Archi4f440b02014-02-28 19:18:54 +0100215 local variant=$2
xplodwild29ffed22013-08-24 17:40:37 +0100216 BLISS_DEVICES_ONLY="true"
217 unset LUNCH_MENU_CHOICES
218 add_lunch_combo full-eng
219 for f in `/bin/ls device/*/*/vendorsetup.sh 2> /dev/null`
220 do
221 echo "including $f"
222 . $f
223 done
224 unset f
225
226 if [ $# -eq 0 ]; then
227 # No arguments, so let's have the full menu
228 lunch
229 else
230 echo "z$target" | grep -q "-"
231 if [ $? -eq 0 ]; then
232 # A buildtype was specified, assume a full device name
233 lunch $target
234 else
235 # This is probably just the bliss model name
Archi4f440b02014-02-28 19:18:54 +0100236 if [ -z "$variant" ]; then
237 variant="userdebug"
238 fi
239 lunch bliss_$target-$variant
xplodwild29ffed22013-08-24 17:40:37 +0100240 fi
241 fi
242 return $?
243}
244
245alias bib=breakfast
246
mikeNGbdc1fde2018-05-17 23:17:12 -0400247function repopick() {
248 T=$(gettop)
249 $T/vendor/bliss/build/tools/repopick.py $@
250}
251
Chirayu Desai352b4d82013-06-30 10:04:25 +0530252function fixup_common_out_dir() {
253 common_out_dir=$(get_build_var OUT_DIR)/target/common
254 target_device=$(get_build_var TARGET_DEVICE)
255 if [ ! -z $ANDROID_FIXUP_COMMON_OUT ]; then
256 if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then
257 mv ${common_out_dir} ${common_out_dir}-${target_device}
258 ln -s ${common_out_dir}-${target_device} ${common_out_dir}
259 else
260 [ -L ${common_out_dir} ] && rm ${common_out_dir}
261 mkdir -p ${common_out_dir}-${target_device}
262 ln -s ${common_out_dir}-${target_device} ${common_out_dir}
263 fi
264 else
265 [ -L ${common_out_dir} ] && rm ${common_out_dir}
266 mkdir -p ${common_out_dir}
267 fi
268}
269
xplodwild29ffed22013-08-24 17:40:37 +0100270# Make using all available CPUs
271function mka() {
Luca Stefani6cd5da92017-08-17 20:34:44 +0200272 m -j "$@"
xplodwild29ffed22013-08-24 17:40:37 +0100273}
xplodwilde1943f22013-08-29 20:18:18 +0200274
275function pushboot() {
276 if [ ! -f $OUT/$* ]; then
277 echo "File not found: $OUT/$*"
278 return 1
279 fi
280
281 adb root
282 sleep 1
283 adb wait-for-device
284 adb remount
285
286 adb push $OUT/$* /$*
287 adb reboot
288}