diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a6db7b0fc..77a27bdd06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,6 @@ jobs: steps: - checkout - run: scripts/build.sh - - run: scripts/build_tools.sh - setup_remote_docker - run: scripts/build_docker.sh - run: mkdir build_docker @@ -37,7 +36,7 @@ jobs: - run: scripts/qa/go-generate.sh - run: scripts/qa/ineffassign.sh - run: scripts/qa/misspell.sh - - run: scripts/qa/tools_gitignore.sh + - run: scripts/qa/gitignore.sh - run: scripts/qa/unused.sh - run: scripts/qa/vendor.sh diff --git a/.gitignore b/.gitignore index 99664845ce..da24058ab6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .*.sw? .notouch build/ -/metrictank +/cmd/metrictank/metrictank /cmd/mt-aggs-explain/mt-aggs-explain /cmd/mt-explain/mt-explain /cmd/mt-index-cat/mt-index-cat diff --git a/Makefile b/Makefile index 32f477a5db..5499ac0176 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,8 @@ check: $(MAKE) test bin: ./scripts/build.sh - ./scripts/build_tools.sh bin-race: ./scripts/build.sh -race - ./scripts/build_tools.sh -race docker: ./scripts/build_docker.sh all: diff --git a/metrictank.go b/cmd/metrictank/metrictank.go similarity index 100% rename from metrictank.go rename to cmd/metrictank/metrictank.go diff --git a/scripts/build.sh b/scripts/build.sh index d62d8115b0..205c26a8a4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,7 +2,6 @@ set -e - # Find the directory we exist within DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) cd ${DIR}/.. @@ -24,13 +23,23 @@ rm -rf $BUILDDIR/* # disable cgo export CGO_ENABLED=0 -OUTPUT=$BUILDDIR/metrictank - -if [ "$1" == "-race" ] -then - set -x - go build -race -ldflags "-X main.gitHash=$GITVERSION" -o $OUTPUT -else - set -x - go build -ldflags "-X main.gitHash=$GITVERSION" -o $OUTPUT -fi +function fail () { + echo "Aborting due to failure." >&2 + exit 2 +} + +# Build binary +cd cmd +for bin in *; do + cd $bin + if [ "$1" == "-race" ] + then + set -x + CGO_ENABLED=1 go build -race -ldflags "-X main.gitHash=$GITVERSION" -o $BUILDDIR/$bin || fail + else + set -x + go build -ldflags "-X main.gitHash=$GITVERSION" -o $BUILDDIR/$bin || fail + fi + set +x + cd .. +done diff --git a/scripts/build_tools.sh b/scripts/build_tools.sh deleted file mode 100755 index 56093e3a8a..0000000000 --- a/scripts/build_tools.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# Find the directory we exist within -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -cd ${DIR}/.. - -GITVERSION=`git describe --abbrev=7` -BUILDDIR=$(pwd)/build - -# Make dir -mkdir -p $BUILDDIR - -# disable cgo -export CGO_ENABLED=0 - -function fail () { - echo "Aborting due to failure." >&2 - exit 2 -} - -# Build binary -cd cmd -for tool in *; do - cd $tool - if [ "$1" == "-race" ] - then - set -x - CGO_ENABLED=1 go build -race -ldflags "-X main.gitHash=$GITVERSION" -o $BUILDDIR/$tool || fail - else - set -x - go build -ldflags "-X main.gitHash=$GITVERSION" -o $BUILDDIR/$tool || fail - fi - set +x - cd .. -done diff --git a/scripts/qa/tools_gitignore.sh b/scripts/qa/gitignore.sh similarity index 83% rename from scripts/qa/tools_gitignore.sh rename to scripts/qa/gitignore.sh index 34fa3d46be..5f39a4ff62 100755 --- a/scripts/qa/tools_gitignore.sh +++ b/scripts/qa/gitignore.sh @@ -7,8 +7,8 @@ file=../.gitignore # NOTE: known limitation: does not clean up stale gitignore rules declare -a missing -for tool in *; do - rule="/cmd/$tool/$tool" +for bin in *; do + rule="/cmd/$bin/$bin" grep -q "^$rule$" $file || missing=("${missing[@]}" "$rule") done @@ -20,4 +20,4 @@ if [ ${#missing[@]} -gt 0 ]; then exit 2 fi -echo "gitignore rules for all tools found" +echo "gitignore rules for all binaries found"