blob: b8ce7f66b916e0d420a3d53486230ea27b98eb9e [file] [log] [blame] [edit]
#!/bin/bash
# Licensed under the Apache-2.0 license
# SPDX-License-Identifier: Apache-2.0
# This is a light wrapper script to seamlessly run the //:pw tool while
# forwarding arguments. This is written as a shell script for three reasons:
#
# 1. `./pw` is significantly shorter than `bazelisk run --config=foo //:pw`.
# 2. .bazelrc configs cannot express multiple portions of this wrapper:
# a. Startup flags in a --config are ignored.
# b. The double-dash separator cannot be correctly expressed in a --config.
# 3. There's no way to ask Bazel to be verbose on the first clean build, and
# as quiet as possible on subsequent runs.
# Print a message that indicates the pw tool might take a few seconds to load.
if [ -t 1 ]; then
printf " ⏱ Initializing pw tool...\r"
fi
# Don't generate compile commands from this action. Note that since we're
# using bazelisk, `BAZEL_WRAPPER` is NOT respected.
export BAZELISK_SKIP_WRAPPER=1
declare -r _PW_SCRIPT_DIR=$(realpath $(dirname $0))
declare -r _PW_WORKFLOWS_OUT_DIR=${_PW_SCRIPT_DIR}/out/workflows_launcher
declare -r _PW_WORKFLOWS_BIN_PATH=${_PW_WORKFLOWS_OUT_DIR}/bazel-bin/pw.exe
# If the `pw` tool hasn't been built yet, don't silence output since it might
# take a long time.
if [ -f "$_PW_WORKFLOWS_BIN_PATH" ]; then
declare -r _PW_WORKFLOWS_QUIET=--quiet
else
declare -r _PW_WORKFLOWS_QUIET
fi
bazelisk \
${_PW_WORKFLOWS_QUIET} \
--output_base=${_PW_WORKFLOWS_OUT_DIR} \
run \
--symlink_prefix=${_PW_WORKFLOWS_OUT_DIR}/bazel- \
--show_result=0 \
//:pw -- "$@"