| Ryan Prichard | 41f1970 | 2019-12-23 13:21:42 -0800 | [diff] [blame] | 1 | #!/bin/bash -e | 
 | 2 | # | 
 | 3 | # Copyright (C) 2019 The Android Open Source Project | 
 | 4 | # All rights reserved. | 
 | 5 | # | 
 | 6 | # Redistribution and use in source and binary forms, with or without | 
 | 7 | # modification, are permitted provided that the following conditions | 
 | 8 | # are met: | 
 | 9 | #  * Redistributions of source code must retain the above copyright | 
 | 10 | #    notice, this list of conditions and the following disclaimer. | 
 | 11 | #  * Redistributions in binary form must reproduce the above copyright | 
 | 12 | #    notice, this list of conditions and the following disclaimer in | 
 | 13 | #    the documentation and/or other materials provided with the | 
 | 14 | #    distribution. | 
 | 15 | # | 
 | 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
 | 17 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
 | 18 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 
 | 19 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 
 | 20 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | 
 | 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 
 | 22 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | 
 | 23 | # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 
 | 24 | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
 | 25 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | 
 | 26 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
 | 27 | # SUCH DAMAGE. | 
 | 28 |  | 
 | 29 | top=$(cd $(dirname $0) && pwd) | 
 | 30 |  | 
 | 31 | bid=6079926 | 
 | 32 |  | 
 | 33 | keep_tmp_dir=0 | 
 | 34 | skip_gen_bench=0 | 
 | 35 | for arg in "$@"; do | 
 | 36 |   case "$arg" in | 
 | 37 |     --keep-tmp-dir) | 
 | 38 |       keep_tmp_dir=1 | 
 | 39 |       ;; | 
 | 40 |     --skip-gen-bench) | 
 | 41 |       skip_gen_bench=1 | 
 | 42 |       ;; | 
 | 43 |     *) | 
 | 44 |       echo "error: unrecognized option: $arg" | 
 | 45 |       exit 1 | 
 | 46 |       ;; | 
 | 47 |   esac | 
 | 48 | done | 
 | 49 |  | 
 | 50 | work_dir=$top/tmp | 
 | 51 | mkdir -p $work_dir | 
 | 52 | cd $work_dir | 
 | 53 |  | 
 | 54 | archive=aosp_arm64-target_files-$bid.zip | 
 | 55 | if [ ! -f $archive ]; then | 
 | 56 |   /google/data/ro/projects/android/fetch_artifact --bid $bid --target aosp_arm64-userdebug $archive | 
 | 57 | fi | 
 | 58 | if [ -e SYSTEM ]; then | 
 | 59 |   rm -rf SYSTEM | 
 | 60 | fi | 
 | 61 |  | 
 | 62 | echo 'Unzipping system files...' | 
 | 63 | unzip -q $archive \ | 
 | 64 |   'SYSTEM/system_ext/apex/com.android.art.debug/*' \ | 
 | 65 |   'SYSTEM/system_ext/apex/com.android.runtime/*' \ | 
 | 66 |   'SYSTEM/lib64/*' | 
 | 67 |  | 
 | 68 | echo 'Dumping relocations...' | 
 | 69 | python3 -B $top/regen/dump_relocs.py \ | 
 | 70 |   -L $work_dir/SYSTEM/system_ext/apex/com.android.art.debug/lib64 \ | 
 | 71 |   -L $work_dir/SYSTEM/system_ext/apex/com.android.runtime/lib64/bionic \ | 
 | 72 |   -L $work_dir/SYSTEM/lib64 \ | 
 | 73 |   $work_dir/SYSTEM/lib64/libandroid_servers.so \ | 
 | 74 |   $work_dir/libandroid_servers_arm64.json | 
 | 75 |  | 
 | 76 | if [ $skip_gen_bench -eq 0 ]; then | 
 | 77 |   echo 'Generating benchmark...' | 
 | 78 |   python3 -B $top/regen/gen_bench.py $work_dir/libandroid_servers_arm64.json $top/gen | 
 | 79 | fi | 
 | 80 |  | 
 | 81 | if [ $keep_tmp_dir -eq 0 ]; then | 
 | 82 |   rm -rf $work_dir | 
 | 83 | fi |