blob: 5afd8c108481aeb57944e37f25257f96ef5ceb0f [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.
10EOF
11}
Anthony King0ac8e1a2015-05-01 00:00:37 +010012
13function bliss_device_combos()
14{
15 local T list_file variant device
16
17 T="$(gettop)"
18 list_file="${T}/vendor/bliss/bliss.devices"
19 variant="userdebug"
20
21 if [[ $1 ]]
22 then
23 if [[ $2 ]]
24 then
25 list_file="$1"
26 variant="$2"
27 else
28 if [[ ${VARIANT_CHOICES[@]} =~ (^| )$1($| ) ]]
29 then
30 variant="$1"
31 else
32 list_file="$1"
33 fi
34 fi
35 fi
36
37 if [[ ! -f "${list_file}" ]]
38 then
39 echo "unable to find device list: ${list_file}"
40 list_file="${T}/vendor/bliss/bliss.devices"
41 echo "defaulting device list file to: ${list_file}"
42 fi
43
44 while IFS= read -r device
45 do
46 add_lunch_combo "bliss_${device}-${variant}"
47 done < "${list_file}"
48}
49
50function bliss_rename_function()
51{
52 eval "original_bliss_$(declare -f ${1})"
53}
54
55function _bliss_build_hmm() #hidden
56{
57 printf "%-8s %s" "${1}:" "${2}"
58}
59
60function bliss_append_hmm()
61{
62 HMM_DESCRIPTIVE=("${HMM_DESCRIPTIVE[@]}" "$(_bliss_build_hmm "$1" "$2")")
63}
64
65function bliss_add_hmm_entry()
66{
67 for c in ${!HMM_DESCRIPTIVE[*]}
68 do
69 if [[ "${1}" == $(echo "${HMM_DESCRIPTIVE[$c]}" | cut -f1 -d":") ]]
70 then
71 HMM_DESCRIPTIVE[${c}]="$(_bliss_build_hmm "$1" "$2")"
72 return
73 fi
74 done
75 bliss_append_hmm "$1" "$2"
76}
77
78function blissremote()
79{
80 local proj pfx project
81
82 if ! git rev-parse &> /dev/null
83 then
84 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
85 return
86 fi
87 git remote rm bliss 2> /dev/null
88
89 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
90
91 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
92 pfx="android_"
93 fi
94
95 project="${proj//\//_}"
96
97 git remote add bliss "git@github.com:BlissRoms/$pfx$project"
98 echo "Remote 'bliss' created"
99}
100
101function losremote()
102{
103 local proj pfx project
104
105 if ! git rev-parse &> /dev/null
106 then
107 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
108 return
109 fi
110 git remote rm cm 2> /dev/null
111
112 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
113 pfx="android_"
114 project="${proj//\//_}"
115 git remote add los "git@github.com:LineageOS/$pfx$project"
116 echo "Remote 'los' created"
117}
118
119function aospremote()
120{
121 local pfx project
122
123 if ! git rev-parse &> /dev/null
124 then
125 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
126 return
127 fi
128 git remote rm aosp 2> /dev/null
129
130 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
131 if [[ "$project" != device* ]]
132 then
133 pfx="platform/"
134 fi
135 git remote add aosp "https://android.googlesource.com/$pfx$project"
136 echo "Remote 'aosp' created"
137}
138
139function cafremote()
140{
141 local pfx project
142
143 if ! git rev-parse &> /dev/null
144 then
145 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
146 fi
147 git remote rm caf 2> /dev/null
148
149 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
150 if [[ "$project" != device* ]]
151 then
152 pfx="platform/"
153 fi
154 git remote add caf "git://codeaurora.org/$pfx$project"
155 echo "Remote 'caf' created"
156}
157
158function bliss_push()
159{
160 local branch ssh_name path_opt proj
161 branch="lp5.1"
162 ssh_name="bliss_review"
163 path_opt=
164
165 if [[ "$1" ]]
166 then
167 proj="$ANDROID_BUILD_TOP/$(echo "$1" | sed "s#$ANDROID_BUILD_TOP/##g")"
168 path_opt="--git-dir=$(printf "%q/.git" "${proj}")"
169 else
170 proj="$(pwd -P)"
171 fi
172 proj="$(echo "$proj" | sed "s#$ANDROID_BUILD_TOP/##g")"
173 proj="$(echo "$proj" | sed 's#/$##')"
174 proj="${proj//\//_}"
175
176 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
177 proj="android_$proj"
178 fi
179
180 git $path_opt push "ssh://${ssh_name}/BlissRoms/$proj" "HEAD:refs/for/$branch"
181}
182
183
184bliss_rename_function hmm
185function hmm() #hidden
186{
187 local i T
188 T="$(gettop)"
189 original_bliss_hmm
190 echo
191
192 echo "vendor/bliss extended functions. The complete list is:"
193 for i in $(grep -P '^function .*$' "$T/vendor/bliss/build/envsetup.sh" | grep -v "#hidden" | sed 's/function \([a-z_]*\).*/\1/' | sort | uniq); do
194 echo "$i"
195 done |column
196}
197
xplodwild29ffed22013-08-24 17:40:37 +0100198function brunch()
199{
200 breakfast $*
201 if [ $? -eq 0 ]; then
202 time mka bacon
203 else
204 echo "No such item in brunch menu. Try 'breakfast'"
205 return 1
206 fi
207 return $?
208}
Anthony King0ac8e1a2015-05-01 00:00:37 +0100209
xplodwild29ffed22013-08-24 17:40:37 +0100210function breakfast()
211{
212 target=$1
213 BLISS_DEVICES_ONLY="true"
214 unset LUNCH_MENU_CHOICES
215 add_lunch_combo full-eng
216 for f in `/bin/ls device/*/*/vendorsetup.sh 2> /dev/null`
217 do
218 echo "including $f"
219 . $f
220 done
221 unset f
222
223 if [ $# -eq 0 ]; then
224 # No arguments, so let's have the full menu
225 lunch
226 else
227 echo "z$target" | grep -q "-"
228 if [ $? -eq 0 ]; then
229 # A buildtype was specified, assume a full device name
230 lunch $target
231 else
232 # This is probably just the bliss model name
233 lunch bliss_$target-userdebug
234 fi
235 fi
236 return $?
237}
238
239alias bib=breakfast
240
241# Make using all available CPUs
242function mka() {
243 case `uname -s` in
244 Darwin)
245 make -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
246 ;;
247 *)
248 schedtool -B -n 1 -e ionice -n 1 make -j `cat /proc/cpuinfo | grep "^processor" | wc -l` "$@"
249 ;;
250 esac
251}