Skip to content

Instantly share code, notes, and snippets.

@andreubotella
Created February 19, 2022 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreubotella/df073caa26ccf8c504ff470c999de8c2 to your computer and use it in GitHub Desktop.
Save andreubotella/df073caa26ccf8c504ff470c999de8c2 to your computer and use it in GitHub Desktop.
My Chromium virtualenv (note: needs goma)
#!/bin/bash
# If this file isn't being run as a source, source it.
if (return 0 2>/dev/null); then
deactivate () {
goma_ctl ensure_stop
export PATH="$OLD_PATH"
unset OLD_PATH
export PS1="$OLD_PS1"
unset OLD_PS1
unset -f deactivate
unset -f build
unset -f build_important
}
build () {
NINJA_BUILD_IN_BACKGROUND=1
DEFAULT_NUM_JOBS=5000
NUM_JOBS=0
BUILD_DIR=out/Default
while true; do
case $1 in
-h|--help)
echo "build [--important] [-C <build_dir>] [<build_targets>...]"
exit 0
;;
--important)
NINJA_BUILD_IN_BACKGROUND=0
DEFAULT_NUM_JOBS=5000
shift
continue
;;
-C)
shift
if [[ $1 == "" ]]; then
echo "build [--important] [-C <build_dir>] [<build_targets>...]"
exit 0
fi
if [[ $1 == */* ]]; then
BUILD_DIR="$1"
else
BUILD_DIR="out/$1"
fi
shift
continue
;;
-j)
shift
if [[ $1 == "" ]]; then
echo "build [--important] [-C <build_dir>] [<build_targets>...]"
exit 0
fi
NUM_JOBS="$1"
shift
continue
;;
*)
break
;;
esac
done
if (( $NUM_JOBS <= 0 )); then
NUM_JOBS="$DEFAULT_NUM_JOBS"
fi
declare -a ARGS
for arg in "$@"; do
if [[ "$arg" == "chromium" ]]; then
arg="chrome"
fi
ARGS+=("$arg")
don
if (( "${#ARGS[*]}" == 0 )); then
ARGS+=("blink_tests")
fi
echo NINJA_BUILD_IN_BACKGROUND="${NINJA_BUILD_IN_BACKGROUND}" autoninja -C "$BUILD_DIR" -j "$NUM_JOBS" "${ARGS[@]}"
NINJA_BUILD_IN_BACKGROUND="${NINJA_BUILD_IN_BACKGROUND}" autoninja -C "$BUILD_DIR" -j "$NUM_JOBS" "${ARGS[@]}"
if (( $? == 0 )); then
notify-send "Chromium build finished!"
else
notify-send "Chromium build failed!"
fi
}
build_important () {
build --important $@
}
OLD_PS1="$PS1"
export PS1="[CHROMIUM - \u@\h \W]\\$ "
OLD_PATH="$PATH"
export PATH="$(realpath "$(dirname "${BASH_SOURCE[0]}")/.path"):$PATH:$(realpath "$(dirname "${BASH_SOURCE[0]}")/../depot_tools"):$(realpath "$(dirname "${BASH_SOURCE[0]}")/src/third_party/blink/tools")"
goma_ctl ensure_start
else
echo "Please run \". '${0}'\" instead."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment