Skip to content

Commit

Permalink
Build only when files get changed
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed Feb 13, 2019
1 parent b2a45e5 commit ffabbae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ IMAGE_NAME := mysql-operator
SIDECAR_IMAGE_NAME := mysql-operator-sidecar
BUILD_TAG := build
IMAGE_TAGS := $(APP_VERSION)
PKG_NAME := github.com/presslabs/mysql-operator

BINDIR := bin
BINDIR := $(PWD)/bin
KUBEBUILDER_VERSION ?= 1.0.7
HELM_VERSION ?= 2.11.0

Expand Down Expand Up @@ -33,9 +34,14 @@ build: generate fmt vet
go build -o bin/mysql-operator github.com/presslabs/mysql-operator/cmd/mysql-operator
go build -o bin/mysql-operator-sidecar github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar

skaffold-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o $(BINDIR)/mysql-operator_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o $(BINDIR)/mysql-operator-sidecar_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar
bin/mysql-operator_linux_amd64: $(shell hack/development/related-go-files.sh $(PKG_NAME) cmd/mysql-operator/main.go)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/mysql-operator_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator

bin/mysql-operator-sidecar_linux_amd64: $(shell hack/development/related-go-files.sh $(PKG_NAME) cmd/mysql-operator-sidecar/main.go)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/mysql-operator-sidecar_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar

skaffold-run: bin/mysql-operator_linux_amd64 bin/mysql-operator-sidecar_linux_amd64
skaffold run

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
Expand Down
5 changes: 5 additions & 0 deletions hack/development/related-go-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

# This command outputs a list of go files on which the given go file depends on
go list -f '{{ join .Deps "\n" }}' $2 | grep 'pkg' | grep -v 'vendor' | sed -e "s|^$1/||" | xargs -I % find % -name "*.go" -maxdepth 1 -type f 2>/dev/null

0 comments on commit ffabbae

Please sign in to comment.