Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back 'make local' #711

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ PKG := github.com/heptio/ark
REGISTRY ?= gcr.io/heptio-images

# Which architecture to build - see $(ALL_ARCH) for options.
# if the 'local' rule is being run, detect the ARCH from 'go env'
# if it wasn't specified by the caller.
local : ARCH ?= $(shell go env GOOS)-$(shell go env GOARCH)
ARCH ?= linux-amd64

VERSION ?= master
Expand Down Expand Up @@ -79,6 +82,15 @@ all-build: $(addprefix build-, $(CLI_PLATFORMS))

#all-push: $(addprefix push-, $(CONTAINER_PLATFORMS))

local: build-dirs
GOOS=$(GOOS) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can omit specifying all the variables that are unmodified and make should pass them through when executing build.sh. That would leave OUTPUT_DIR as the only one we need. Try that and see if it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, we could export whatever variables we want to be passed down to all shell invocations from all targets, if desired.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, maybe in a separate PR :)

GOARCH=$(GOARCH) \
VERSION=$(VERSION) \
PKG=$(PKG) \
BIN=$(BIN) \
OUTPUT_DIR=$$(pwd)/_output/bin/$(GOOS)/$(GOARCH) \
./hack/build.sh

build: _output/bin/$(GOOS)/$(GOARCH)/$(BIN)

_output/bin/$(GOOS)/$(GOARCH)/$(BIN): build-dirs
Expand Down Expand Up @@ -153,6 +165,11 @@ ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/test.sh $(SRC_DIRS)'"
endif

test-local: build-dirs
ifneq ($(SKIP_TESTS), 1)
hack/test.sh $(SRC_DIRS)
endif

verify:
ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/verify-all.sh'"
Expand Down
4 changes: 2 additions & 2 deletions docs/build-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Run [generate-proto.sh][13] to regenerate files if you make the following change

### Cross compiling

By default, `make` builds an `ark` binary that runs on your host operating system and architecture.
To build for another platform, run `make build-<GOOS>-<GOARCH`.
By default, `make build` builds an `ark` binary for `linux-amd64`.
To build for another platform, run `make build-<GOOS>-<GOARCH>`.
For example, to build for the Mac, run `make build-darwin-amd64`.
All binaries are placed in `_output/bin/<GOOS>/<GOARCH>`-- for example, `_output/bin/darwin/amd64/ark`.

Expand Down