cefd2dab7a
* add script for tooling * add to make * not to forget * reworked go tools * add tool installation script * adding readme * updating readme * updating readme * cleanup install.sh and makefile * update the readme file * cleanup scripts * switch variables.mk to lazy evaluation * add tools ache to gitignore * get rid of absolute path in hte Variables.mk file * switch to reusable function for path generation * add debug statements * add create cache tool dir * add debuig statements to make file * drop tool cache * fix race condition n ci * fix race condition n ci * cleanup workspace * add lefthook.rc to codeowners * copy .citools folder to docker image * switch back to main branch of grafana-build * Add .citools to the drone builder * fix wording in generate.sh and README.md
37 lines
917 B
Bash
Executable File
37 lines
917 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
TOOLS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
TOOLS_SRC_DIR="$TOOLS_DIR/src"
|
|
TOOLS_MK="$TOOLS_DIR/Variables.mk"
|
|
|
|
echo "# Generated tool paths" > "$TOOLS_MK"
|
|
|
|
cat <<'EOL' >> "$TOOLS_MK"
|
|
tools_dir := $(shell cd $(dir $(lastword $(MAKEFILE_LIST))) && pwd)
|
|
src_dir := $(tools_dir)/src
|
|
|
|
# Due to a race condition, after initial call to `go tool` golang may report a wrong binary location pointing to the invalid `/tmp/go-buildXXX` directory
|
|
define compile_tool
|
|
$(shell \
|
|
(cd $(src_dir)/$(1) \
|
|
&& GOWORK=off go tool -n $(2) > /dev/null \
|
|
&& GOWORK=off go tool -n $(2)) | sed 's/^[[:space:]]*//g'; \
|
|
)
|
|
endef
|
|
|
|
EOL
|
|
|
|
for tooldir in "$TOOLS_SRC_DIR"/*; do
|
|
[ -d "$tooldir" ] || continue
|
|
tool=$(basename "$tooldir")
|
|
fqtn=$(awk '/^tool / { print $2 }' "$tooldir/go.mod")
|
|
|
|
cat <<EOL >> "$TOOLS_MK"
|
|
|
|
# Tool: "$tool"
|
|
${tool} = "\$(call compile_tool,${tool},${fqtn})"
|
|
EOL
|
|
done
|