Skip to content

Commit

Permalink
build: bind BUILD_D in so you can use a BUILD_D outside of the tree.
Browse files Browse the repository at this point in the history
This allows:

    make BUILD_D=/tmp/build

Without the change, only a BUILD_D that was under the stacker
checkout would work.

Note that in order to take advantage of shared GOCACHE and GOPATH,
they must be under BUILD_D (they are by default).

Signed-off-by: Scott Moser <[email protected]>
  • Loading branch information
smoser committed Oct 4, 2023
1 parent 4689ad5 commit 8076490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TOP_LEVEL := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
BUILD_D = $(TOP_LEVEL)/.build
export GOPATH = $(BUILD_D)/gopath
export GOCACHE = $(GOPATH)/gocache
export GOPATH ?= $(BUILD_D)/gopath
export GOCACHE ?= $(GOPATH)/gocache

GO_SRC=$(shell find pkg cmd -name \*.go)
VERSION?=$(shell git describe --tags || git rev-parse HEAD)
Expand Down Expand Up @@ -44,7 +44,8 @@ STACKER_DEPS = $(GO_SRC) go.mod go.sum

stacker: $(STAGE1_STACKER) $(STACKER_DEPS) cmd/stacker/lxc-wrapper/lxc-wrapper.c
$(STAGE1_STACKER) --debug $(STACKER_OPTS) build \
-f build.yaml --shell-fail \
-f build.yaml \
--substitute BUILD_D=$(BUILD_D) \
--substitute STACKER_BUILD_BASE_IMAGE=$(STACKER_BUILD_BASE_IMAGE) \
--substitute LXC_CLONE_URL=$(LXC_CLONE_URL) \
--substitute LXC_BRANCH=$(LXC_BRANCH) \
Expand Down
7 changes: 4 additions & 3 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ build:
tag: build-env
binds:
- . -> /stacker-tree
- ${{BUILD_D}} -> /build
run: |
#!/bin/sh -ex
# golang wants somewhere to put its garbage
Expand All @@ -90,6 +91,6 @@ build:
export VERSION_FULL=${{VERSION_FULL}}
cd /stacker-tree
make show-info
make -C cmd/stacker/lxc-wrapper clean
make stacker-static
make BUILD_D=/build show-info
make BUILD_D=/build -C cmd/stacker/lxc-wrapper clean
make BUILD_D=/build stacker-static

0 comments on commit 8076490

Please sign in to comment.