Anthony King | efd1542 | 2015-05-01 00:00:37 +0100 | [diff] [blame] | 1 | # slim functions that extend build/envsetup.sh |
| 2 | |
| 3 | function slim_device_combos() { |
Anthony King | 92a74cc | 2015-05-04 16:23:37 +0100 | [diff] [blame] | 4 | local device |
| 5 | |
Anthony King | efd1542 | 2015-05-01 00:00:37 +0100 | [diff] [blame] | 6 | 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 King | 8765d66 | 2015-05-01 00:46:46 +0100 | [diff] [blame] | 39 | function slim_rename_function() { |
| 40 | eval "original_slim_$(declare -f ${1})" |
| 41 | } |
| 42 | |
Anthony King | 58c3dfb | 2015-05-04 14:05:57 +0100 | [diff] [blame] | 43 | function 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 61 | |
| 62 | function slimremote() |
| 63 | { |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 64 | if ! git rev-parse &> /dev/null |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 65 | then |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 66 | 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 70 | |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 71 | 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 75 | fi |
| 76 | |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 77 | project="${proj//\//_}" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 78 | |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 79 | git remote add slim "git@github.com:SlimRoms/$pfx$project" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 80 | echo "Remote 'slim' created" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | function cmremote() |
| 84 | { |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 85 | if ! git rev-parse &> /dev/null |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 86 | then |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 87 | echo "Not in a git directory. Please run this from an Android repository you wish to set up." |
| 88 | return |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 89 | fi |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 90 | 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 96 | echo "Remote 'cm' created" |
| 97 | } |
| 98 | |
| 99 | function aospremote() |
| 100 | { |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 101 | 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 106 | git remote rm aosp 2> /dev/null |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 107 | |
| 108 | project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| 109 | if [[ "$project" != device* ]] |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 110 | then |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 111 | pfx="platform/" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 112 | fi |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 113 | git remote add aosp "https://android.googlesource.com/$pfx$project" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 114 | echo "Remote 'aosp' created" |
| 115 | } |
| 116 | |
| 117 | function cafremote() |
| 118 | { |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 119 | 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 King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 123 | git remote rm caf 2> /dev/null |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 124 | |
| 125 | project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| 126 | if [[ "$project" != device* ]] |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 127 | then |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 128 | pfx="platform/" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 129 | fi |
Anthony King | 9854d3e | 2015-05-04 14:44:32 +0100 | [diff] [blame] | 130 | git remote add caf "git://codeaurora.org/$pfx$project" |
Anthony King | 1c9bca2 | 2015-05-04 14:18:18 +0100 | [diff] [blame] | 131 | echo "Remote 'caf' created" |
| 132 | } |
Anthony King | 35181fd | 2015-05-04 15:01:56 +0100 | [diff] [blame] | 133 | |
| 134 | function 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 | } |