1#!/bin/bash 2# Copyright (C) 2024 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# Script to collect the ravenwood "stats" CVS files and create a single file. 17 18set -e 19 20# Output files 21out_dir=/tmp/ravenwood 22stats=$out_dir/ravenwood-stats-all.csv 23apis=$out_dir/ravenwood-apis-all.csv 24keep_all_dir=$out_dir/ravenwood-keep-all/ 25dump_dir=$out_dir/ravenwood-dump/ 26 27rm -fr $out_dir 28mkdir -p $out_dir 29mkdir -p $keep_all_dir 30mkdir -p $dump_dir 31 32# Where the input files are. 33path=$ANDROID_BUILD_TOP/out/host/linux-x86/testcases/ravenwood-stats-checker/x86_64/ 34 35timestamp="$(date --iso-8601=seconds)" 36 37m() { 38 ${ANDROID_BUILD_TOP}/build/soong/soong_ui.bash --make-mode "$@" 39} 40 41# Building this will generate the files we need. 42m ravenwood-stats-checker 43 44# Start... 45 46cd $path 47 48dump() { 49 local jar=$1 50 local file=$2 51 52 # Remove the header row, and prepend the columns. 53 sed -e '1d' -e "s/^/$jar,$timestamp,/" $file 54} 55 56collect_stats() { 57 local out="$1" 58 { 59 # Copy the header, with the first column appended. 60 echo -n "Jar,Generated Date," 61 head -n 1 hoststubgen_framework-minus-apex_stats.csv 62 63 dump "framework-minus-apex" hoststubgen_framework-minus-apex_stats.csv 64 dump "service.core" hoststubgen_services.core_stats.csv 65 dump "framework-configinfrastructure" framework-configinfrastructure_stats.csv 66 dump "framework-statsd" framework-statsd_stats.csv 67 } > "$out" 68 69 echo "Stats CVS created at $out" 70} 71 72collect_apis() { 73 local out="$1" 74 { 75 # Copy the header, with the first column appended. 76 echo -n "Jar,Generated Date," 77 head -n 1 hoststubgen_framework-minus-apex_apis.csv 78 79 dump "framework-minus-apex" hoststubgen_framework-minus-apex_apis.csv 80 dump "service.core" hoststubgen_services.core_apis.csv 81 dump "framework-configinfrastructure" framework-configinfrastructure_apis.csv 82 dump "framework-statsd" framework-statsd_apis.csv 83 } > "$out" 84 85 echo "API CVS created at $out" 86} 87 88 89collect_stats $stats 90collect_apis $apis 91 92cp *keep_all.txt $keep_all_dir 93echo "Keep all files created at:" 94find $keep_all_dir -type f 95 96cp *dump.txt $dump_dir 97echo "Dump files created at:" 98find $dump_dir -type f