Files
scylladb/scripts/refresh-pgo-profiles.sh
Avi Kivity cf72c31617 treewide: improve bash error reporting
bash error handling and reporting is atrocious. Without -e it will
just ignore errors. With -e it will stop on errors, but not report
where the error happened (apart from exiting itself with an error code).

Improve that with the `trap ERR` command. Note that this won't be invoked
on intentional error exit with `exit 1`.

We apply this on every bash script that contains -e or that it appears
trivial to set it in. Non-trivial scripts without -e are left unmodified,
since they might intentionally invoke failing scripts.

Closes scylladb/scylladb#22747
2025-02-10 18:28:52 +03:00

34 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (C) 2023-present ScyllaDB
#
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
set -eu
trap 'echo "error $? in $0 line $LINENO"' ERR
SCRIPT_PATH="$(realpath "$0")"
PROJECT_BASE="$(realpath "$(dirname "$0")"/..)"
WORKING_DIR="$(realpath "$PWD")"
if [ "$PROJECT_BASE" != "$WORKING_DIR" ]; then
echo "Error: $SCRIPT_PATH should be ran with $PROJECT_BASE instead of $WORKING_DIR as the working directory" >&2
exit 1
fi
BUILD_PATH=build/release-cs-pgo/profiles/merged.profdata
TARGET_PATH=pgo/profiles/$(uname -m)/profile.profdata.xz
./configure.py --mode=release --pgo --cspgo --use-profile=
# ninja "$BUILD_PATH" would avoid a build step, but let's do it voluntarily
# to check that the profile doesn't cause any compilation problems.
ninja build/release/scylla
# Profiles are stored in version control, so we want very strong compression.
mkdir -p "$(dirname "$TARGET_PATH")"
xz --compress -9 --stdout "$BUILD_PATH" >"$TARGET_PATH"
echo "Profile $TARGET_PATH regenerated. You can now stage, commit, and push it."