blob: d424a6807d6d77a17cc3fb746ff5abc48814a6b9 [file] [log] [blame]
Anthony King0ac8e1a2015-05-01 00:00:37 +01001# bliss functions that extend build/envsetup.sh
2
3function bliss_device_combos()
4{
5 local T list_file variant device
6
7 T="$(gettop)"
8 list_file="${T}/vendor/bliss/bliss.devices"
9 variant="userdebug"
10
11 if [[ $1 ]]
12 then
13 if [[ $2 ]]
14 then
15 list_file="$1"
16 variant="$2"
17 else
18 if [[ ${VARIANT_CHOICES[@]} =~ (^| )$1($| ) ]]
19 then
20 variant="$1"
21 else
22 list_file="$1"
23 fi
24 fi
25 fi
26
27 if [[ ! -f "${list_file}" ]]
28 then
29 echo "unable to find device list: ${list_file}"
30 list_file="${T}/vendor/bliss/bliss.devices"
31 echo "defaulting device list file to: ${list_file}"
32 fi
33
34 while IFS= read -r device
35 do
36 add_lunch_combo "bliss_${device}-${variant}"
37 done < "${list_file}"
38}
39
40function bliss_rename_function()
41{
42 eval "original_bliss_$(declare -f ${1})"
43}
44
45function _bliss_build_hmm() #hidden
46{
47 printf "%-8s %s" "${1}:" "${2}"
48}
49
50function bliss_append_hmm()
51{
52 HMM_DESCRIPTIVE=("${HMM_DESCRIPTIVE[@]}" "$(_bliss_build_hmm "$1" "$2")")
53}
54
55function bliss_add_hmm_entry()
56{
57 for c in ${!HMM_DESCRIPTIVE[*]}
58 do
59 if [[ "${1}" == $(echo "${HMM_DESCRIPTIVE[$c]}" | cut -f1 -d":") ]]
60 then
61 HMM_DESCRIPTIVE[${c}]="$(_bliss_build_hmm "$1" "$2")"
62 return
63 fi
64 done
65 bliss_append_hmm "$1" "$2"
66}
67
68function blissremote()
69{
70 local proj pfx project
71
72 if ! git rev-parse &> /dev/null
73 then
74 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
75 return
76 fi
77 git remote rm bliss 2> /dev/null
78
79 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
80
81 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
82 pfx="android_"
83 fi
84
85 project="${proj//\//_}"
86
87 git remote add bliss "git@github.com:BlissRoms/$pfx$project"
88 echo "Remote 'bliss' created"
89}
90
91function losremote()
92{
93 local proj pfx project
94
95 if ! git rev-parse &> /dev/null
96 then
97 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
98 return
99 fi
100 git remote rm cm 2> /dev/null
101
102 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
103 pfx="android_"
104 project="${proj//\//_}"
105 git remote add los "git@github.com:LineageOS/$pfx$project"
106 echo "Remote 'los' created"
107}
108
109function aospremote()
110{
111 local pfx project
112
113 if ! git rev-parse &> /dev/null
114 then
115 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
116 return
117 fi
118 git remote rm aosp 2> /dev/null
119
120 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
121 if [[ "$project" != device* ]]
122 then
123 pfx="platform/"
124 fi
125 git remote add aosp "https://android.googlesource.com/$pfx$project"
126 echo "Remote 'aosp' created"
127}
128
129function cafremote()
130{
131 local pfx project
132
133 if ! git rev-parse &> /dev/null
134 then
135 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
136 fi
137 git remote rm caf 2> /dev/null
138
139 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
140 if [[ "$project" != device* ]]
141 then
142 pfx="platform/"
143 fi
144 git remote add caf "git://codeaurora.org/$pfx$project"
145 echo "Remote 'caf' created"
146}
147
148function bliss_push()
149{
150 local branch ssh_name path_opt proj
151 branch="lp5.1"
152 ssh_name="bliss_review"
153 path_opt=
154
155 if [[ "$1" ]]
156 then
157 proj="$ANDROID_BUILD_TOP/$(echo "$1" | sed "s#$ANDROID_BUILD_TOP/##g")"
158 path_opt="--git-dir=$(printf "%q/.git" "${proj}")"
159 else
160 proj="$(pwd -P)"
161 fi
162 proj="$(echo "$proj" | sed "s#$ANDROID_BUILD_TOP/##g")"
163 proj="$(echo "$proj" | sed 's#/$##')"
164 proj="${proj//\//_}"
165
166 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
167 proj="android_$proj"
168 fi
169
170 git $path_opt push "ssh://${ssh_name}/BlissRoms/$proj" "HEAD:refs/for/$branch"
171}
172
173
174bliss_rename_function hmm
175function hmm() #hidden
176{
177 local i T
178 T="$(gettop)"
179 original_bliss_hmm
180 echo
181
182 echo "vendor/bliss extended functions. The complete list is:"
183 for i in $(grep -P '^function .*$' "$T/vendor/bliss/build/envsetup.sh" | grep -v "#hidden" | sed 's/function \([a-z_]*\).*/\1/' | sort | uniq); do
184 echo "$i"
185 done |column
186}
187
188bliss_append_hmm "blissremote" "Add a git remote for matching BlissRoms repository"
189bliss_append_hmm "losremote" "Add a git remote for matching LineageOS repository"
190bliss_append_hmm "aospremote" "Add git remote for matching AOSP repository"
191bliss_append_hmm "cafremote" "Add git remote for matching CodeAurora repository."
192