mirror of https://github.com/docker/docs.git
Merge pull request #1991 from dmp42/01-carry-on-build-tweaks
Add simpler make targets and fix Windows build
This commit is contained in:
commit
a63f26f438
|
@ -95,19 +95,23 @@ This will generate and open the report file:
|
|||
make test
|
||||
make validate
|
||||
|
||||
### Build targets
|
||||
### Advanced build targets
|
||||
|
||||
Just build the machine binary itself:
|
||||
Just build the machine binary itself (native):
|
||||
|
||||
make `pwd`/bin/docker-machine
|
||||
make machine
|
||||
|
||||
Just build the plugins (native):
|
||||
|
||||
make plugins
|
||||
|
||||
Build for all supported oses and architectures (binaries will be in the `bin` project subfolder):
|
||||
|
||||
make build-x
|
||||
make cross
|
||||
|
||||
Build for a specific list of oses and architectures:
|
||||
|
||||
TARGET_OS=linux TARGET_ARCH="amd64 arm" make build-x
|
||||
TARGET_OS=linux TARGET_ARCH="amd64 arm" make cross
|
||||
|
||||
You can further control build options through the following environment variables:
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -31,6 +31,6 @@ test: build
|
|||
make $@
|
||||
|
||||
@test ! -d bin || rm -Rf bin
|
||||
@test -z "$(findstring build,$@)" || docker cp $(DOCKER_CONTAINER_NAME):/go/src/github.com/docker/machine/bin bin
|
||||
@test -z "$(findstring build,$(patsubst cross,build,$@))" || docker cp $(DOCKER_CONTAINER_NAME):/go/src/github.com/docker/machine/bin bin
|
||||
|
||||
endif
|
||||
|
|
|
@ -29,7 +29,7 @@ dependencies:
|
|||
test:
|
||||
pre:
|
||||
- gvm use stable && go version
|
||||
- gvm use stable && make build-simple:
|
||||
- gvm use stable && make build:
|
||||
pwd: $BASE_STABLE
|
||||
|
||||
override:
|
||||
|
|
26
mk/build.mk
26
mk/build.mk
|
@ -1,23 +1,31 @@
|
|||
build-clean:
|
||||
@rm -Rf $(PREFIX)/bin/*
|
||||
|
||||
extension = $(patsubst windows,.exe,$(filter windows,$(1)))
|
||||
|
||||
# Cross builder helper
|
||||
define gocross
|
||||
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build -o $(PREFIX)/bin/$(1)-$(2)/docker-$(patsubst cmd/%.go,%,$3) \
|
||||
-a $(VERBOSE_GO) -tags "static_build netgo $(BUILDTAGS)" -installsuffix netgo -ldflags "$(GO_LDFLAGS) \
|
||||
-extldflags -static" $(GO_GCFLAGS) $(3);
|
||||
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build \
|
||||
-o $(PREFIX)/bin/$(1)-$(2)/docker-$(patsubst cmd/%.go,%,$3)$(call extension,$(GOOS)) \
|
||||
-a $(VERBOSE_GO) -tags "static_build netgo $(BUILDTAGS)" -installsuffix netgo \
|
||||
-ldflags "$(GO_LDFLAGS) -extldflags -static" $(GO_GCFLAGS) $(3);
|
||||
endef
|
||||
|
||||
# XXX building with -a fails in debug (with -N -l) ????
|
||||
|
||||
# Independent targets for every bin
|
||||
$(PREFIX)/bin/docker-%: ./cmd/%.go $(shell find . -type f -name '*.go')
|
||||
$(GO) build -o $@ $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) $<
|
||||
$(GO) build -o $@$(call extension,$(GOOS)) $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) $<
|
||||
|
||||
# Native build
|
||||
build-simple: $(patsubst ./cmd/%.go,$(PREFIX)/bin/docker-%,$(filter-out %_test.go, $(wildcard ./cmd/*.go)))
|
||||
|
||||
# Cross compilation targets
|
||||
# Cross-compilation targets
|
||||
build-x-%: ./cmd/%.go $(shell find . -type f -name '*.go')
|
||||
@$(foreach GOARCH,$(TARGET_ARCH),$(foreach GOOS,$(TARGET_OS),$(call gocross,$(GOOS),$(GOARCH),$<)))
|
||||
|
||||
# Cross-build
|
||||
# Build just machine
|
||||
build-machine: $(PREFIX)/bin/docker-machine
|
||||
|
||||
# Build all plugins
|
||||
build-plugins: $(patsubst ./cmd/%.go,$(PREFIX)/bin/docker-%,$(filter-out %_test.go, $(wildcard ./cmd/machine-driver-*.go)))
|
||||
|
||||
# Overall cross-build
|
||||
build-x: $(patsubst ./cmd/%.go,build-x-%,$(filter-out %_test.go, $(wildcard ./cmd/*.go)))
|
||||
|
|
12
mk/main.mk
12
mk/main.mk
|
@ -44,15 +44,23 @@ include mk/release.mk
|
|||
include mk/test.mk
|
||||
include mk/validate.mk
|
||||
|
||||
.all_build: build build-clean build-x
|
||||
.all_build: build build-clean build-x build-machine build-plugins
|
||||
.all_coverage: coverage-generate coverage-html coverage-send coverage-serve coverage-clean
|
||||
.all_release: release-checksum release
|
||||
.all_test: test-short test-long test-integration
|
||||
.all_validate: dco fmt vet lint
|
||||
|
||||
default: build
|
||||
# Build native machine and all drivers
|
||||
build: build-machine build-plugins
|
||||
# Just build native machine itself
|
||||
machine: build-machine
|
||||
# Just build the native plugins
|
||||
plugins: build-plugins
|
||||
# Build all, cross platform
|
||||
cross: build-x
|
||||
|
||||
clean: coverage-clean build-clean
|
||||
build: build-simple
|
||||
test: dco fmt vet test-short
|
||||
validate: dco fmt vet lint test-short test-long
|
||||
|
||||
|
|
Loading…
Reference in New Issue