diff --git a/INSTALL.md b/INSTALL.md index c9fd811ee..d5cd4e03e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,32 +21,19 @@ The following tools are need on the host: ## Build -You can build Rook by simply running: +You can build the Rook binaries and all container images for the host platform by simply running the +command below. Building in parallel with the `-j` option is recommended. ``` make -j4 ``` -This will build the Rook binaries and container images for the host platform. - -You can also run the build for all supported platforms: +Developers may often wish to make only images for a particular backend in their testing. This can +be done by specifying the `IMAGES` environment variable with `make` as exemplified below. Possible +values for are as defined by subdir names in the `/rook/images/` dir. ``` -make -j4 build.all -``` - -Currently, only `amd64` platform supports this kind of 'cross' build. In order to make `build.all` succeed, we need to follow the steps specified by the below section -`Building for other platforms` first. - -We suggest to use native `build` to create the binaries and container images on `arm{32,64}` platform, but if you do want to build those `arm{32,64}` binaries and images -on `amd64` platform with `build.all` command, please make sure the multi-arch feature is supported. To test run the following: - -``` -> docker run --rm -ti arm32v7/ubuntu uname -a -Linux bad621a75757 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 armv7l armv7l armv7l GNU/Linux - -> docker run --rm -ti arm64v8/ubuntu uname -a -Linux f51ea93e76a2 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux +make -j4 IMAGES='ceph ceph-toolbox' build ``` Run `make help` for more options. @@ -73,6 +60,35 @@ build/reset ## Building for other platforms +You can also run the build for all supported platforms: + +``` +make -j4 build.all +``` + +Or from the cross container: + +``` +build/run make -j4 build.all +``` + +Currently, only `amd64` platform supports this kind of 'cross' build. In order to make `build.all` +succeed, we need to follow the steps specified by the below section `Building for other platforms` +first. + +We suggest to use native `build` to create the binaries and container images on `arm{32,64}` +platform, but if you do want to build those `arm{32,64}` binaries and images on `amd64` platform +with `build.all` command, please make sure the multi-arch feature is supported. To test run the +following: + +``` +> docker run --rm -ti arm32v7/ubuntu uname -a +Linux bad621a75757 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 armv7l armv7l armv7l GNU/Linux + +> docker run --rm -ti arm64v8/ubuntu uname -a +Linux f51ea93e76a2 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux +``` + In order to build container images for these platforms we rely on cross-compilers and QEMU. Cross compiling is much faster than QEMU and so we lean heavily on it. In order for QEMU to work inside docker containers you need to do a few things on diff --git a/Makefile b/Makefile index b7f8c81fa..81f152e14 100644 --- a/Makefile +++ b/Makefile @@ -163,35 +163,40 @@ prune: # ==================================================================================== # Help +define HELPTEXT +Usage: make ... + +Targets: + build Build source code for host platform. + build.all Build source code for all platforms. + Best done in the cross build container + due to cross compiler dependencies. + check Runs unit tests. + clean Remove all files that are created by building. + codegen Run code generators. + distclean Remove all files that are created + by building or configuring. + fmt Check formatting of go sources. + lint Check syntax and styling of go sources. + help Show this help info. + prune Prune cached artifacts. + test Runs unit tests. + test-integration Runs integration tests. + vendor Update vendor dependencies. + vet Runs lint checks on go sources. + +Options: + DEBUG Whether to generate debug symbols. Default is 0. + IMAGES Backend images to make. All by default. See: /rook/images/ dir + PLATFORM The platform to build. + SUITE The test suite to run. + TESTFILTER Tests to run in a suite. + VERSION The version information compiled into binaries. + The default is obtained from git. + V Set to 1 enable verbose build. Default is 0. + +endef +export HELPTEXT .PHONY: help help: - @echo 'Usage: make ... ' - @echo '' - @echo 'Targets:' - @echo ' build Build source code for host platform.' - @echo ' build.all Build source code for all platforms.' - @echo ' Best done in the cross build container' - @echo ' due to cross compiler dependencies.' - @echo ' check Runs unit tests.' - @echo ' clean Remove all files that are created ' - @echo ' by building.' - @echo ' codegen Run code generators.' - @echo ' distclean Remove all files that are created ' - @echo ' by building or configuring.' - @echo ' fmt Check formatting of go sources.' - @echo ' lint Check syntax and styling of go sources.' - @echo ' help Show this help info.' - @echo ' prune Prune cached artifacts.' - @echo ' test Runs unit tests.' - @echo ' test-integration Runs integration tests.' - @echo ' vendor Update vendor dependencies.' - @echo ' vet Runs lint checks on go sources.' - @echo '' - @echo 'Options:' - @echo ' DEBUG Whether to generate debug symbols. Default is 0.' - @echo ' PLATFORM The platform to build.' - @echo ' SUITE The test suite to run.' - @echo ' TESTFILTER Tests to run in a suite.' - @echo ' VERSION The version information compiled into binaries.' - @echo ' The default is obtained from git.' - @echo ' V Set to 1 enable verbose build. Default is 0.' + @echo "$$HELPTEXT" diff --git a/build/makelib/common.mk b/build/makelib/common.mk index 152df1e9e..94f6a55a7 100644 --- a/build/makelib/common.mk +++ b/build/makelib/common.mk @@ -94,6 +94,9 @@ ifeq ($(origin BUILD_REGISTRY), undefined) BUILD_REGISTRY := build-$(shell echo $(HOSTNAME)-$(ROOT_DIR) | shasum -a 256 | cut -c1-8) endif +# Select which images (backends) to make; default to all possible images +IMAGES ?= ceph ceph-toolbox cockroachdb minio + COMMA := , SPACE := SPACE += diff --git a/build/release/Makefile b/build/release/Makefile index c0ceaa5be..85def4383 100644 --- a/build/release/Makefile +++ b/build/release/Makefile @@ -58,7 +58,6 @@ endif DOCKER_REGISTRY ?= rook QUAY_REGISTRY ?= quay.io/rook REGISTRIES ?= $(DOCKER_REGISTRY) $(QUAY_REGISTRY) -IMAGES ?= ceph ceph-toolbox cockroachdb minio IMAGE_ARCHS := $(subst linux_,,$(filter linux_%,$(PLATFORMS))) IMAGE_PLATFORMS := $(subst _,/,$(subst $(SPACE),$(COMMA),$(filter linux_%,$(PLATFORMS)))) diff --git a/images/Makefile b/images/Makefile index dcfa7317a..74f182901 100644 --- a/images/Makefile +++ b/images/Makefile @@ -38,7 +38,7 @@ cockroachdb.%: minio.%: @$(MAKE) -C minio PLATFORM=$* -do.build.images.%: ceph.% ceph-toolbox.% cockroachdb.% minio.% ; +do.build.images.%: $(foreach i,$(IMAGES), $(i).%); do.build: do.build.images.$(PLATFORM) ; build.all: $(foreach p,$(PLATFORMS), do.build.images.$(p)) ; diff --git a/images/ceph-toolbox/Makefile b/images/ceph-toolbox/Makefile index 513130f76..b3e914273 100644 --- a/images/ceph-toolbox/Makefile +++ b/images/ceph-toolbox/Makefile @@ -16,7 +16,6 @@ include ../image.mk TOOLBOX_IMAGE = $(BUILD_REGISTRY)/ceph-toolbox-$(GOARCH) TOOLBOX_BASE_IMAGE = $(BUILD_REGISTRY)/ceph-toolbox-base-$(GOARCH) -IMAGES = $(TOOLBOX_IMAGE) $(TOOLBOX_BASE_IMAGE) CACHE_IMAGES = $(TOOLBOX_BASE_IMAGE) CEPH_VERSION = $(shell cat ../ceph/ceph_version) diff --git a/images/ceph/Makefile b/images/ceph/Makefile index 9b3ac4d20..f883a6f17 100755 --- a/images/ceph/Makefile +++ b/images/ceph/Makefile @@ -18,7 +18,6 @@ include ../image.mk # Image Build Options CEPH_IMAGE = $(BUILD_REGISTRY)/ceph-$(GOARCH) -IMAGES = $(CEPH_IMAGE) CEPH_VERSION = $(shell cat ceph_version) BASEIMAGE = $(CEPH_VERSION)-$(PLATFORM_ARCH) diff --git a/images/cockroachdb/Makefile b/images/cockroachdb/Makefile index 77e814504..67e7edbc9 100755 --- a/images/cockroachdb/Makefile +++ b/images/cockroachdb/Makefile @@ -18,7 +18,6 @@ include ../image.mk # Image Build Options COCKROACHDB_IMAGE = $(BUILD_REGISTRY)/cockroachdb-$(GOARCH) -IMAGES = $(COCKROACHDB_IMAGE) TEMP := $(shell mktemp -d) diff --git a/images/cross/Makefile b/images/cross/Makefile index 2b41696c4..18aa137d5 100644 --- a/images/cross/Makefile +++ b/images/cross/Makefile @@ -15,8 +15,7 @@ include ../image.mk IMAGE = $(BUILD_REGISTRY)/cross-$(GOARCH) -IMAGES := $(IMAGE) -CACHE_IMAGES = $(IMAGES) +CACHE_IMAGES = $(IMAGE) TEMP := $(shell mktemp -d) diff --git a/images/image.mk b/images/image.mk index 579fd787a..82e1cb49f 100644 --- a/images/image.mk +++ b/images/image.mk @@ -81,7 +81,7 @@ clean: clean.build prune: cache.prune clean.images: - @for i in $(IMAGES); do \ + @for i in $(CLEAN_IMAGES); do \ if [ -n "$$(docker images -q $$i)" ]; then \ for c in $$(docker ps -a -q --no-trunc --filter=ancestor=$$i); do \ if [ "$$c" != "$(SELF_CID)" ]; then \ @@ -98,7 +98,7 @@ clean.images: # this will clean everything for this build clean.build: @echo === cleaning images for $(BUILD_REGISTRY) - @$(MAKE) clean.images IMAGES="$(shell docker images | grep -E '^$(BUILD_REGISTRY)/' | awk '{print $$1":"$$2}')" + @$(MAKE) clean.images CLEAN_IMAGES="$(shell docker images | grep -E '^$(BUILD_REGISTRY)/' | awk '{print $$1":"$$2}')" # ===================================================================================== # Caching