| # slim functions that extend build/envsetup.sh |
| |
| function slim_device_combos() { |
| T="$(gettop)" |
| list_file="${T}/vendor/slim/slim.devices" |
| variant="userdebug" |
| |
| if [[ $1 ]] |
| then |
| if [[ $2 ]] |
| then |
| list_file="$1" |
| variant="$2" |
| else |
| if [[ ${VARIANT_CHOICES[@]} =~ (^| )$1($| ) ]] |
| then |
| variant="$1" |
| else |
| list_file="$1" |
| fi |
| fi |
| fi |
| |
| if [[ ! -f "${list_file}" ]] |
| then |
| echo "unable to find device list: ${list_file}" |
| list_file="${T}/vendor/slim/slim.devices" |
| echo "defaulting device list file to: ${list_file}" |
| fi |
| |
| while IFS= read -r device |
| do |
| add_lunch_combo "slim_${device}-${variant}" |
| done < "${list_file}" |
| } |
| |
| function slim_rename_function() { |
| eval "original_slim_$(declare -f ${1})" |
| } |
| |
| function slim_add_hmm_entry() { |
| f_name="${1}" |
| f_desc="${2}" |
| |
| function _build_entry() { |
| printf "%-8s %s" "${f_name}:" "${f_desc}" |
| } |
| |
| for c in ${!HMM_DESCRIPTIVE[*]} |
| do |
| if [[ "${f_name}" == $(echo "${HMM_DESCRIPTIVE[$c]}" | cut -f1 -d":") ]] |
| then |
| HMM_DESCRIPTIVE[${c}]="$(_build_entry)" |
| return |
| fi |
| done |
| HMM_DESCRIPTIVE=(HMM_DESCRIPTIVE[@] "$(_build_entry)") |
| } |
| |
| function slimremote() |
| { |
| if ! git rev-parse &> /dev/null |
| then |
| echo "Not in a git directory. Please run this from an Android repository you wish to set up." |
| return |
| fi |
| git remote rm slim 2> /dev/null |
| |
| proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| |
| if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then |
| pfx="android_" |
| fi |
| |
| project="${proj//\//_}" |
| |
| git remote add slim "git@github.com:SlimRoms/$pfx$project" |
| echo "Remote 'slim' created" |
| } |
| |
| function cmremote() |
| { |
| if ! git rev-parse &> /dev/null |
| then |
| echo "Not in a git directory. Please run this from an Android repository you wish to set up." |
| return |
| fi |
| git remote rm cm 2> /dev/null |
| |
| proj="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| pfx="android_" |
| project="${proj//\//_}" |
| git remote add cm "git@github.com:CyanogenMod/$pfx$project" |
| echo "Remote 'cm' created" |
| } |
| |
| function aospremote() |
| { |
| if ! git rev-parse &> /dev/null |
| then |
| echo "Not in a git directory. Please run this from an Android repository you wish to set up." |
| return |
| fi |
| git remote rm aosp 2> /dev/null |
| |
| project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| if [[ "$project" != device* ]] |
| then |
| pfx="platform/" |
| fi |
| git remote add aosp "https://android.googlesource.com/$pfx$project" |
| echo "Remote 'aosp' created" |
| } |
| |
| function cafremote() |
| { |
| if ! git rev-parse &> /dev/null |
| then |
| echo "Not in a git directory. Please run this from an Android repository you wish to set up." |
| fi |
| git remote rm caf 2> /dev/null |
| |
| project="$(pwd -P | sed "s#$ANDROID_BUILD_TOP/##g")" |
| if [[ "$project" != device* ]] |
| then |
| pfx="platform/" |
| fi |
| git remote add caf "git://codeaurora.org/$pfx$project" |
| echo "Remote 'caf' created" |
| } |
| |
| function slim_push() |
| { |
| branch="lp5.1" |
| ssh_name="slim_review" |
| path_opt= |
| |
| if [[ "$1" ]] |
| then |
| proj="$ANDROID_BUILD_TOP/$(echo "$1" | sed "s#$ANDROID_BUILD_TOP/##g")" |
| path_opt="--git-dir=$(printf "%q/.git" "${proj}")" |
| else |
| proj="$(pwd -P)" |
| fi |
| proj="$(echo "$proj" | sed "s#$ANDROID_BUILD_TOP/##g")" |
| proj="$(echo "$proj" | sed 's#/$##')" |
| proj="${proj//\//_}" |
| |
| if (echo "$proj" | egrep -q 'external|system|build|bionic|art|libcore|prebuilt|dalvik') ; then |
| proj="android_$proj" |
| fi |
| |
| git $path_opt push "ssh://${ssh_name}/SlimRoms/$proj" "HEAD:refs/for/$branch" |
| } |