From 5b3d26453a44515901194f99fa77931fb6d36183 Mon Sep 17 00:00:00 2001 From: smlng Date: Tue, 25 Sep 2018 17:51:18 +0200 Subject: [PATCH 1/3] make: introduce BUILDOUT_DIR This introduces a new environment variable for a common directory that holds all output of the build process, such as application or package binaries. This would also allow to easily redirect output to any other location, e.g. for out-of-source builds. --- Makefile.include | 3 +++ makefiles/scan-build.inc.mk | 1 + makefiles/vars.inc.mk | 1 + 3 files changed, 5 insertions(+) diff --git a/Makefile.include b/Makefile.include index d85ce551da..dd31b6b2b0 100644 --- a/Makefile.include +++ b/Makefile.include @@ -23,6 +23,7 @@ RIOTTOOLS ?= $(RIOTBASE)/dist/tools RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd) GITCACHE ?= $(RIOTTOOLS)/git/git-cache GIT_CACHE_DIR ?= $(HOME)/.gitcache +BUILD_DIR ?= $(RIOTBASE)/build APPDIR ?= $(CURDIR) BINDIRBASE ?= $(APPDIR)/bin BINDIR ?= $(BINDIRBASE)/$(BOARD) @@ -39,6 +40,7 @@ __DIRECTORY_VARIABLES := \ RIOTTOOLS \ RIOTPROJECT \ APPDIR \ + BUILD_DIR \ BINDIRBASE \ BINDIR \ CCACHE_BASEDIR \ @@ -58,6 +60,7 @@ override RIOTTOOLS := $(abspath $(RIOTTOOLS)) override RIOTPROJECT := $(abspath $(RIOTPROJECT)) override GITCACHE := $(abspath $(GITCACHE)) override APPDIR := $(abspath $(APPDIR)) +override BUILD_DIR := $(abspath $(BUILD_DIR)) override BINDIRBASE := $(abspath $(BINDIRBASE)) override BINDIR := $(abspath $(BINDIR)) override PKGDIRBASE := $(abspath $(PKGDIRBASE)) diff --git a/makefiles/scan-build.inc.mk b/makefiles/scan-build.inc.mk index 5160971c7e..10fb376f06 100644 --- a/makefiles/scan-build.inc.mk +++ b/makefiles/scan-build.inc.mk @@ -7,6 +7,7 @@ SCANBUILD_ENV_VARS := \ BINDIR \ BINDIRBASE \ BOARD \ + BUILD_DIR \ BUILDRELPATH \ CC \ CFLAGS \ diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index 0dee732764..cff66ea75b 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -29,6 +29,7 @@ export RIOTPROJECT # Top level git root of the project being built, or export RIOTMAKE # Location of all supplemental Makefiles (such as this file) export BINDIRBASE # This is the folder where the application should be built in. For each BOARD a different subfolder is used. export BINDIR # This is the folder where the application should be built in. +export BUILD_DIR # This is the base folder to store common build files and artifacts, e.g. test results. export APPDIR # The base folder containing the application export PKGDIRBASE # The base folder for building packages From 4b7a7dad0d66c4853f732f55297b5730495e0db2 Mon Sep 17 00:00:00 2001 From: cladmi Date: Wed, 17 Oct 2018 21:32:26 +0200 Subject: [PATCH 2/3] gitignore: ignore 'build' directory The 'build' directory should not be tracked by git. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 74aeebbddd..c5f6b8d4b6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ doc/doxygen/*.db doc/doxygen/*.tmp # Built binaries *bin +# Build directory +/build # Backup files *~ *.orig From ed1798634b43bbc2790dcb6faa4f8f80a7421579 Mon Sep 17 00:00:00 2001 From: cladmi Date: Wed, 17 Oct 2018 21:52:07 +0200 Subject: [PATCH 3/3] makefiles/docker.inc.mk: handle 'build' directory The 'build' directory should be created before starting docker. If not it will be created as root. Also add mapping for the directory in docker. Currently create the directory in the target until there is a directory creation target. --- makefiles/docker.inc.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index 1f32a87cbf..775549f630 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -108,14 +108,18 @@ ETC_LOCALTIME = $(realpath /etc/localtime) # hardware which may not be reachable from inside the container. ..in-docker-container: @$(COLOR_ECHO) '$(COLOR_GREEN)Launching build container using image "$(DOCKER_IMAGE)".$(COLOR_RESET)' + @# HACK: Handle directory creation here until it is provided globally + $(Q)mkdir -p $(BUILD_DIR) $(DOCKER) run $(DOCKER_FLAGS) -t -u "$$(id -u)" \ -v '$(RIOTBASE):$(DOCKER_BUILD_ROOT)/riotbase' \ + -v '$(BUILD_DIR):$(DOCKER_BUILD_ROOT)/build' \ -v '$(RIOTCPU):$(DOCKER_BUILD_ROOT)/riotcpu' \ -v '$(RIOTBOARD):$(DOCKER_BUILD_ROOT)/riotboard' \ -v '$(RIOTMAKE):$(DOCKER_BUILD_ROOT)/riotmake' \ -v '$(RIOTPROJECT):$(DOCKER_BUILD_ROOT)/riotproject' \ -v '$(ETC_LOCALTIME):/etc/localtime:ro' \ -e 'RIOTBASE=$(DOCKER_BUILD_ROOT)/riotbase' \ + -e 'BUILD_DIR=$(DOCKER_BUILD_ROOT)/build' \ -e 'CCACHE_BASEDIR=$(DOCKER_BUILD_ROOT)/riotbase' \ -e 'RIOTCPU=$(DOCKER_BUILD_ROOT)/riotcpu' \ -e 'RIOTBOARD=$(DOCKER_BUILD_ROOT)/riotboard' \