From e4ae8eaa6e585f36873c67dfd06d7231afbae8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Thu, 30 Oct 2014 22:40:41 +0100 Subject: [PATCH] make: allow tagged RIOT_VERSION --- Makefile.buildtests | 20 -------------- Makefile.include | 66 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/Makefile.buildtests b/Makefile.buildtests index 9c564c6254..b307203b4c 100644 --- a/Makefile.buildtests +++ b/Makefile.buildtests @@ -33,26 +33,6 @@ endif OS := $(shell uname) -COLOR_GREEN := -COLOR_RED := -COLOR_PURPLE := -COLOR_RESET := -COLOR_ECHO := /bin/echo -ifeq (, ${JENKINS_URL}) - ifeq (0, $(shell tput colors 2>&1 > /dev/null; echo $$?)) - COLOR_GREEN := \033[1;32m - COLOR_RED := \033[1;31m - COLOR_PURPLE := \033[1;35m - COLOR_RESET := \033[0m - ifeq ($(OS),Darwin) - COLOR_ECHO := echo -e - SHELL=bash - else - COLOR_ECHO := /bin/echo -e - endif - endif -endif - buildtest: @ \ BUILDTESTOK=true; \ diff --git a/Makefile.include b/Makefile.include index 6f3b40b0b1..a17fac05ea 100644 --- a/Makefile.include +++ b/Makefile.include @@ -1,5 +1,4 @@ -# Provide a shallow sanity check. You cannot call `make` in a module directory. -export __RIOTBUILD_FLAG := RIOT +all: # set undefined variables RIOTBASE ?= $(shell dirname "$(lastword $(MAKEFILE_LIST))") @@ -12,7 +11,30 @@ RIOTBOARD ?= $(RIOTBASE)/boards RIOTBOARD := $(abspath $(RIOTBOARD)) BINDIRBASE ?= $(CURDIR)/bin -BINDIR ?= $(abspath $(BINDIRBASE)/$(BOARD))/ +BINDIRBASE := $(abspath $(BINDIRBASE)) + +BINDIR ?= $(BINDIRBASE)/$(BOARD) +BINDIR := $(abspath $(BINDIR))/ + +COLOR_GREEN := +COLOR_RED := +COLOR_PURPLE := +COLOR_RESET := +COLOR_ECHO := /bin/echo +ifeq (, ${JENKINS_URL}) + ifeq (0, $(shell tput colors 2>&1 > /dev/null; echo $$?)) + COLOR_GREEN := \033[1;32m + COLOR_RED := \033[1;31m + COLOR_PURPLE := \033[1;35m + COLOR_RESET := \033[0m + ifeq ($(OS),Darwin) + COLOR_ECHO := echo -e + SHELL=bash + else + COLOR_ECHO := /bin/echo -e + endif + endif +endif ifeq ($(QUIET),1) AD=@ @@ -21,6 +43,11 @@ else AD= endif +ifneq (10,$(if ${RIOT_VERSION},1,0)$(if ${__RIOTBUILD_FLAG},1,0)) + +# Provide a shallow sanity check. You cannot call `make` in a module directory. +export __RIOTBUILD_FLAG := RIOT + BOARD := $(strip $(BOARD)) # provide common external programs for `Makefile.include`s @@ -134,7 +161,8 @@ endif endif ..build-message: - @echo "Building application $(APPLICATION) for $(BOARD) w/ MCU $(MCU)." + @$(COLOR_ECHO) '${COLOR_GREEN}Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".${COLOR_RESET}' + @$(COLOR_ECHO) # add extra include paths for packages in $(USEMODULE) export USEMODULE_INCLUDES = @@ -203,7 +231,6 @@ include $(RIOTBASE)/Makefile.vars # Warn if the selected board and drivers don't provide all needed featues: ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) - EXPECT_ERRORS := # Test if there where dependencies against a module in DISABLE_MODULE. @@ -240,3 +267,32 @@ ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) $(shell $(COLOR_ECHO) "\n\n$(COLOR_RED)EXPECT ERRORS!$(COLOR_RESET)\n\n" 1>&2) endif endif + +else # RIOT_VERSION + + export __RIOTBUILD_FLAG := RIOT + + NUM_RIOT_VERSION := $(shell cd $(RIOTBASE) && git rev-parse --verify --short "$(RIOT_VERSION)" 2>/dev/null) + ifeq (, ${NUM_RIOT_VERSION}) + $(error The supplied RIOT_VERSION=$(RIOT_VERSION) is invalid!) + endif + + all $(filter-out clean, ${MAKECMDGOALS}): ..delegate + ifneq (, $(filter clean, $(MAKECMDGOALS))) + all $(filter-out clean, ${MAKECMDGOALS}): clean + endif + + clean: + -$(AD)rm -rf $(BINDIR) + + $(BINDIR)riot-version/$(NUM_RIOT_VERSION)/Makefile.include: + $(AD)rm -rf $(@D) + $(AD)mkdir -p $(@D) + $(AD)cd $(RIOTBASE) && git archive --format=tar $(NUM_RIOT_VERSION) | ( cd $(@D) && tar x 1>&2 ) + + ..delegate: $(BINDIR)riot-version/$(NUM_RIOT_VERSION)/Makefile.include + @$(COLOR_ECHO) '$(COLOR_GREEN)Using RIOT_VERSION=${NUM_RIOT_VERSION}$(COLOR_RESET)' 1>&2 + @$(COLOR_ECHO) + $(MAKE) RIOTBASE=$(