mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Update build to cross compile
Currently targeting linux/amd64 and darwin/amd64
This commit is contained in:
+3
-1
@@ -4,8 +4,10 @@
|
||||
|
||||
# build artifacts
|
||||
coverage
|
||||
opa
|
||||
ast/parser.go
|
||||
opa
|
||||
opa_linux_amd64
|
||||
opa_darwin_amd64
|
||||
|
||||
# runtime artifacts
|
||||
policies
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
language: go
|
||||
env:
|
||||
- CROSSCOMPILE="linux/amd64 darwin/amd64"
|
||||
go:
|
||||
- 1.5
|
||||
- 1.6
|
||||
|
||||
@@ -10,6 +10,9 @@ PACKAGES := \
|
||||
github.com/open-policy-agent/opa/storage/.../ \
|
||||
github.com/open-policy-agent/opa/util/.../
|
||||
|
||||
GO := go
|
||||
GOX := gox
|
||||
|
||||
BUILD_COMMIT := $(shell ./build/get-build-commit.sh)
|
||||
BUILD_TIMESTAMP := $(shell ./build/get-build-timestamp.sh)
|
||||
BUILD_HOSTNAME := $(shell ./build/get-build-hostname.sh)
|
||||
@@ -18,7 +21,9 @@ LDFLAGS := -ldflags "-X github.com/open-policy-agent/opa/version.Vcs=$(BUILD_COM
|
||||
-X github.com/open-policy-agent/opa/version.Timestamp=$(BUILD_TIMESTAMP) \
|
||||
-X github.com/open-policy-agent/opa/version.Hostname=$(BUILD_HOSTNAME)"
|
||||
|
||||
GO := go
|
||||
# Set CROSSCOMPILE to space separated list of <platform>/<arch> pairs
|
||||
# and "gox" will be used to build the binaries instead of "go".
|
||||
CROSSCOMPILE ?=
|
||||
|
||||
GO15VENDOREXPERIMENT := 1
|
||||
export GO15VENDOREXPERIMENT
|
||||
@@ -31,12 +36,17 @@ deps:
|
||||
$(GO) install ./vendor/github.com/PuerkitoBio/pigeon
|
||||
$(GO) install ./vendor/golang.org/x/tools/cmd/goimports
|
||||
$(GO) install ./vendor/github.com/golang/lint/golint
|
||||
$(GO) get github.com/mitchellh/gox
|
||||
|
||||
generate:
|
||||
$(GO) generate
|
||||
|
||||
build: generate
|
||||
ifeq ($(CROSSCOMPILE),)
|
||||
$(GO) build -o opa $(LDFLAGS)
|
||||
else
|
||||
$(GOX) -osarch="$(CROSSCOMPILE)" $(LDFLAGS)
|
||||
endif
|
||||
|
||||
install: generate
|
||||
$(GO) install $(LDFLAGS)
|
||||
@@ -68,3 +78,5 @@ fmt:
|
||||
|
||||
clean:
|
||||
rm -f ./opa
|
||||
rm -f ./opa_linux_amd64
|
||||
rm -f ./opa_darwin_amd64
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ CHANGELOG.md snippet and uploading the packages from the build phase.
|
||||
1. Run command to build packages. This will produce a bunch of binaries (e.g., amd64/linux, i386/linux, amd64/darwin, etc.) that can be published (“distributions”).
|
||||
|
||||
```
|
||||
make dist
|
||||
make build CROSSCOMPILE="linux/amd64 darwin/amd64"
|
||||
```
|
||||
|
||||
## Publishing
|
||||
|
||||
Reference in New Issue
Block a user