blob: 9b0bc6aa2418f326d05cefeb68c49bb3ff84368b [file] [log] [blame]
Anthony Kingefd15422015-05-01 00:00:37 +01001# slim functions that extend build/envsetup.sh
2
3function slim_device_combos() {
Anthony King92a74cc2015-05-04 16:23:37 +01004 local device
5
Anthony Kingefd15422015-05-01 00:00:37 +01006 T="$(gettop)"
7 list_file="${T}/vendor/slim/slim.devices"
8 variant="userdebug"
9
10 if [[ $1 ]]
11 then
12 if [[ $2 ]]
13 then
14 list_file="$1"
15 variant="$2"
16 else
17 if [[ ${VARIANT_CHOICES[@]} =~ (^| )$1($| ) ]]
18 then
19 variant="$1"
20 else
21 list_file="$1"
22 fi
23 fi
24 fi
25
26 if [[ ! -f "${list_file}" ]]
27 then
28 echo "unable to find device list: ${list_file}"
29 list_file="${T}/vendor/slim/slim.devices"
30 echo "defaulting device list file to: ${list_file}"
31 fi
32
33 while IFS= read -r device
34 do
35 add_lunch_combo "slim_${device}-${variant}"
36 done < "${list_file}"
37}
38
Anthony King8765d662015-05-01 00:46:46 +010039function slim_rename_function() {
40 eval "original_slim_$(declare -f ${1})"
41}
42
Anthony King58c3dfb2015-05-04 14:05:57 +010043function slim_add_hmm_entry() {
44 f_name="${1}"
45 f_desc="${2}"
46
47 function _build_entry() {
48 printf "%-8s %s" "${f_name}:" "${f_desc}"
49 }
50
51 for c in ${!HMM_DESCRIPTIVE[*]}
52 do
53 if [[ "${f_name}" == $(echo "${HMM_DESCRIPTIVE[$c]}" | cut -f1 -d":") ]]
54 then
55 HMM_DESCRIPTIVE[${c}]="$(_build_entry)"
56 return
57 fi
58 done
59 HMM_DESCRIPTIVE=(HMM_DESCRIPTIVE[@] "$(_build_entry)")
60}
Anthony King1c9bca22015-05-04 14:18:18 +010061
62function slimremote()
63{
Anthony King9854d3e2015-05-04 14:44:32 +010064 if ! git rev-parse &> /dev/null
Anthony King1c9bca22015-05-04 14:18:18 +010065 then
Anthony King9854d3e2015-05-04 14:44:32 +010066 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
67 return
68 fi
69 git remote rm slim 2> /dev/null
Anthony King1c9bca22015-05-04 14:18:18 +010070
Anthony King9854d3e2015-05-04 14:44:32 +010071 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
72
73 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
74 pfx="android_"
Anthony King1c9bca22015-05-04 14:18:18 +010075 fi
76
Anthony King9854d3e2015-05-04 14:44:32 +010077 project="${proj//\//_}"
Anthony King1c9bca22015-05-04 14:18:18 +010078
Anthony King9854d3e2015-05-04 14:44:32 +010079 git remote add slim "git@github.com:SlimRoms/$pfx$project"
Anthony King1c9bca22015-05-04 14:18:18 +010080 echo "Remote 'slim' created"
Anthony King1c9bca22015-05-04 14:18:18 +010081}
82
83function cmremote()
84{
Anthony King9854d3e2015-05-04 14:44:32 +010085 if ! git rev-parse &> /dev/null
Anthony King1c9bca22015-05-04 14:18:18 +010086 then
Anthony King9854d3e2015-05-04 14:44:32 +010087 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
88 return
Anthony King1c9bca22015-05-04 14:18:18 +010089 fi
Anthony King9854d3e2015-05-04 14:44:32 +010090 git remote rm cm 2> /dev/null
91
92 proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
93 pfx="android_"
94 project="${proj//\//_}"
95 git remote add cm "git@github.com:CyanogenMod/$pfx$project"
Anthony King1c9bca22015-05-04 14:18:18 +010096 echo "Remote 'cm' created"
97}
98
99function aospremote()
100{
Anthony King9854d3e2015-05-04 14:44:32 +0100101 if ! git rev-parse &> /dev/null
102 then
103 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
104 return
105 fi
Anthony King1c9bca22015-05-04 14:18:18 +0100106 git remote rm aosp 2> /dev/null
Anthony King9854d3e2015-05-04 14:44:32 +0100107
108 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
109 if [[ "$project" != device* ]]
Anthony King1c9bca22015-05-04 14:18:18 +0100110 then
Anthony King9854d3e2015-05-04 14:44:32 +0100111 pfx="platform/"
Anthony King1c9bca22015-05-04 14:18:18 +0100112 fi
Anthony King9854d3e2015-05-04 14:44:32 +0100113 git remote add aosp "https://android.googlesource.com/$pfx$project"
Anthony King1c9bca22015-05-04 14:18:18 +0100114 echo "Remote 'aosp' created"
115}
116
117function cafremote()
118{
Anthony King9854d3e2015-05-04 14:44:32 +0100119 if ! git rev-parse &> /dev/null
120 then
121 echo "Not in a git directory. Please run this from an Android repository you wish to set up."
122 fi
Anthony King1c9bca22015-05-04 14:18:18 +0100123 git remote rm caf 2> /dev/null
Anthony King9854d3e2015-05-04 14:44:32 +0100124
125 project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")"
126 if [[ "$project" != device* ]]
Anthony King1c9bca22015-05-04 14:18:18 +0100127 then
Anthony King9854d3e2015-05-04 14:44:32 +0100128 pfx="platform/"
Anthony King1c9bca22015-05-04 14:18:18 +0100129 fi
Anthony King9854d3e2015-05-04 14:44:32 +0100130 git remote add caf "git://codeaurora.org/$pfx$project"
Anthony King1c9bca22015-05-04 14:18:18 +0100131 echo "Remote 'caf' created"
132}
Anthony King35181fd2015-05-04 15:01:56 +0100133
134function slim_push()
135{
136 branch="lp5.1"
137 ssh_name="slim_review"
138 path_opt=
139
140 if [[ "$1" ]]
141 then
142 proj="$ANDROID_BUILD_TOP/$(echo "$1" | sed "s#$ANDROID_BUILD_TOP/##g")"
143 path_opt="--git-dir=$(printf "%q/.git" "${proj}")"
144 else
145 proj="$(pwd -P)"
146 fi
147 proj="$(echo "$proj" | sed "s#$ANDROID_BUILD_TOP/##g")"
148 proj="$(echo "$proj" | sed 's#/$##')"
149 proj="${proj//\//_}"
150
151 if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then
152 proj="android_$proj"
153 fi
154
155 git $path_opt push "ssh://${ssh_name}/SlimRoms/$proj" "HEAD:refs/for/$branch"
156}