From 15f8285c57ee68918026d37cfebe8fdf74e9b3f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Mau Date: Mon, 29 Jan 2018 17:27:56 +0100 Subject: [PATCH] crosscompile added with make --- .gitignore | 1 + .travis.yml | 3 ++- Makefile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 53baed59..f53f6b57 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ coverage.out # Build artifacts k8s-oidc-helper +build/ # Architecture specific extensions/prefixes *.[568vq] diff --git a/.travis.yml b/.travis.yml index 516701be..35c67357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ before_install: - go get -u github.com/golang/lint/golint script: -- go build -i - go test ./... - go test -race ./... +- make + diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2c1d3d37 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +SHELL := /bin/bash + +# The destination for binaries +BUILD_DIR = build + +# The name of the executable (default is current directory name) +TARGET := $(shell echo $${PWD\#\#*/}) +.DEFAULT_GOAL: $(TARGET) + +# These will be provided to the target +VERSION :=0.9.0-rc1 +BUILD := `git rev-parse HEAD` + +# Use linker flags to provide version/build settings to the target +LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)" + +# go source files, ignore vendor directory +SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*") + +.PHONY: all build clean install uninstall fmt simplify check run + +all: check compile + +$(TARGET): $(SRC) + @go build $(LDFLAGS) -o $(TARGET) + +compile: check goxcompile + +goxcompile: export CGO_ENABLED=0 +goxcompile: dependencies + gox -arch amd64 -os darwin -os linux -os windows -output "$(BUILD_DIR)/{{.OS}}/$(NAME)/${TARGET}" . + +clean: + @rm -f $(TARGET) + @rm -rf $(BUILD_DIR) + +install: dependencies + @go install $(LDFLAGS) + +uninstall: clean + @rm -f $$(which ${TARGET}) + +fmt: + @gofmt -l -w $(SRC) + +simplify: + @gofmt -s -l -w $(SRC) + +check: dependencies + @test -z $(shell gofmt -l *.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'" + @for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done + @go tool vet ${SRC} + +run: install + @$(TARGET) + +dependencies: + go get github.com/mitchellh/gox + go get github.com/jstemmer/go-junit-report + go get github.com/golang/lint/golint + git submodule update --init --recursive \ No newline at end of file