summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile67
-rw-r--r--test/integration/helper.bash8
2 files changed, 31 insertions, 44 deletions
diff --git a/Makefile b/Makefile
index a843bdd4..afa708ac 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+.DEFAULT_GOAL = build
extension = $(patsubst windows,.exe,$(filter windows,$(1)))
GO := go
PKG_NAME := gomplate
@@ -9,17 +10,11 @@ VERSION ?= `git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1)
COMMIT_FLAG := -X `go list ./version`.GitCommit=$(COMMIT)
VERSION_FLAG := -X `go list ./version`.Version=$(VERSION)
-GOOS ?= `go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/'`
-GOARCH ?= `go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/'`
+GOOS ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/')
+GOARCH ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/')
platforms := linux-amd64 linux-386 linux-arm linux-arm64 darwin-amd64 solaris-amd64 windows-amd64.exe windows-386.exe
-
-define gocross
- GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 \
- $(GO) build \
- -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
- -o $(PREFIX)/bin/$(PKG_NAME)_$(1)-$(2)$(call extension,$(1));
-endef
+compressed-platforms := linux-amd64-slim linux-arm-slim linux-arm64-slim darwin-amd64-slim windows-amd64-slim.exe
define gocross-tool
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 \
@@ -29,11 +24,6 @@ define gocross-tool
$(PREFIX)/test/integration/$(3)svc;
endef
-define compress
- upx --lzma $(PREFIX)/bin/$(PKG_NAME)_$(1)-$(2)$(call extension,$(1)) \
- -o $(PREFIX)/bin/$(PKG_NAME)_$(1)-$(2)-slim$(call extension,$(1))
-endef
-
clean:
rm -Rf $(PREFIX)/bin/*
rm -f $(PREFIX)/test/integration/gomplate
@@ -43,52 +33,45 @@ clean:
build-x: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(platforms))
-compress-all:
- $(call compress,linux,amd64)
- $(call compress,linux,arm)
- $(call compress,windows,amd64)
+compress-all: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(compressed-platforms))
-compress: build
- @upx --lzma $(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)) \
- -o $(PREFIX)/bin/$(PKG_NAME)-slim$(call extension,$(GOOS))
+$(PREFIX)/bin/$(PKG_NAME)_%-slim: $(PREFIX)/bin/$(PKG_NAME)_%
+ upx --lzma $< -o $@
-build-release: clean build-x compress-all
+$(PREFIX)/bin/$(PKG_NAME)_%-slim.exe: $(PREFIX)/bin/$(PKG_NAME)_%.exe
+ upx --lzma $< -o $@
-$(PREFIX)/bin/$(PKG_NAME)_%: $(shell find $(PREFIX) -type f -name '*.go' -not -path "$(PREFIX)/test/*")
- $(call gocross,$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\1/'),$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\2/'))
-
-$(PREFIX)/bin/mirror_%: $(shell find $(PREFIX)/test/integration/mirrorsvc -type f -name '*.go')
- $(call gocross-tool,$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\1/'),$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\2/'),mirror)
+compress: $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)-slim$(call extension,$(GOOS))
+ cp $< $(PREFIX)/bin/$(PKG_NAME)-slim$(call extension,$(GOOS))
-$(PREFIX)/bin/meta_%: $(shell find $(PREFIX)/test/integration/metasvc -type f -name '*.go')
- $(call gocross-tool,$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\1/'),$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\2/'),meta)
-
-$(PREFIX)/bin/aws_%: $(shell find $(PREFIX)/test/integration/awssvc -type f -name '*.go')
- $(call gocross-tool,$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\1/'),$(shell echo $* | sed 's/\([^-]*\)-\([^.]*\).*/\2/'),aws)
+$(PREFIX)/bin/$(PKG_NAME)_%: $(shell find $(PREFIX) -type f -name '*.go' -not -path "$(PREFIX)/test/*")
+ GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- | cut -f1 -d.) CGO_ENABLED=0 \
+ $(GO) build \
+ -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
+ -o $@
-$(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name '*.go' -not -path "$(PREFIX)/test/*")
- CGO_ENABLED=0 \
- $(GO) build -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" -o $@
+$(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)): $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)$(call extension,$(GOOS))
+ cp $< $@
-$(PREFIX)/bin/mirror$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/mirrorsvc -type f -name '*.go')
+$(PREFIX)/test/integration/mirror$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/mirrorsvc -type f -name '*.go')
CGO_ENABLED=0 \
$(GO) build -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" -o $@ $(PREFIX)/test/integration/mirrorsvc
-$(PREFIX)/bin/meta$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/metasvc -type f -name '*.go')
+$(PREFIX)/test/integration/meta$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/metasvc -type f -name '*.go')
CGO_ENABLED=0 \
$(GO) build -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" -o $@ $(PREFIX)/test/integration/metasvc
-$(PREFIX)/bin/aws$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/awssvc -type f -name '*.go')
+$(PREFIX)/test/integration/aws$(call extension,$(GOOS)): $(shell find $(PREFIX)/test/integration/awssvc -type f -name '*.go')
CGO_ENABLED=0 \
$(GO) build -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" -o $@ $(PREFIX)/test/integration/awssvc
build: $(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS))
-build-mirror: $(PREFIX)/bin/mirror$(call extension,$(GOOS))
+build-mirror: $(PREFIX)/test/integration/mirror$(call extension,$(GOOS))
-build-meta: $(PREFIX)/bin/meta$(call extension,$(GOOS))
+build-meta: $(PREFIX)/test/integration/meta$(call extension,$(GOOS))
-build-aws: $(PREFIX)/bin/aws$(call extension,$(GOOS))
+build-aws: $(PREFIX)/test/integration/aws$(call extension,$(GOOS))
test:
$(GO) test -v -race ./...
@@ -130,3 +113,5 @@ lint:
endif
.PHONY: gen-changelog clean test build-x compress-all build-release build build-integration-image test-integration-docker gen-docs lint
+.DELETE_ON_ERROR:
+.SECONDARY:
diff --git a/test/integration/helper.bash b/test/integration/helper.bash
index 39c30fe6..5ae28e16 100644
--- a/test/integration/helper.bash
+++ b/test/integration/helper.bash
@@ -1,5 +1,7 @@
#!/bin/bash
+helper_dir=${BASH_SOURCE%/*}
+
function gomplate () {
run bin/gomplate "$@"
@@ -27,7 +29,7 @@ function __gomplate_stdin () {
}
function start_mirror_svc () {
- bin/mirror &
+ ${helper_dir}/mirror &
wait_for_url http://127.0.0.1:8080/
}
@@ -36,7 +38,7 @@ function stop_mirror_svc () {
}
function start_meta_svc () {
- bin/meta &> /tmp/meta.log &
+ ${helper_dir}/meta &> /tmp/meta.log &
wait_for_url http://127.0.0.1:8081/
}
@@ -45,7 +47,7 @@ function stop_meta_svc () {
}
function start_aws_svc () {
- bin/aws &
+ ${helper_dir}/aws &
wait_for_url http://127.0.0.1:8082/
}