Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
stage0,stage1: autoconf-based build
Browse files Browse the repository at this point in the history
This commit migrates rkt build process to autoconf and make toolchain
to provide the following features:

* checking for prerequisites in before the build instead of build time
* adds the following explicit configuration flags:

  --with-stage1=type      type of stage1 build one of 'src', 'coreos', 'none'
  --with-stage1-systemd-src=git-path
                          address to git repository of systemd, used in 'src'
                          build mode
  --with-stage1-systemd-version=version
                          systemd version to build
  --with-stage1-image-path
                          custom stage1 image path

* adds explicit `BUILDDIR` make variable to build outside of the source tree
* adds explicit `make stage0` and `make stage1` targets
* adds makefile macros library `makelib/lib.mk` for common build operations

Build changes
-------------

The build is now changed from the "./build" to 3 phase step:

1. First time only `./autogen.sh` step to generate configure script
2. Requried `./configure` build step to generate Makefile
3. Requried `make` bild step

Test changes
-------------

Stage 0 and stage1 tests can be now run separately.

1. `make stage0-test` executes tests for stage0 binaries
2. `make stage1-test` executes functional stage1 tests
3. `make test` executes all tests

Other changes
-------------

1. remove `aggregate` directory in favor of `BUILDDIR` external directory
2. split `aggregate` contents into individual modules in stage1 directory
3. port tests to Makefiles
4. rebase to latest master (Krzesimir Nowak)
  • Loading branch information
klizhentas authored and krnowak committed Jul 10, 2015
1 parent 1ea8a0a commit c1f54c8
Show file tree
Hide file tree
Showing 86 changed files with 1,342 additions and 617 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ tests/image/rootfs/
tests/inspect/inspect tests/inspect/inspect
tests/*.aci tests/*.aci
tests/*.log tests/*.log
autom4te.cache
Makefile
config.log
config.status
build-*
*.test
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ install:
- go get golang.org/x/tools/cmd/vet - go get golang.org/x/tools/cmd/vet


script: script:
- ./test - ./configure

- make stage0-test SHELL="/bin/bash -v"
145 changes: 145 additions & 0 deletions Makefile.in
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,145 @@
# These variables are set by configure script
# Please check configure.ac instead of modifying these manually

# package specific substitution names
package := @PACKAGE_NAME@
version := @PACKAGE_VERSION@
tarname := @PACKAGE_TARNAME@
distdir := $(tarname)-$(version)

# prefix-specific substitution names
prefix := @prefix@
exec_prefix := @exec_prefix@
bindir := @bindir@

# Setup install scripts for portability
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@

# these are rkt-build specific variables

# binaries we need to build things
GO := @GOBINARY@
GOFMT := @GOFMTBINARY@
GIT := @GIT@
BASH := @BASH@

# path to rkt source code distro
ORG_PATH := github.com/coreos
REPO_PATH := $(ORG_PATH)/rkt

# [STAGE1] build settings

# selinux tags for rkt and functional tests
RKT_TAGS := -tags selinux
# stage1 build mode
RKT_STAGE1_USR_FROM := @RKT_STAGE1_USR_FROM@
# git path to systemd
RKT_STAGE1_SYSTEMD_SRC := @RKT_STAGE1_SYSTEMD_SRC@
# systemd build version
RKT_STAGE1_SYSTEMD_VER := @RKT_STAGE1_SYSTEMD_VER@
# stage1 image flags (the optional custom path linked into binary set by user)
RKT_STAGE1_IMAGE_FLAGS := @RKT_STAGE1_IMAGE_FLAGS@

# build-related directories and binaries
BUILDDIR ?= $(shell pwd)/build-$(distdir)
BUILDDIR := $(abspath $(BUILDDIR))

BINDIR := $(BUILDDIR)$(bindir)
GOPATH := $(BUILDDIR)/gopath
GOBIN := $(BUILDDIR)/bin
ACTOOL := $(GOBIN)/actool
ROOT = $(BUILDDIR)/aci/rootfs
ACI = $(BUILDDIR)/aci

# test-related variables
GO_TEST_COVER := -cover
GO_TEST_PACKAGES ?= ./...
GO_TEST_SKIP_DIRS := tests builds
GO_TEST_FUNC_ARGS ?=

# runtime variables
OSTYPE := $(shell uname)
CORES := $(shell grep -c ^processor /proc/cpuinfo)

# export variables to inner makefiles
export

# include standard librares
include makelib/*.mk

.PHONY: clean stage0 stage1 stage1-tools stage1-deps stage0-test stage1-test test

# create directories and symlinks needed to for build in advance so we should not worry about them
$(call make-dirs,$(BINDIR) $(GOPATH)/src/$(ORG_PATH) $(GOBIN) $(BUILDDIR)/src $(BUILDDIR)/install.d $(BUILDDIR)/cache $(ROOT))
$(call make-dir-symlink,$(shell pwd),$(GOPATH)/src/$(REPO_PATH))

all: stage0 stage1

# stage0 builds rkt binary
stage0:
$(info [STAGE0] building rkt binary...)
$(GO) build -o $(GOBIN)/rkt $(RKT_STAGE1_IMAGE_FLAGS) $(RKT_TAGS) $(REPO_PATH)/rkt

# stage1 builds stage1 image and associated toolset
ifneq ($(RKT_STAGE1_USR_FROM),none)
stage1: stage1-tools stage1-rootfs
else
stage1:
@echo [STAGE1] skiping stage 1 build as configured by user
endif

stage1-tools:
@echo [STAGE1] building stage1 build tools...
go build -o $(GOBIN)/actool github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/actool

stage1-rootfs:
$(if $(filter-out Linux,$(OSTYPE)),$(error unsupported OS: $(OSTYPE)),@echo building on $(OSTYPE))
@echo [STAGE1] building stage1 rootfs using $(CORES) cores...
$(MAKE) -C stage1 -j $(CORES) -f stage1.mk

test: stage0-test stage1-test
@echo "[STAGE0] [STAGE1] executing tests"

stage0-test: GO_PACKAGES_WITH_TESTS := $(call go-find-packages-with-tests,$(GO_TEST_PACKAGES),$(GO_TEST_SKIP_DIRS))
stage0-test: GO_PACKAGES_ALL := $(call go-find-packages,$(GO_TEST_PACKAGES),$(GO_TEST_SKIP_DIRS))
stage0-test:
@echo [STAGE0] checking for gofmt verdict...
@set -e; \
cd $(GOPATH)/src ;\
NEED_FORMATTING="$$(GOPATH=$(GOPATH) $(GOFMT) -l $(GO_PACKAGES_WITH_TESTS))"; \
if [ -n "$$NEED_FORMATTING" ] ; then \
echo "[STAGE0] ERROR: these packages need formatting: $$NEED_FORMATTING"; \
exit 255; \
fi;

@echo [STAGE0] checking for go vet verdict...
@set -e; $(GO) vet $(GO_PACKAGES_ALL)

@set -e; echo [STAGE0] checking license headers...; \
licRes=$$( \
for file in $$(find . -type f -iname '*.go' ! -path './Godeps/*'); do \
head -n1 "$${file}" | grep -Eq "(Copyright|generated)" || echo -e " $${file}"; \
done; \
); \
if [ -n "${licRes}" ]; then \
echo -e "license header checking failed:\n${licRes}"; \
exit 255; \
fi

@echo [STAGE0] executing tests...
@$(GO) test -timeout 60s $(RKT_TAGS) $(GO_TEST_COVER) $(GO_PACKAGES_WITH_TESTS) --race

ifeq ($(filter true,$(RKT_ENABLE_FUNCTIONAL_TESTS)$(GO_TEST_STAGE1_FORCE)),true)
stage1-test: stage0 stage1
$(if $(filter-out Linux,$(OSTYPE)),$(error unsupported OS: $(OSTYPE)),@echo building on $(OSTYPE))
$(MAKE) -C tests -f tests.mk SHELL="/bin/bash -v"
else
stage1-test:
@echo [STAGE1] skipping tests in unsupported environment...
endif

clean:
rm -rf $(BUILDDIR)
2 changes: 2 additions & 0 deletions autogen.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
autoreconf --install
96 changes: 0 additions & 96 deletions build

This file was deleted.

Loading

0 comments on commit c1f54c8

Please sign in to comment.