Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
crosscompile added with make
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangMau committed Jan 29, 2018
1 parent 6f93801 commit 15f8285
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coverage.out

# Build artifacts
k8s-oidc-helper
build/

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ before_install:
- go get -u github.com/golang/lint/golint

script:
- go build -i
- go test ./...
- go test -race ./...
- make

61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 15f8285

Please sign in to comment.