Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 12cb722

Browse files
committed
Add makefile
build, cross, test, clean
1 parent 62e5205 commit 12cb722

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
tests/*_actual.json
2+
out/*

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
VERSION_MAJOR ?= 0
2+
VERSION_MINOR ?= 2
3+
VERSION_BUILD ?= 0
4+
5+
GOOS ?= $(shell go env GOOS)
6+
GOARCH = amd64
7+
BUILD_DIR ?= ./out
8+
ORG := github.com/GoogleCloudPlatform
9+
PROJECT := container-diff
10+
REPOPATH ?= $(ORG)/$(PROJECT)
11+
12+
SUPPORTED_PLATFORMS := linux-amd64 darwin-amd64
13+
BUILD_PACKAGE = $(REPOPATH)
14+
15+
# These build tags are from the containers/image library.
16+
#
17+
# container_image_ostree_stub allows building the library without requiring the libostree development libraries
18+
# container_image_openpgp forces a Golang-only OpenPGP implementation for signature verification instead of the default cgo/gpgme-based implementation
19+
GO_BUILD_TAGS := "container_image_ostree_stub containers_image_openpgp"
20+
GO_FILES := $(shell go list -f '{{join .Deps "\n"}}' $(BUILD_PACKAGE) | grep $(ORG) | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
21+
22+
$(BUILD_DIR)/$(PROJECT): out/$(PROJECT)-$(GOOS)-$(GOARCH)
23+
cp $(BUILD_DIR)/$(PROJECT)-$(GOOS)-$(GOARCH) $@
24+
25+
$(BUILD_DIR)/$(PROJECT)-%-$(GOARCH): $(GO_FILES) $(BUILD_DIR)
26+
GOOS=$* GOARCH=$(GOARCH) go build -tags $(GO_BUILD_TAGS) -o $@ $(BUILD_PACKAGE)
27+
28+
$(BUILD_DIR):
29+
mkdir -p $(BUILD_DIR)
30+
31+
.PHONY: cross
32+
cross: $(foreach platform, $(SUPPORTED_PLATFORMS), out/$(PROJECT)-$(platform))
33+
34+
.PHONY: test
35+
test: $(BUILD_DIR)/$(PROJECT)
36+
./.container-diff-tests.sh
37+
38+
.PHONY: clean
39+
clean:
40+
rm -rf $(BUILD_DIR)
41+
42+

0 commit comments

Comments
 (0)