From 4a7032aff44ad618b1481c5deb0a59f99fd824b0 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Tue, 3 Nov 2020 20:47:16 +0000 Subject: [PATCH] add some bin tools --- bin/bazel-in-bear | 4 ++++ bin/move_bazel_rule.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 bin/bazel-in-bear create mode 100755 bin/move_bazel_rule.sh diff --git a/bin/bazel-in-bear b/bin/bazel-in-bear new file mode 100755 index 0000000..1fd0873 --- /dev/null +++ b/bin/bazel-in-bear @@ -0,0 +1,4 @@ +#!/bin/sh +LIB=lib/x86_64-linux-gnu +export LD_PRELOAD=$(eval "echo ${LD_PRELOAD}") +bazel --batch "$@" --action_env=LD_PRELOAD=${LD_PRELOAD} --action_env=BEAR_OUTPUT=${BEAR_OUTPUT} --spawn_strategy=local diff --git a/bin/move_bazel_rule.sh b/bin/move_bazel_rule.sh new file mode 100755 index 0000000..f852922 --- /dev/null +++ b/bin/move_bazel_rule.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +if [ -z "$1" ]; then + cat << EOF +Usages: + $0 NEW_BAZEL_FILE + Search for BUILD targets with these names in the git repo + $0 NEW_BAZEL_FILE FIXUP_BAZEL_FILE + Find instances of the BUILD targets in the to-be-fixed-file + $0 NEW_BAZEL_FILE FIXUP_BAZEL_FILE PREFIX + Find instances of that BUILD target with an old prefix (eg: '//:') + $0 NEW_BAZEL_FILE FIXUP_BAZEL_FILE PREFIX NEW_PREFIX + Apply the NEW_PREFIX (eg, a package move) in place of the PREFIX in the FIXUP file. +EOF + exit +fi +INCOMING_SET=$(grep "name" $1 | cut -d '"' -f 2) +TO_CHANGE=$2 +PREVIOUS_PATH=$3 +NEW_PATH=$4 + +for TARGET in $INCOMING_SET; do + if [ -n "$TO_CHANGE" ]; then + grep ${PREVIOUS_PATH}${TARGET} $TO_CHANGE + if [ -n "$NEW_PATH" ]; then + sed -i "s^${PREVIOUS_PATH}${TARGET}^${NEW_PATH}${TARGET}^g" $TO_CHANGE + fi + else + git grep ${TARGET} + fi + +done