Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 1 | function __print_cm_functions_help() { |
| 2 | cat <<EOF |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 3 | Additional LineageOS functions: |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 4 | - cout: Changes directory to out. |
| 5 | - mmp: Builds all of the modules in the current directory and pushes them to the device. |
| 6 | - mmap: Builds all of the modules in the current directory and its dependencies, then pushes the package to the device. |
| 7 | - mmmp: Builds all of the modules in the supplied directories and pushes them to the device. |
| 8 | - mms: Short circuit builder. Quickly re-build the kernel, rootfs, boot and system images |
| 9 | without deep dependencies. Requires the full build to have run before. |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 10 | - cmgerrit: A Git wrapper that fetches/pushes patch from/to LineageOS Gerrit Review. |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 11 | - cmrebase: Rebase a Gerrit change and push it again. |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 12 | - cmremote: Add git remote for LineageOS Gerrit Review. |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 13 | - aospremote: Add git remote for matching AOSP repository. |
| 14 | - cafremote: Add git remote for matching CodeAurora repository. |
| 15 | - mka: Builds using SCHED_BATCH on all processors. |
| 16 | - mkap: Builds the module(s) using mka and pushes them to the device. |
| 17 | - cmka: Cleans and builds using mka. |
| 18 | - repodiff: Diff 2 different branches or tags within the same repo |
| 19 | - repolastsync: Prints date and time of last repo sync. |
| 20 | - reposync: Parallel repo sync using ionice and SCHED_BATCH. |
| 21 | - repopick: Utility to fetch changes from Gerrit. |
| 22 | - installboot: Installs a boot.img to the connected device. |
| 23 | - installrecovery: Installs a recovery.img to the connected device. |
| 24 | EOF |
| 25 | } |
| 26 | |
| 27 | function brunch() |
| 28 | { |
| 29 | breakfast $* |
| 30 | if [ $? -eq 0 ]; then |
| 31 | mka bacon |
| 32 | else |
| 33 | echo "No such item in brunch menu. Try 'breakfast'" |
| 34 | return 1 |
| 35 | fi |
| 36 | return $? |
| 37 | } |
| 38 | |
| 39 | function breakfast() |
| 40 | { |
| 41 | target=$1 |
| 42 | local variant=$2 |
| 43 | CM_DEVICES_ONLY="true" |
| 44 | unset LUNCH_MENU_CHOICES |
| 45 | add_lunch_combo full-eng |
| 46 | for f in `/bin/ls vendor/cm/vendorsetup.sh 2> /dev/null` |
| 47 | do |
| 48 | echo "including $f" |
| 49 | . $f |
| 50 | done |
| 51 | unset f |
| 52 | |
| 53 | if [ $# -eq 0 ]; then |
| 54 | # No arguments, so let's have the full menu |
| 55 | lunch |
| 56 | else |
| 57 | echo "z$target" | grep -q "-" |
| 58 | if [ $? -eq 0 ]; then |
| 59 | # A buildtype was specified, assume a full device name |
| 60 | lunch $target |
| 61 | else |
Simon Shields | 63ce74b | 2016-12-28 11:33:29 +1100 | [diff] [blame] | 62 | # This is probably just the Lineage model name |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 63 | if [ -z "$variant" ]; then |
| 64 | variant="userdebug" |
| 65 | fi |
Matt Mower | ed8c248 | 2017-01-02 02:26:01 -0600 | [diff] [blame] | 66 | |
| 67 | if ! check_product lineage_$target && check_product cm_$target; then |
Simon Shields | 63ce74b | 2016-12-28 11:33:29 +1100 | [diff] [blame] | 68 | echo "** Warning: '$target' is using CM-based makefiles. This will be deprecated in the next major release." |
| 69 | lunch cm_$target-$variant |
Matt Mower | ed8c248 | 2017-01-02 02:26:01 -0600 | [diff] [blame] | 70 | else |
| 71 | lunch lineage_$target-$variant |
Simon Shields | 63ce74b | 2016-12-28 11:33:29 +1100 | [diff] [blame] | 72 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 73 | fi |
| 74 | fi |
| 75 | return $? |
| 76 | } |
| 77 | |
| 78 | alias bib=breakfast |
| 79 | |
| 80 | function eat() |
| 81 | { |
| 82 | if [ "$OUT" ] ; then |
Zhao Wei Liew | 321dde5 | 2017-01-01 15:24:38 +0800 | [diff] [blame] | 83 | MODVERSION=$(get_build_var LINEAGE_VERSION) |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 84 | ZIPFILE=lineage-$MODVERSION.zip |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 85 | ZIPPATH=$OUT/$ZIPFILE |
| 86 | if [ ! -f $ZIPPATH ] ; then |
| 87 | echo "Nothing to eat" |
| 88 | return 1 |
| 89 | fi |
| 90 | adb start-server # Prevent unexpected starting server message from adb get-state in the next line |
| 91 | if [ $(adb get-state) != device -a $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then |
| 92 | echo "No device is online. Waiting for one..." |
| 93 | echo "Please connect USB and/or enable USB debugging" |
| 94 | until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do |
| 95 | sleep 1 |
| 96 | done |
| 97 | echo "Device Found.." |
| 98 | fi |
Ethan Chen | b69c2ff | 2016-12-31 13:23:56 -0800 | [diff] [blame] | 99 | if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD"); then |
| 100 | # if adbd isn't root we can't write to /cache/recovery/ |
| 101 | adb root |
| 102 | sleep 1 |
| 103 | adb wait-for-device |
| 104 | cat << EOF > /tmp/command |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 105 | --sideload_auto_reboot |
| 106 | EOF |
Ethan Chen | b69c2ff | 2016-12-31 13:23:56 -0800 | [diff] [blame] | 107 | if adb push /tmp/command /cache/recovery/ ; then |
| 108 | echo "Rebooting into recovery for sideload installation" |
| 109 | adb reboot recovery |
| 110 | adb wait-for-sideload |
| 111 | adb sideload $ZIPPATH |
| 112 | fi |
| 113 | rm /tmp/command |
| 114 | else |
| 115 | echo "The connected device does not appear to be $CM_BUILD, run away!" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 116 | fi |
Ethan Chen | b69c2ff | 2016-12-31 13:23:56 -0800 | [diff] [blame] | 117 | return $? |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 118 | else |
| 119 | echo "Nothing to eat" |
| 120 | return 1 |
| 121 | fi |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | function omnom() |
| 125 | { |
| 126 | brunch $* |
| 127 | eat |
| 128 | } |
| 129 | |
| 130 | function cout() |
| 131 | { |
| 132 | if [ "$OUT" ]; then |
| 133 | cd $OUT |
| 134 | else |
| 135 | echo "Couldn't locate out directory. Try setting OUT." |
| 136 | fi |
| 137 | } |
| 138 | |
| 139 | function dddclient() |
| 140 | { |
| 141 | local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT) |
| 142 | local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED) |
| 143 | local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED) |
| 144 | local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED) |
| 145 | local OUT_EXE_SYMBOLS=$(get_symbols_directory) |
| 146 | local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS) |
| 147 | local ARCH=$(get_build_var TARGET_ARCH) |
| 148 | local GDB |
| 149 | case "$ARCH" in |
| 150 | arm) GDB=arm-linux-androideabi-gdb;; |
| 151 | arm64) GDB=arm-linux-androideabi-gdb; GDB64=aarch64-linux-android-gdb;; |
| 152 | mips|mips64) GDB=mips64el-linux-android-gdb;; |
| 153 | x86) GDB=x86_64-linux-android-gdb;; |
| 154 | x86_64) GDB=x86_64-linux-android-gdb;; |
| 155 | *) echo "Unknown arch $ARCH"; return 1;; |
| 156 | esac |
| 157 | |
| 158 | if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then |
| 159 | local EXE="$1" |
| 160 | if [ "$EXE" ] ; then |
| 161 | EXE=$1 |
| 162 | if [[ $EXE =~ ^[^/].* ]] ; then |
| 163 | EXE="system/bin/"$EXE |
| 164 | fi |
| 165 | else |
| 166 | EXE="app_process" |
| 167 | fi |
| 168 | |
| 169 | local PORT="$2" |
| 170 | if [ "$PORT" ] ; then |
| 171 | PORT=$2 |
| 172 | else |
| 173 | PORT=":5039" |
| 174 | fi |
| 175 | |
| 176 | local PID="$3" |
| 177 | if [ "$PID" ] ; then |
| 178 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
| 179 | PID=`pid $3` |
| 180 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
| 181 | # that likely didn't work because of returning multiple processes |
| 182 | # try again, filtering by root processes (don't contain colon) |
| 183 | PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'` |
| 184 | if [[ ! "$PID" =~ ^[0-9]+$ ]] |
| 185 | then |
| 186 | echo "Couldn't resolve '$3' to single PID" |
| 187 | return 1 |
| 188 | else |
| 189 | echo "" |
| 190 | echo "WARNING: multiple processes matching '$3' observed, using root process" |
| 191 | echo "" |
| 192 | fi |
| 193 | fi |
| 194 | fi |
| 195 | adb forward "tcp$PORT" "tcp$PORT" |
| 196 | local USE64BIT="$(is64bit $PID)" |
| 197 | adb shell gdbserver$USE64BIT $PORT --attach $PID & |
| 198 | sleep 2 |
| 199 | else |
| 200 | echo "" |
| 201 | echo "If you haven't done so already, do this first on the device:" |
| 202 | echo " gdbserver $PORT /system/bin/$EXE" |
| 203 | echo " or" |
| 204 | echo " gdbserver $PORT --attach <PID>" |
| 205 | echo "" |
| 206 | fi |
| 207 | |
| 208 | OUT_SO_SYMBOLS=$OUT_SO_SYMBOLS$USE64BIT |
| 209 | OUT_VENDOR_SO_SYMBOLS=$OUT_VENDOR_SO_SYMBOLS$USE64BIT |
| 210 | |
| 211 | echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS" |
| 212 | echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl" |
| 213 | echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb" |
| 214 | echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT" |
| 215 | # Enable special debugging for ART processes. |
| 216 | if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then |
| 217 | echo >> "$OUT_ROOT/gdbclient.cmds" "art-on" |
| 218 | fi |
| 219 | echo >>"$OUT_ROOT/gdbclient.cmds" "" |
| 220 | |
| 221 | local WHICH_GDB= |
| 222 | # 64-bit exe found |
| 223 | if [ "$USE64BIT" != "" ] ; then |
| 224 | WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB64 |
| 225 | # 32-bit exe / 32-bit platform |
| 226 | elif [ "$(get_build_var TARGET_2ND_ARCH)" = "" ]; then |
| 227 | WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB |
| 228 | # 32-bit exe / 64-bit platform |
| 229 | else |
| 230 | WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB |
| 231 | fi |
| 232 | |
| 233 | ddd --debugger $WHICH_GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE" |
| 234 | else |
| 235 | echo "Unable to determine build system output dir." |
| 236 | fi |
| 237 | } |
| 238 | |
| 239 | function cmremote() |
| 240 | { |
| 241 | if ! git rev-parse --git-dir &> /dev/null |
| 242 | then |
| 243 | echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." |
| 244 | return 1 |
| 245 | fi |
| 246 | git remote rm cmremote 2> /dev/null |
| 247 | GERRIT_REMOTE=$(git config --get remote.github.projectname) |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 248 | CMUSER=$(git config --get review.review.lineageos.org.username) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 249 | if [ -z "$CMUSER" ] |
| 250 | then |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 251 | git remote add cmremote ssh://review.lineageos.org:29418/$GERRIT_REMOTE |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 252 | else |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 253 | git remote add cmremote ssh://$CMUSER@review.lineageos.org:29418/$GERRIT_REMOTE |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 254 | fi |
| 255 | echo "Remote 'cmremote' created" |
| 256 | } |
| 257 | |
| 258 | function aospremote() |
| 259 | { |
| 260 | if ! git rev-parse --git-dir &> /dev/null |
| 261 | then |
| 262 | echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." |
| 263 | return 1 |
| 264 | fi |
| 265 | git remote rm aosp 2> /dev/null |
Michael Bestas | e724a1c | 2016-10-20 23:25:40 +0300 | [diff] [blame] | 266 | PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##") |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 267 | if (echo $PROJECT | grep -qv "^device") |
| 268 | then |
| 269 | PFX="platform/" |
| 270 | fi |
| 271 | git remote add aosp https://android.googlesource.com/$PFX$PROJECT |
| 272 | echo "Remote 'aosp' created" |
| 273 | } |
| 274 | |
| 275 | function cafremote() |
| 276 | { |
| 277 | if ! git rev-parse --git-dir &> /dev/null |
| 278 | then |
| 279 | echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." |
| 280 | return 1 |
| 281 | fi |
| 282 | git remote rm caf 2> /dev/null |
Michael Bestas | e724a1c | 2016-10-20 23:25:40 +0300 | [diff] [blame] | 283 | PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##") |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 284 | if (echo $PROJECT | grep -qv "^device") |
| 285 | then |
| 286 | PFX="platform/" |
| 287 | fi |
Zhao Wei Liew | fb4b8c5 | 2017-01-08 09:03:01 +0800 | [diff] [blame] | 288 | git remote add caf https://source.codeaurora.org/quic/la/$PFX$PROJECT |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 289 | echo "Remote 'caf' created" |
| 290 | } |
| 291 | |
| 292 | function installboot() |
| 293 | { |
| 294 | if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ]; |
| 295 | then |
| 296 | echo "No recovery.fstab found. Build recovery first." |
| 297 | return 1 |
| 298 | fi |
| 299 | if [ ! -e "$OUT/boot.img" ]; |
| 300 | then |
| 301 | echo "No boot.img found. Run make bootimage first." |
| 302 | return 1 |
| 303 | fi |
| 304 | PARTITION=`grep "^\/boot" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 305 | if [ -z "$PARTITION" ]; |
| 306 | then |
| 307 | # Try for RECOVERY_FSTAB_VERSION = 2 |
| 308 | PARTITION=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}` |
| 309 | PARTITION_TYPE=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 310 | if [ -z "$PARTITION" ]; |
| 311 | then |
| 312 | echo "Unable to determine boot partition." |
| 313 | return 1 |
| 314 | fi |
| 315 | fi |
| 316 | adb start-server |
| 317 | adb wait-for-online |
| 318 | adb root |
| 319 | sleep 1 |
| 320 | adb wait-for-online shell mount /system 2>&1 > /dev/null |
| 321 | adb wait-for-online remount |
| 322 | if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD"); |
| 323 | then |
| 324 | adb push $OUT/boot.img /cache/ |
| 325 | for i in $OUT/system/lib/modules/*; |
| 326 | do |
| 327 | adb push $i /system/lib/modules/ |
| 328 | done |
| 329 | adb shell dd if=/cache/boot.img of=$PARTITION |
| 330 | adb shell chmod 644 /system/lib/modules/* |
| 331 | echo "Installation complete." |
| 332 | else |
| 333 | echo "The connected device does not appear to be $CM_BUILD, run away!" |
| 334 | fi |
| 335 | } |
| 336 | |
| 337 | function installrecovery() |
| 338 | { |
| 339 | if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ]; |
| 340 | then |
| 341 | echo "No recovery.fstab found. Build recovery first." |
| 342 | return 1 |
| 343 | fi |
| 344 | if [ ! -e "$OUT/recovery.img" ]; |
| 345 | then |
| 346 | echo "No recovery.img found. Run make recoveryimage first." |
| 347 | return 1 |
| 348 | fi |
| 349 | PARTITION=`grep "^\/recovery" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 350 | if [ -z "$PARTITION" ]; |
| 351 | then |
| 352 | # Try for RECOVERY_FSTAB_VERSION = 2 |
| 353 | PARTITION=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}` |
| 354 | PARTITION_TYPE=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 355 | if [ -z "$PARTITION" ]; |
| 356 | then |
| 357 | echo "Unable to determine recovery partition." |
| 358 | return 1 |
| 359 | fi |
| 360 | fi |
| 361 | adb start-server |
| 362 | adb wait-for-online |
| 363 | adb root |
| 364 | sleep 1 |
| 365 | adb wait-for-online shell mount /system 2>&1 >> /dev/null |
| 366 | adb wait-for-online remount |
| 367 | if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD"); |
| 368 | then |
| 369 | adb push $OUT/recovery.img /cache/ |
| 370 | adb shell dd if=/cache/recovery.img of=$PARTITION |
| 371 | echo "Installation complete." |
| 372 | else |
| 373 | echo "The connected device does not appear to be $CM_BUILD, run away!" |
| 374 | fi |
| 375 | } |
| 376 | |
| 377 | function makerecipe() { |
| 378 | if [ -z "$1" ] |
| 379 | then |
| 380 | echo "No branch name provided." |
| 381 | return 1 |
| 382 | fi |
| 383 | cd android |
| 384 | sed -i s/'default revision=.*'/'default revision="refs\/heads\/'$1'"'/ default.xml |
| 385 | git commit -a -m "$1" |
| 386 | cd .. |
| 387 | |
| 388 | repo forall -c ' |
| 389 | |
| 390 | if [ "$REPO_REMOTE" = "github" ] |
| 391 | then |
| 392 | pwd |
| 393 | cmremote |
| 394 | git push cmremote HEAD:refs/heads/'$1' |
| 395 | fi |
| 396 | ' |
| 397 | } |
| 398 | |
| 399 | function cmgerrit() { |
| 400 | if [ "$(__detect_shell)" = "zsh" ]; then |
| 401 | # zsh does not define FUNCNAME, derive from funcstack |
| 402 | local FUNCNAME=$funcstack[1] |
| 403 | fi |
| 404 | |
| 405 | if [ $# -eq 0 ]; then |
| 406 | $FUNCNAME help |
| 407 | return 1 |
| 408 | fi |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 409 | local user=`git config --get review.review.lineageos.org.username` |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 410 | local review=`git config --get remote.github.review` |
| 411 | local project=`git config --get remote.github.projectname` |
| 412 | local command=$1 |
| 413 | shift |
| 414 | case $command in |
| 415 | help) |
| 416 | if [ $# -eq 0 ]; then |
| 417 | cat <<EOF |
| 418 | Usage: |
| 419 | $FUNCNAME COMMAND [OPTIONS] [CHANGE-ID[/PATCH-SET]][{@|^|~|:}ARG] [-- ARGS] |
| 420 | |
| 421 | Commands: |
| 422 | fetch Just fetch the change as FETCH_HEAD |
| 423 | help Show this help, or for a specific command |
| 424 | pull Pull a change into current branch |
| 425 | push Push HEAD or a local branch to Gerrit for a specific branch |
| 426 | |
| 427 | Any other Git commands that support refname would work as: |
| 428 | git fetch URL CHANGE && git COMMAND OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS |
| 429 | |
| 430 | See '$FUNCNAME help COMMAND' for more information on a specific command. |
| 431 | |
| 432 | Example: |
| 433 | $FUNCNAME checkout -b topic 1234/5 |
| 434 | works as: |
| 435 | git fetch http://DOMAIN/p/PROJECT refs/changes/34/1234/5 \\ |
| 436 | && git checkout -b topic FETCH_HEAD |
| 437 | will checkout a new branch 'topic' base on patch-set 5 of change 1234. |
| 438 | Patch-set 1 will be fetched if omitted. |
| 439 | EOF |
| 440 | return |
| 441 | fi |
| 442 | case $1 in |
| 443 | __cmg_*) echo "For internal use only." ;; |
| 444 | changes|for) |
| 445 | if [ "$FUNCNAME" = "cmgerrit" ]; then |
| 446 | echo "'$FUNCNAME $1' is deprecated." |
| 447 | fi |
| 448 | ;; |
| 449 | help) $FUNCNAME help ;; |
| 450 | fetch|pull) cat <<EOF |
| 451 | usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET] |
| 452 | |
| 453 | works as: |
| 454 | git $1 OPTIONS http://DOMAIN/p/PROJECT \\ |
| 455 | refs/changes/HASH/CHANGE-ID/{PATCH-SET|1} |
| 456 | |
| 457 | Example: |
| 458 | $FUNCNAME $1 1234 |
| 459 | will $1 patch-set 1 of change 1234 |
| 460 | EOF |
| 461 | ;; |
| 462 | push) cat <<EOF |
| 463 | usage: $FUNCNAME push [OPTIONS] [LOCAL_BRANCH:]REMOTE_BRANCH |
| 464 | |
| 465 | works as: |
| 466 | git push OPTIONS ssh://USER@DOMAIN:29418/PROJECT \\ |
| 467 | {LOCAL_BRANCH|HEAD}:refs/for/REMOTE_BRANCH |
| 468 | |
| 469 | Example: |
| 470 | $FUNCNAME push fix6789:gingerbread |
| 471 | will push local branch 'fix6789' to Gerrit for branch 'gingerbread'. |
| 472 | HEAD will be pushed from local if omitted. |
| 473 | EOF |
| 474 | ;; |
| 475 | *) |
| 476 | $FUNCNAME __cmg_err_not_supported $1 && return |
| 477 | cat <<EOF |
| 478 | usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET][{@|^|~|:}ARG] [-- ARGS] |
| 479 | |
| 480 | works as: |
| 481 | git fetch http://DOMAIN/p/PROJECT \\ |
| 482 | refs/changes/HASH/CHANGE-ID/{PATCH-SET|1} \\ |
| 483 | && git $1 OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS |
| 484 | EOF |
| 485 | ;; |
| 486 | esac |
| 487 | ;; |
| 488 | __cmg_get_ref) |
| 489 | $FUNCNAME __cmg_err_no_arg $command $# && return 1 |
| 490 | local change_id patchset_id hash |
| 491 | case $1 in |
| 492 | */*) |
| 493 | change_id=${1%%/*} |
| 494 | patchset_id=${1#*/} |
| 495 | ;; |
| 496 | *) |
| 497 | change_id=$1 |
| 498 | patchset_id=1 |
| 499 | ;; |
| 500 | esac |
| 501 | hash=$(($change_id % 100)) |
| 502 | case $hash in |
| 503 | [0-9]) hash="0$hash" ;; |
| 504 | esac |
| 505 | echo "refs/changes/$hash/$change_id/$patchset_id" |
| 506 | ;; |
| 507 | fetch|pull) |
| 508 | $FUNCNAME __cmg_err_no_arg $command $# help && return 1 |
| 509 | $FUNCNAME __cmg_err_not_repo && return 1 |
| 510 | local change=$1 |
| 511 | shift |
| 512 | git $command $@ http://$review/p/$project \ |
| 513 | $($FUNCNAME __cmg_get_ref $change) || return 1 |
| 514 | ;; |
| 515 | push) |
| 516 | $FUNCNAME __cmg_err_no_arg $command $# help && return 1 |
| 517 | $FUNCNAME __cmg_err_not_repo && return 1 |
| 518 | if [ -z "$user" ]; then |
| 519 | echo >&2 "Gerrit username not found." |
| 520 | return 1 |
| 521 | fi |
| 522 | local local_branch remote_branch |
| 523 | case $1 in |
| 524 | *:*) |
| 525 | local_branch=${1%:*} |
| 526 | remote_branch=${1##*:} |
| 527 | ;; |
| 528 | *) |
| 529 | local_branch=HEAD |
| 530 | remote_branch=$1 |
| 531 | ;; |
| 532 | esac |
| 533 | shift |
| 534 | git push $@ ssh://$user@$review:29418/$project \ |
| 535 | $local_branch:refs/for/$remote_branch || return 1 |
| 536 | ;; |
| 537 | changes|for) |
| 538 | if [ "$FUNCNAME" = "cmgerrit" ]; then |
| 539 | echo >&2 "'$FUNCNAME $command' is deprecated." |
| 540 | fi |
| 541 | ;; |
| 542 | __cmg_err_no_arg) |
| 543 | if [ $# -lt 2 ]; then |
| 544 | echo >&2 "'$FUNCNAME $command' missing argument." |
| 545 | elif [ $2 -eq 0 ]; then |
| 546 | if [ -n "$3" ]; then |
| 547 | $FUNCNAME help $1 |
| 548 | else |
| 549 | echo >&2 "'$FUNCNAME $1' missing argument." |
| 550 | fi |
| 551 | else |
| 552 | return 1 |
| 553 | fi |
| 554 | ;; |
| 555 | __cmg_err_not_repo) |
| 556 | if [ -z "$review" -o -z "$project" ]; then |
| 557 | echo >&2 "Not currently in any reviewable repository." |
| 558 | else |
| 559 | return 1 |
| 560 | fi |
| 561 | ;; |
| 562 | __cmg_err_not_supported) |
| 563 | $FUNCNAME __cmg_err_no_arg $command $# && return |
| 564 | case $1 in |
| 565 | #TODO: filter more git commands that don't use refname |
| 566 | init|add|rm|mv|status|clone|remote|bisect|config|stash) |
| 567 | echo >&2 "'$FUNCNAME $1' is not supported." |
| 568 | ;; |
| 569 | *) return 1 ;; |
| 570 | esac |
| 571 | ;; |
| 572 | #TODO: other special cases? |
| 573 | *) |
| 574 | $FUNCNAME __cmg_err_not_supported $command && return 1 |
| 575 | $FUNCNAME __cmg_err_no_arg $command $# help && return 1 |
| 576 | $FUNCNAME __cmg_err_not_repo && return 1 |
| 577 | local args="$@" |
| 578 | local change pre_args refs_arg post_args |
| 579 | case "$args" in |
| 580 | *--\ *) |
| 581 | pre_args=${args%%-- *} |
| 582 | post_args="-- ${args#*-- }" |
| 583 | ;; |
| 584 | *) pre_args="$args" ;; |
| 585 | esac |
| 586 | args=($pre_args) |
| 587 | pre_args= |
| 588 | if [ ${#args[@]} -gt 0 ]; then |
| 589 | change=${args[${#args[@]}-1]} |
| 590 | fi |
| 591 | if [ ${#args[@]} -gt 1 ]; then |
| 592 | pre_args=${args[0]} |
| 593 | for ((i=1; i<${#args[@]}-1; i++)); do |
| 594 | pre_args="$pre_args ${args[$i]}" |
| 595 | done |
| 596 | fi |
| 597 | while ((1)); do |
| 598 | case $change in |
| 599 | ""|--) |
| 600 | $FUNCNAME help $command |
| 601 | return 1 |
| 602 | ;; |
| 603 | *@*) |
| 604 | if [ -z "$refs_arg" ]; then |
| 605 | refs_arg="@${change#*@}" |
| 606 | change=${change%%@*} |
| 607 | fi |
| 608 | ;; |
| 609 | *~*) |
| 610 | if [ -z "$refs_arg" ]; then |
| 611 | refs_arg="~${change#*~}" |
| 612 | change=${change%%~*} |
| 613 | fi |
| 614 | ;; |
| 615 | *^*) |
| 616 | if [ -z "$refs_arg" ]; then |
| 617 | refs_arg="^${change#*^}" |
| 618 | change=${change%%^*} |
| 619 | fi |
| 620 | ;; |
| 621 | *:*) |
| 622 | if [ -z "$refs_arg" ]; then |
| 623 | refs_arg=":${change#*:}" |
| 624 | change=${change%%:*} |
| 625 | fi |
| 626 | ;; |
| 627 | *) break ;; |
| 628 | esac |
| 629 | done |
| 630 | $FUNCNAME fetch $change \ |
| 631 | && git $command $pre_args FETCH_HEAD$refs_arg $post_args \ |
| 632 | || return 1 |
| 633 | ;; |
| 634 | esac |
| 635 | } |
| 636 | |
| 637 | function cmrebase() { |
| 638 | local repo=$1 |
| 639 | local refs=$2 |
| 640 | local pwd="$(pwd)" |
| 641 | local dir="$(gettop)/$repo" |
| 642 | |
| 643 | if [ -z $repo ] || [ -z $refs ]; then |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 644 | echo "LineageOS Gerrit Rebase Usage: " |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 645 | echo " cmrebase <path to project> <patch IDs on Gerrit>" |
| 646 | echo " The patch IDs appear on the Gerrit commands that are offered." |
| 647 | echo " They consist on a series of numbers and slashes, after the text" |
| 648 | echo " refs/changes. For example, the ID in the following command is 26/8126/2" |
| 649 | echo "" |
| 650 | echo " git[...]ges_apps_Camera refs/changes/26/8126/2 && git cherry-pick FETCH_HEAD" |
| 651 | echo "" |
| 652 | return |
| 653 | fi |
| 654 | |
| 655 | if [ ! -d $dir ]; then |
| 656 | echo "Directory $dir doesn't exist in tree." |
| 657 | return |
| 658 | fi |
| 659 | cd $dir |
| 660 | repo=$(cat .git/config | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g) |
| 661 | echo "Starting branch..." |
| 662 | repo start tmprebase . |
| 663 | echo "Bringing it up to date..." |
| 664 | repo sync . |
| 665 | echo "Fetching change..." |
Dan Pasanen | 0344771 | 2016-12-19 11:22:55 -0600 | [diff] [blame] | 666 | git fetch "http://review.lineageos.org/p/$repo" "refs/changes/$refs" && git cherry-pick FETCH_HEAD |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 667 | if [ "$?" != "0" ]; then |
| 668 | echo "Error cherry-picking. Not uploading!" |
| 669 | return |
| 670 | fi |
| 671 | echo "Uploading..." |
| 672 | repo upload . |
| 673 | echo "Cleaning up..." |
| 674 | repo abandon tmprebase . |
| 675 | cd $pwd |
| 676 | } |
| 677 | |
| 678 | function mka() { |
| 679 | local T=$(gettop) |
| 680 | if [ "$T" ]; then |
| 681 | case `uname -s` in |
| 682 | Darwin) |
| 683 | make -C $T -j `sysctl hw.ncpu|cut -d" " -f2` "$@" |
| 684 | ;; |
| 685 | *) |
frk | f85ec8a | 2017-02-19 15:57:25 +0100 | [diff] [blame] | 686 | mk_timer schedtool -B -n 10 -e ionice -n 7 make -C $T -j$(grep "^processor" /proc/cpuinfo | wc -l) "$@" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 687 | ;; |
| 688 | esac |
| 689 | |
| 690 | else |
| 691 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 692 | fi |
| 693 | } |
| 694 | |
| 695 | function cmka() { |
| 696 | if [ ! -z "$1" ]; then |
| 697 | for i in "$@"; do |
| 698 | case $i in |
| 699 | bacon|otapackage|systemimage) |
| 700 | mka installclean |
| 701 | mka $i |
| 702 | ;; |
| 703 | *) |
| 704 | mka clean-$i |
| 705 | mka $i |
| 706 | ;; |
| 707 | esac |
| 708 | done |
| 709 | else |
| 710 | mka clean |
| 711 | mka |
| 712 | fi |
| 713 | } |
| 714 | |
| 715 | function mms() { |
| 716 | local T=$(gettop) |
| 717 | if [ -z "$T" ] |
| 718 | then |
| 719 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 720 | return 1 |
| 721 | fi |
| 722 | |
| 723 | case `uname -s` in |
| 724 | Darwin) |
| 725 | local NUM_CPUS=$(sysctl hw.ncpu|cut -d" " -f2) |
| 726 | ONE_SHOT_MAKEFILE="__none__" \ |
| 727 | make -C $T -j $NUM_CPUS "$@" |
| 728 | ;; |
| 729 | *) |
frk | f85ec8a | 2017-02-19 15:57:25 +0100 | [diff] [blame] | 730 | local NUM_CPUS=$(grep "^processor" /proc/cpuinfo | wc -l) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 731 | ONE_SHOT_MAKEFILE="__none__" \ |
| 732 | mk_timer schedtool -B -n 1 -e ionice -n 1 \ |
| 733 | make -C $T -j $NUM_CPUS "$@" |
| 734 | ;; |
| 735 | esac |
| 736 | } |
| 737 | |
| 738 | function repolastsync() { |
| 739 | RLSPATH="$ANDROID_BUILD_TOP/.repo/.repo_fetchtimes.json" |
| 740 | RLSLOCAL=$(date -d "$(stat -c %z $RLSPATH)" +"%e %b %Y, %T %Z") |
| 741 | RLSUTC=$(date -d "$(stat -c %z $RLSPATH)" -u +"%e %b %Y, %T %Z") |
| 742 | echo "Last repo sync: $RLSLOCAL / $RLSUTC" |
| 743 | } |
| 744 | |
| 745 | function reposync() { |
| 746 | case `uname -s` in |
| 747 | Darwin) |
| 748 | repo sync -j 4 "$@" |
| 749 | ;; |
| 750 | *) |
| 751 | schedtool -B -n 1 -e ionice -n 1 `which repo` sync -j 4 "$@" |
| 752 | ;; |
| 753 | esac |
| 754 | } |
| 755 | |
| 756 | function repodiff() { |
| 757 | if [ -z "$*" ]; then |
| 758 | echo "Usage: repodiff <ref-from> [[ref-to] [--numstat]]" |
| 759 | return |
| 760 | fi |
| 761 | diffopts=$* repo forall -c \ |
| 762 | 'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;' |
| 763 | } |
| 764 | |
| 765 | # Return success if adb is up and not in recovery |
| 766 | function _adb_connected { |
| 767 | { |
| 768 | if [[ "$(adb get-state)" == device && |
Marc K | 299137f | 2016-10-20 10:27:10 +0200 | [diff] [blame] | 769 | "$(adb shell test -e /sbin/recovery; echo $?)" != 0 ]] |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 770 | then |
| 771 | return 0 |
| 772 | fi |
| 773 | } 2>/dev/null |
| 774 | |
| 775 | return 1 |
| 776 | }; |
| 777 | |
| 778 | # Credit for color strip sed: http://goo.gl/BoIcm |
| 779 | function dopush() |
| 780 | { |
| 781 | local func=$1 |
| 782 | shift |
| 783 | |
| 784 | adb start-server # Prevent unexpected starting server message from adb get-state in the next line |
| 785 | if ! _adb_connected; then |
| 786 | echo "No device is online. Waiting for one..." |
| 787 | echo "Please connect USB and/or enable USB debugging" |
| 788 | until _adb_connected; do |
| 789 | sleep 1 |
| 790 | done |
| 791 | echo "Device Found." |
| 792 | fi |
| 793 | |
| 794 | if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" = "true" ]; |
| 795 | then |
| 796 | # retrieve IP and PORT info if we're using a TCP connection |
Marc K | 2be9cac | 2016-10-20 10:27:35 +0200 | [diff] [blame] | 797 | TCPIPPORT=$(adb devices \ |
| 798 | | egrep '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]):[0-9]+[^0-9]+' \ |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 799 | | head -1 | awk '{print $1}') |
| 800 | adb root &> /dev/null |
| 801 | sleep 0.3 |
| 802 | if [ -n "$TCPIPPORT" ] |
| 803 | then |
| 804 | # adb root just killed our connection |
| 805 | # so reconnect... |
| 806 | adb connect "$TCPIPPORT" |
| 807 | fi |
| 808 | adb wait-for-device &> /dev/null |
| 809 | sleep 0.3 |
| 810 | adb remount &> /dev/null |
| 811 | |
| 812 | mkdir -p $OUT |
| 813 | ($func $*|tee $OUT/.log;return ${PIPESTATUS[0]}) |
| 814 | ret=$?; |
| 815 | if [ $ret -ne 0 ]; then |
| 816 | rm -f $OUT/.log;return $ret |
| 817 | fi |
| 818 | |
Rashed Abdel-Tawab | 0180664 | 2017-01-19 15:52:13 -0500 | [diff] [blame] | 819 | is_gnu_sed=`sed --version | head -1 | grep -c GNU` |
| 820 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 821 | # Install: <file> |
Rashed Abdel-Tawab | 0180664 | 2017-01-19 15:52:13 -0500 | [diff] [blame] | 822 | if [ $is_gnu_sed -gt 0 ]; then |
Marc K | 97b035d | 2016-10-20 10:27:44 +0200 | [diff] [blame] | 823 | LOC="$(cat $OUT/.log | sed -r -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' -e 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \ |
| 824 | | grep '^Install: ' | cut -d ':' -f 2)" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 825 | else |
Marc K | 97b035d | 2016-10-20 10:27:44 +0200 | [diff] [blame] | 826 | LOC="$(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" -E "s/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//" \ |
| 827 | | grep '^Install: ' | cut -d ':' -f 2)" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 828 | fi |
| 829 | |
| 830 | # Copy: <file> |
Rashed Abdel-Tawab | 0180664 | 2017-01-19 15:52:13 -0500 | [diff] [blame] | 831 | if [ $is_gnu_sed -gt 0 ]; then |
Marc K | 97b035d | 2016-10-20 10:27:44 +0200 | [diff] [blame] | 832 | LOC="$LOC $(cat $OUT/.log | sed -r -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' -e 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \ |
| 833 | | grep '^Copy: ' | cut -d ':' -f 2)" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 834 | else |
Marc K | 97b035d | 2016-10-20 10:27:44 +0200 | [diff] [blame] | 835 | LOC="$LOC $(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" -E 's/^\[ {0,2}[0-9]{1,3}% [0-9]{1,6}\/[0-9]{1,6}\] +//' \ |
| 836 | | grep '^Copy: ' | cut -d ':' -f 2)" |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 837 | fi |
| 838 | |
| 839 | # If any files are going to /data, push an octal file permissions reader to device |
| 840 | if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then |
| 841 | CHKPERM="/data/local/tmp/chkfileperm.sh" |
| 842 | ( |
| 843 | cat <<'EOF' |
| 844 | #!/system/xbin/sh |
| 845 | FILE=$@ |
| 846 | if [ -e $FILE ]; then |
| 847 | ls -l $FILE | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' | cut -d ' ' -f1 |
| 848 | fi |
| 849 | EOF |
| 850 | ) > $OUT/.chkfileperm.sh |
| 851 | echo "Pushing file permissions checker to device" |
| 852 | adb push $OUT/.chkfileperm.sh $CHKPERM |
| 853 | adb shell chmod 755 $CHKPERM |
| 854 | rm -f $OUT/.chkfileperm.sh |
| 855 | fi |
| 856 | |
| 857 | stop_n_start=false |
| 858 | for FILE in $(echo $LOC | tr " " "\n"); do |
| 859 | # Make sure file is in $OUT/system or $OUT/data |
| 860 | case $FILE in |
| 861 | $OUT/system/*|$OUT/data/*) |
| 862 | # Get target file name (i.e. /system/bin/adb) |
| 863 | TARGET=$(echo $FILE | sed "s#$OUT##") |
| 864 | ;; |
| 865 | *) continue ;; |
| 866 | esac |
| 867 | |
| 868 | case $TARGET in |
| 869 | /data/*) |
| 870 | # fs_config only sets permissions and se labels for files pushed to /system |
| 871 | if [ -n "$CHKPERM" ]; then |
| 872 | OLDPERM=$(adb shell $CHKPERM $TARGET) |
| 873 | OLDPERM=$(echo $OLDPERM | tr -d '\r' | tr -d '\n') |
| 874 | OLDOWN=$(adb shell ls -al $TARGET | awk '{print $2}') |
| 875 | OLDGRP=$(adb shell ls -al $TARGET | awk '{print $3}') |
| 876 | fi |
| 877 | echo "Pushing: $TARGET" |
| 878 | adb push $FILE $TARGET |
| 879 | if [ -n "$OLDPERM" ]; then |
| 880 | echo "Setting file permissions: $OLDPERM, $OLDOWN":"$OLDGRP" |
| 881 | adb shell chown "$OLDOWN":"$OLDGRP" $TARGET |
| 882 | adb shell chmod "$OLDPERM" $TARGET |
| 883 | else |
| 884 | echo "$TARGET did not exist previously, you should set file permissions manually" |
| 885 | fi |
| 886 | adb shell restorecon "$TARGET" |
| 887 | ;; |
| 888 | /system/priv-app/SystemUI/SystemUI.apk|/system/framework/*) |
| 889 | # Only need to stop services once |
| 890 | if ! $stop_n_start; then |
| 891 | adb shell stop |
| 892 | stop_n_start=true |
| 893 | fi |
| 894 | echo "Pushing: $TARGET" |
| 895 | adb push $FILE $TARGET |
| 896 | ;; |
| 897 | *) |
| 898 | echo "Pushing: $TARGET" |
| 899 | adb push $FILE $TARGET |
| 900 | ;; |
| 901 | esac |
| 902 | done |
| 903 | if [ -n "$CHKPERM" ]; then |
| 904 | adb shell rm $CHKPERM |
| 905 | fi |
| 906 | if $stop_n_start; then |
| 907 | adb shell start |
| 908 | fi |
| 909 | rm -f $OUT/.log |
| 910 | return 0 |
| 911 | else |
| 912 | echo "The connected device does not appear to be $CM_BUILD, run away!" |
| 913 | fi |
| 914 | } |
| 915 | |
| 916 | alias mmp='dopush mm' |
| 917 | alias mmmp='dopush mmm' |
| 918 | alias mmap='dopush mma' |
Zhao Wei Liew | 64fc5ae | 2016-12-10 16:48:27 +0800 | [diff] [blame] | 919 | alias mmmap='dopush mmma' |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 920 | alias mkap='dopush mka' |
| 921 | alias cmkap='dopush cmka' |
| 922 | |
| 923 | function repopick() { |
| 924 | T=$(gettop) |
| 925 | $T/vendor/cm/build/tools/repopick.py $@ |
| 926 | } |
| 927 | |
| 928 | function fixup_common_out_dir() { |
| 929 | common_out_dir=$(get_build_var OUT_DIR)/target/common |
| 930 | target_device=$(get_build_var TARGET_DEVICE) |
| 931 | if [ ! -z $CM_FIXUP_COMMON_OUT ]; then |
| 932 | if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then |
| 933 | mv ${common_out_dir} ${common_out_dir}-${target_device} |
| 934 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 935 | else |
| 936 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 937 | mkdir -p ${common_out_dir}-${target_device} |
| 938 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 939 | fi |
| 940 | else |
| 941 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 942 | mkdir -p ${common_out_dir} |
| 943 | fi |
| 944 | } |
Steve Kondik | 26e669b | 2016-11-04 12:05:19 -0700 | [diff] [blame] | 945 | |
| 946 | # Enable SD-LLVM if available |
| 947 | if [ -d $(gettop)/prebuilts/snapdragon-llvm/toolchains ]; then |
Alexander Martinz | 1bbf3e9 | 2016-11-05 15:27:43 +0100 | [diff] [blame] | 948 | case `uname -s` in |
| 949 | Darwin) |
| 950 | # Darwin is not supported yet |
| 951 | ;; |
| 952 | *) |
| 953 | export SDCLANG=true |
| 954 | export SDCLANG_PATH=$(gettop)/prebuilts/snapdragon-llvm/toolchains/llvm-Snapdragon_LLVM_for_Android_3.8/prebuilt/linux-x86_64/bin |
| 955 | export SDCLANG_LTO_DEFS=$(gettop)/device/qcom/common/sdllvm-lto-defs.mk |
| 956 | ;; |
| 957 | esac |
Steve Kondik | 26e669b | 2016-11-04 12:05:19 -0700 | [diff] [blame] | 958 | fi |
Luca Stefani | 84fda60 | 2016-11-24 14:16:33 +0100 | [diff] [blame] | 959 | |
| 960 | # Android specific JACK args |
| 961 | if [ -n "$JACK_SERVER_VM_ARGUMENTS" ] && [ -z "$ANDROID_JACK_VM_ARGS" ]; then |
| 962 | export ANDROID_JACK_VM_ARGS=$JACK_SERVER_VM_ARGUMENTS |
| 963 | fi |