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