Merge "STT: Get disk size data from the stt build test" into main

This commit is contained in:
Treehugger Robot
2023-09-27 06:23:00 +00:00
committed by Gerrit Code Review

View File

@@ -21,7 +21,7 @@ usage() {
echo " -d DIST_OUT : Path for dist out"
echo " -a ALTER_TARGET: Alternative targets that share the build artifacts with the primary target"
echo " -c : Run the target build again after installclean for reference"
echo ' -o : Write build time results to "build_time_results.txt" file in "${OUT_DIR}" or "${DIST_OUT}/logs" if -d defined'
echo ' -o : Write build time ("build_time_results.txt") and disk usage results (disk_size_results.txt") to "${OUT_DIR}" or "${DIST_OUT}/logs" if -d defined'
echo " -r : Dryrun to see the commands without actually building the targets"
}
@@ -41,6 +41,7 @@ while getopts ha:cd:ort:v: opt; do
;;
o)
result_out="build_time_results.txt"
result_out_size="disk_size_results.txt"
;;
r)
dry_run="true"
@@ -94,34 +95,49 @@ run_command() {
fi
}
read_df() {
# read the available disk size
df . | awk '{print $4}' | sed -n '2p'
}
write_output() {
if [[ -z "${result_out}" || -n "${dry_run}" ]]; then
if [[ -z "$2" || -n "${dry_run}" ]]; then
echo "Output: $1"
else
echo "$1" >> "${out_dir}/${result_out}"
echo "$1" >> "${out_dir}/$2"
fi
}
get_build_trace() {
run_command "cp -f ${out_dir}/build.trace.gz ${out_dir}/${1}"
if [[ -n "${result_out}" ]]; then
write_output "$(python3 development/treble/read_build_trace_gz.py ${out_dir}/${1})"
write_output "$(python3 development/treble/read_build_trace_gz.py ${out_dir}/${1})" "${result_out}"
fi
}
if [[ -n "${result_out}" ]]; then
run_command "rm -f ${out_dir}/${result_out}"
write_output "target, soong, kati, ninja, total"
write_output "target, soong, kati, ninja, total" "${result_out}"
fi
if [[ -n "${result_out_size}" ]]; then
run_command "rm -f ${out_dir}/${result_out_size}"
write_output "target, size, size_after_clean" "${result_out_size}"
fi
# Build the target first.
disk_space_source=$(read_df)
echo; echo "Initial build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} ${goals}"
size_primary=$((${disk_space_source}-$(read_df)))
if [[ -n "${installclean}" ]]; then
# Run the same build after installclean
echo; echo "Installclean for incremental build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} installclean"
size_primary_clean=$((${disk_space_source}-$(read_df)))
write_output "${target}, ${size_primary}, ${size_primary_clean}" "${result_out_size}"
echo "Build the same initial build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}"
get_build_trace "build_${target}_installclean.trace.gz"
@@ -135,10 +151,13 @@ for alter_target in "${alter_targets[@]}"; do
count=$((${count}+1))
echo; echo "Build ${alter_target}...(${count})"
run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}"
size_alter=$((${disk_space_source}-$(read_df)))
get_build_trace "build_${alter_target}_ab${count}.trace.gz"
echo "Installclean for ${alter_target}..."
run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} installclean"
size_alter_clean=$((${disk_space_source}-$(read_df)))
write_output "${alter_target}, ${size_alter}, ${size_alter_clean}" "${result_out_size}"
if [[ -n "${dist_dir}" ]]; then
# Remove target-specific dist artifacts