From fc84c90f66f29300ed73b33483b3f24b4a0d8331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 16:51:16 +0200 Subject: [PATCH 01/10] Makefile.include: allow directories that cannot be overridden Allow defining new directory variables that will not be overridden when set from command line. Command line is supposed to override from the value in make. Promoting another behavior is against `make`. --- Makefile.include | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index 4a1ecaec2b..12206d33bb 100644 --- a/Makefile.include +++ b/Makefile.include @@ -59,6 +59,12 @@ __DIRECTORY_VARIABLES := \ DLCACHE_DIR \ # +# In GNU make command line is supposed to override the value set in makefile +# These variables can be overridden even when set from command line +__OVERRIDE_DIRECTORY_VARIABLES := $(__DIRECTORY_VARIABLES) +# Use absolute paths in recursive "make" even if overridden on command line. +MAKEOVERRIDES += $(foreach v,$(__OVERRIDE_DIRECTORY_VARIABLES),$(v)=$($(v))) + # Make all paths absolute. override RIOTBASE := $(abspath $(RIOTBASE)) override RIOTCPU := $(abspath $(RIOTCPU)) @@ -82,9 +88,6 @@ ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v))))) $(error Make sure no path override is empty or contains spaces!) endif -# Use absolute paths in recusive "make" even if overriden on command line. -MAKEOVERRIDES += $(foreach v,$(__DIRECTORY_VARIABLES),$(v)=$($(v))) - # Path to the current directory relative to RIOTPROJECT # trailing '/' is important when RIOTPROJECT == CURDIR BUILDRELPATH ?= $(patsubst $(RIOTPROJECT)/%,%,$(CURDIR)/) From f76a2d201eea6ce1ab12552ae62c64870de2ee35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 16:55:55 +0200 Subject: [PATCH 02/10] Makefile.include: introduce 'BOARDSDIR' for boards directory Introduce a new variable 'BOARDSDIR' to use when referencing the base boards directory. This is a transition to allow defining external boards while still using the `RIOT/boards` directory for like `boards/common` for example through 'RIOTBOARD'. --- Makefile.include | 8 ++++++++ makefiles/vars.inc.mk | 1 + 2 files changed, 9 insertions(+) diff --git a/Makefile.include b/Makefile.include index 12206d33bb..2467c29f97 100644 --- a/Makefile.include +++ b/Makefile.include @@ -25,6 +25,7 @@ include $(RIOT_MAKEFILES_GLOBAL_PRE) RIOTBASE ?= $(_riotbase) RIOTCPU ?= $(RIOTBASE)/cpu RIOTBOARD ?= $(RIOTBASE)/boards +BOARDSDIR ?= $(RIOTBOARD) RIOTMAKE ?= $(RIOTBASE)/makefiles RIOTPKG ?= $(RIOTBASE)/pkg RIOTTOOLS ?= $(RIOTBASE)/dist/tools @@ -81,6 +82,13 @@ override BINDIR := $(abspath $(BINDIR)) override PKGDIRBASE := $(abspath $(PKGDIRBASE)) override DLCACHE_DIR := $(abspath $(DLCACHE_DIR)) +# Keep standard make behavior for new variables +__DIRECTORY_VARIABLES += \ + BOARDSDIR \ + # + +BOARDSDIR := $(abspath $(BOARDSDIR)) + # Ensure that all directories are set and don't contain spaces. ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v)))))) $(info Aborting compilation for your safety.) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index bc2732b496..4fcb7489e7 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -26,6 +26,7 @@ export APPDEPS # Files / Makefile targets that need to be created export RIOTBASE # The root folder of RIOT. The folder where this very file lives in. export RIOTCPU # For third party CPUs this folder is the base of the CPUs. export RIOTBOARD # For third party BOARDs this folder is the base of the BOARDs. +export BOARDSDIR # For third party BOARDs this folder is the base of the BOARDs. (Migration in progress) export RIOTPKG # For overriding RIOT's pkg directory export RIOTTOOLS # Location of host machine tools export RIOTPROJECT # Top level git root of the project being built, or PWD if not a git repository From 90692ac92bcdaf2fddb71777ee41caf9be99af1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:00:59 +0200 Subject: [PATCH 03/10] makefiles: use 'BOARDSDIR' for the boards directory in compilation Replace uses of 'RIOTBOARD' by 'BOARDSDIR' during the compilation. --- Makefile.dep | 2 +- Makefile.features | 6 +++++- Makefile.include | 6 +++--- makefiles/application.inc.mk | 2 +- makefiles/boards.inc.mk | 6 +++--- makefiles/info.inc.mk | 1 + makefiles/scan-build.inc.mk | 1 + 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index 0c54aeb7fc..a89a5d2547 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -6,7 +6,7 @@ OLD_USEPKG := $(sort $(USEPKG)) -include $(APPDIR)/Makefile.board.dep # include board dependencies --include $(RIOTBOARD)/$(BOARD)/Makefile.dep +-include $(BOARDSDIR)/$(BOARD)/Makefile.dep # include cpu dependencies -include $(RIOTCPU)/$(CPU)/Makefile.dep diff --git a/Makefile.features b/Makefile.features index 64831850a7..536eeb90bd 100644 --- a/Makefile.features +++ b/Makefile.features @@ -5,7 +5,11 @@ # This makes them available when setting features based on CPU_MODEL in the cpu # Makefile.features and also during dependency resolution. -include $(RIOTBOARD)/$(BOARD)/Makefile.features +# Transition: +# Moving 'CPU/CPU_MODEL' to Makefile.features is an ongoing work and may not +# reflect the state of all boards for the moment. + +include $(BOARDSDIR)/$(BOARD)/Makefile.features # Sanity check ifeq (,$(CPU)) diff --git a/Makefile.include b/Makefile.include index 2467c29f97..b2a269c2ef 100644 --- a/Makefile.include +++ b/Makefile.include @@ -259,7 +259,7 @@ LAZYSPONGE_FLAGS ?= $(if $(filter 1,$(QUIET)),,--verbose) ifeq (, $(APPLICATION)) $(error An application name must be specified as APPLICATION.) endif -ifneq (0,$(shell test -d $(RIOTBOARD)/$(BOARD); echo $$?)) +ifneq (0,$(shell test -d $(BOARDSDIR)/$(BOARD); echo $$?)) $(error The specified board $(BOARD) does not exist.) endif @@ -317,8 +317,8 @@ include $(RIOTMAKE)/pseudomodules.inc.mk include $(RIOTMAKE)/defaultmodules.inc.mk # Include Board and CPU configuration -INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/$(BOARD)/include)) -include $(RIOTBOARD)/$(BOARD)/Makefile.include +INCLUDES += $(addprefix -I,$(wildcard $(BOARDSDIR)/$(BOARD)/include)) +include $(BOARDSDIR)/$(BOARD)/Makefile.include INCLUDES += -I$(RIOTCPU)/$(CPU)/include include $(RIOTCPU)/$(CPU)/Makefile.include diff --git a/makefiles/application.inc.mk b/makefiles/application.inc.mk index e34ad39f2f..0d750371c4 100644 --- a/makefiles/application.inc.mk +++ b/makefiles/application.inc.mk @@ -1,6 +1,6 @@ MODULE = $(APPLICATION_MODULE) -DIRS += $(RIOTCPU)/$(CPU) $(RIOTBOARD)/$(BOARD) +DIRS += $(RIOTCPU)/$(CPU) $(BOARDSDIR)/$(BOARD) DIRS += $(RIOTBASE)/core $(RIOTBASE)/drivers $(RIOTBASE)/sys # For regular modules, adding files to BLOBS to their Makefile is sufficient to diff --git a/makefiles/boards.inc.mk b/makefiles/boards.inc.mk index 5049c44c5b..7a56a238fc 100644 --- a/makefiles/boards.inc.mk +++ b/makefiles/boards.inc.mk @@ -1,10 +1,10 @@ # Default when RIOTBASE is not set and is executed from the RIOT directory -RIOTBOARD ?= $(or $(RIOTBASE),$(CURDIR))/boards +BOARDSDIR ?= $(or $(RIOTBASE),$(CURDIR))/boards # List all boards. -# By default, all directories in RIOTBOARD except 'common' +# By default, all directories in BOARDSDIR except 'common' # use 'wildcard */.' to only list directories -ALLBOARDS ?= $(sort $(filter-out common,$(patsubst $(RIOTBOARD)/%/.,%,$(wildcard $(RIOTBOARD)/*/.)))) +ALLBOARDS ?= $(sort $(filter-out common,$(patsubst $(BOARDSDIR)/%/.,%,$(wildcard $(BOARDSDIR)/*/.)))) # Set the default value from `BOARDS` BOARDS ?= $(ALLBOARDS) diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index e87e3c3e64..f8ee66741e 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -36,6 +36,7 @@ info-build: @echo '' @echo 'RIOTBASE: $(RIOTBASE)' @echo 'RIOTBOARD: $(RIOTBOARD)' + @echo 'BOARDSDIR: $(BOARDSDIR)' @echo 'RIOTCPU: $(RIOTCPU)' @echo 'RIOTPKG: $(RIOTPKG)' @echo '' diff --git a/makefiles/scan-build.inc.mk b/makefiles/scan-build.inc.mk index 9fcf881b0d..ddf231048e 100644 --- a/makefiles/scan-build.inc.mk +++ b/makefiles/scan-build.inc.mk @@ -7,6 +7,7 @@ SCANBUILD_ENV_VARS := \ BINDIR \ BINDIRBASE \ BOARD \ + BOARDSDIR \ BUILD_DIR \ BUILDRELPATH \ CC \ From 41a891f284a44eb9761ebf4b56a74f3fa3fedb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:23:01 +0200 Subject: [PATCH 04/10] tools: use 'BOARDSDIR' for the boards directory Replace uses of 'RIOTBOARD' by 'BOARDSDIR' for tools. --- dist/gdbinit-docker | 2 +- dist/tools/openocd/openocd.sh | 4 ++-- dist/tools/renode/run-renode.sh | 4 ++-- makefiles/tools/avrdude.inc.mk | 2 +- makefiles/tools/openocd-adapters/stlink.inc.mk | 2 +- makefiles/tools/uniflash.inc.mk | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/gdbinit-docker b/dist/gdbinit-docker index a3e4f1b39c..b24aa12755 100644 --- a/dist/gdbinit-docker +++ b/dist/gdbinit-docker @@ -18,7 +18,7 @@ except KeyError: else: gdb.execute('set substitute-path /data/riotbuild/riotcpu ' + path) try: - path = os.environ['RIOTBOARD'] + path = os.environ['BOARDSDIR'] except KeyError: # Environment variable wasn't set. pass diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index d9e8b0b7ad..0363d18776 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -13,7 +13,7 @@ # Global environment variables used: # OPENOCD: OpenOCD command name, default: "openocd" # OPENOCD_CONFIG: OpenOCD configuration file name, -# default: "${RIOTBOARD}/${BOARD}/dist/openocd.cfg" +# default: "${BOARDSDIR}/${BOARD}/dist/openocd.cfg" # # The script supports the following actions: # @@ -66,7 +66,7 @@ # Default TCL port, set to 0 to disable : ${TCL_PORT:=6333} # Default path to OpenOCD configuration file -: ${OPENOCD_CONFIG:=${RIOTBOARD}/${BOARD}/dist/openocd.cfg} +: ${OPENOCD_CONFIG:=${BOARDSDIR}/${BOARD}/dist/openocd.cfg} # Default OpenOCD command : ${OPENOCD:=openocd} # Extra board initialization commands to pass to OpenOCD diff --git a/dist/tools/renode/run-renode.sh b/dist/tools/renode/run-renode.sh index 1164708e3f..8b20e6be14 100755 --- a/dist/tools/renode/run-renode.sh +++ b/dist/tools/renode/run-renode.sh @@ -13,14 +13,14 @@ # Global environment variables used: # RENODE: Renode command name, default: "renode" # RENODE_CONFIG: Renode configuration file name, -# default: "${RIOTBOARD}/${BOARD}/dist/board.resc" +# default: "${BOARDSDIR}/${BOARD}/dist/board.resc" # RENODE_BIN_CONFIG: Renode intermediate configuration file name, # default: "${BINDIR}/board.resc" # # @author Bas Stottelaar # Default path to Renode configuration file -: ${RENODE_CONFIG:=${RIOTBOARD}/${BOARD}/dist/board.resc} +: ${RENODE_CONFIG:=${BOARDSDIR}/${BOARD}/dist/board.resc} # Default path to Renode intermediate configuration file : ${RENODE_BIN_CONFIG:=${BINDIR}/board.resc} # Default Renode command diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index 5bde9d60e3..c5a317b892 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -1,5 +1,5 @@ FLASHER = avrdude -DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist +DIST_PATH = $(BOARDSDIR)/$(BOARD)/dist DEBUGSERVER_PORT = 4242 DEBUGSERVER = $(DIST_PATH)/debug_srv.sh DEBUGSERVER_INTERFACE ?= diff --git a/makefiles/tools/openocd-adapters/stlink.inc.mk b/makefiles/tools/openocd-adapters/stlink.inc.mk index c9b12908e0..c86a691248 100644 --- a/makefiles/tools/openocd-adapters/stlink.inc.mk +++ b/makefiles/tools/openocd-adapters/stlink.inc.mk @@ -18,7 +18,7 @@ export OPENOCD_ADAPTER_INIT ifeq (,$(OPENOCD_CONFIG)) # if no openocd default configuration is provided by the board, # use the STM32 common one - ifeq (0,$(words $(wildcard $(RIOTBOARD)/$(BOARD)/dist/openocd.cfg))) + ifeq (0,$(words $(wildcard $(BOARDSDIR)/$(BOARD)/dist/openocd.cfg))) export OPENOCD_CONFIG := $(RIOTBASE)/boards/common/stm32/dist/$(CPU).cfg endif endif diff --git a/makefiles/tools/uniflash.inc.mk b/makefiles/tools/uniflash.inc.mk index eff7c09b43..af74e1281e 100644 --- a/makefiles/tools/uniflash.inc.mk +++ b/makefiles/tools/uniflash.inc.mk @@ -1,9 +1,9 @@ # http://www.ti.com/tool/uniflash FLASHFILE ?= $(ELFFILE) -UNIFLASH_CONFIG_CCXML ?= $(RIOTBOARD)/$(BOARD)/dist/$(CPU_MODEL)_$(XDEBUGGER).ccxml -UNIFLASH_CONFIG_DAT ?= $(RIOTBOARD)/$(BOARD)/dist/$(CPU_MODEL)_$(XDEBUGGER).dat -UNIFLASH_CONFIG_GDB ?= $(RIOTBOARD)/$(BOARD)/dist/$(CPU_MODEL)_gdb.conf +UNIFLASH_CONFIG_CCXML ?= $(BOARDSDIR)/$(BOARD)/dist/$(CPU_MODEL)_$(XDEBUGGER).ccxml +UNIFLASH_CONFIG_DAT ?= $(BOARDSDIR)/$(BOARD)/dist/$(CPU_MODEL)_$(XDEBUGGER).dat +UNIFLASH_CONFIG_GDB ?= $(BOARDSDIR)/$(BOARD)/dist/$(CPU_MODEL)_gdb.conf export UNIFLASH_PATH ?= "UNIFLASH_PATH unconfigured" # check which uniflash version is available, either 4.x or 3.x From c26710ac7e8d5edbe41f0d746a1ff119822eb75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:52:54 +0200 Subject: [PATCH 05/10] makefiles/docker: handle mounting 'BOARDSDIR' Handle setting 'BOARDSDIR' when building in docker. --- makefiles/docker.inc.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index 4f053f3f67..b4055b8faf 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -251,6 +251,12 @@ DOCKER_VOLUMES_AND_ENV += $(if $(wildcard $(GIT_CACHE_DIR)),-e 'GIT_CACHE_DIR=$( DOCKER_VOLUMES_AND_ENV += $(call docker_volumes_mapping,$(EXTERNAL_MODULE_DIRS),$(DOCKER_BUILD_ROOT)/external,) DOCKER_OVERRIDE_CMDLINE += $(call docker_cmdline_mapping,EXTERNAL_MODULE_DIRS,$(DOCKER_BUILD_ROOT)/external,) +# Remap 'BOARDSDIR' if it is external +DOCKER_VOLUMES_AND_ENV += $(call docker_volumes_mapping,$(BOARDSDIR),,boards) +# Value is overridden from command line if it is not the default value +# This allows handling even if the value is set in the 'Makefile'. +DOCKER_OVERRIDE_CMDLINE += $(if $(findstring $(RIOTBOARD),$(BOARDSDIR)),,$(call docker_cmdline_mapping,BOARDSDIR,,boards)) + # External module directories sanity check: # # Detect if there are remapped directories with the same name as it is not handled. From 1427ef998f45acc83aceec6aa138b194ddc83c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:27:25 +0200 Subject: [PATCH 06/10] makefiles/vars.inc.mk: document BOARDSDIR as external boards directory Replace using 'RIOTBOARD' by 'BOARDSDIR' to define external boards. --- makefiles/vars.inc.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index 4fcb7489e7..f2c5fb21b0 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -25,8 +25,8 @@ export APPDEPS # Files / Makefile targets that need to be created export RIOTBASE # The root folder of RIOT. The folder where this very file lives in. export RIOTCPU # For third party CPUs this folder is the base of the CPUs. -export RIOTBOARD # For third party BOARDs this folder is the base of the BOARDs. -export BOARDSDIR # For third party BOARDs this folder is the base of the BOARDs. (Migration in progress) +export RIOTBOARD # This folder is the base of the riot boards. +export BOARDSDIR # For third party BOARDs this folder is the base of the BOARDs. export RIOTPKG # For overriding RIOT's pkg directory export RIOTTOOLS # Location of host machine tools export RIOTPROJECT # Top level git root of the project being built, or PWD if not a git repository From 633f050d1fce7bb961c76779141081dc7c01d293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:58:00 +0200 Subject: [PATCH 07/10] tests/external_board_native: show an example of external board Add an example that implements an external board based on native. It relies on 'BOARDSDIR' and uses common files from 'RIOT/boards' through 'RIOTBOARDS'. This application also works with the docker integration. --- tests/external_board_native/Makefile | 15 ++++++++ tests/external_board_native/README.md | 14 ++++++++ .../external_boards/native/Makefile | 6 ++++ .../external_boards/native/Makefile.dep | 4 +++ .../external_boards/native/Makefile.features | 1 + .../external_boards/native/Makefile.include | 7 ++++ .../external_boards/native/external_native.c | 3 ++ .../native/include/external_native.h | 36 +++++++++++++++++++ tests/external_board_native/main.c | 34 ++++++++++++++++++ tests/external_board_native/tests/01-run.py | 22 ++++++++++++ 10 files changed, 142 insertions(+) create mode 100644 tests/external_board_native/Makefile create mode 100644 tests/external_board_native/README.md create mode 100644 tests/external_board_native/external_boards/native/Makefile create mode 100644 tests/external_board_native/external_boards/native/Makefile.dep create mode 100644 tests/external_board_native/external_boards/native/Makefile.features create mode 100644 tests/external_board_native/external_boards/native/Makefile.include create mode 100644 tests/external_board_native/external_boards/native/external_native.c create mode 100644 tests/external_board_native/external_boards/native/include/external_native.h create mode 100644 tests/external_board_native/main.c create mode 100755 tests/external_board_native/tests/01-run.py diff --git a/tests/external_board_native/Makefile b/tests/external_board_native/Makefile new file mode 100644 index 0000000000..94c1ef91bf --- /dev/null +++ b/tests/external_board_native/Makefile @@ -0,0 +1,15 @@ +APPLICATION = external_board +RIOTBASE ?= $(CURDIR)/../../ + +# Only support this board +# No need for a `WHITELIST` as there is only one board in `external_boards`. +# +# HACK I named the external board as 'native' to be in murdock test path for +# 'native' +# In practice it should be something else +BOARD ?= native + +# Set without '?=' to also verify the docker integration when set with = +BOARDSDIR = $(CURDIR)/external_boards + +include $(RIOTBASE)/Makefile.include diff --git a/tests/external_board_native/README.md b/tests/external_board_native/README.md new file mode 100644 index 0000000000..ba79ea8369 --- /dev/null +++ b/tests/external_board_native/README.md @@ -0,0 +1,14 @@ +Example with an external board +============================== + +This tests an external board implementation. +The goal is to show using an external board that still needs to use the +'RIOT/boards' directory. + +To allow automated testing by `murdock` this board is named 'native'. + +As it wants to extend native, which is not a common board, some hacks must be +done as the 'board' module is implemented directly by the 'RIOT/boards/native'. + +If you are running an 'ubuntu-bionic' you could even compile the example in +docker and run the test. diff --git a/tests/external_board_native/external_boards/native/Makefile b/tests/external_board_native/external_boards/native/Makefile new file mode 100644 index 0000000000..fb23e07c14 --- /dev/null +++ b/tests/external_board_native/external_boards/native/Makefile @@ -0,0 +1,6 @@ +# This must be a different name than 'board' as it is implemented by 'native' +MODULE = board_external_native + +DIRS += $(RIOTBOARD)/native + +include $(RIOTBASE)/Makefile.base diff --git a/tests/external_board_native/external_boards/native/Makefile.dep b/tests/external_board_native/external_boards/native/Makefile.dep new file mode 100644 index 0000000000..91cb568c97 --- /dev/null +++ b/tests/external_board_native/external_boards/native/Makefile.dep @@ -0,0 +1,4 @@ +# This must be a different name than 'board' as it is implemented by 'native' +USEMODULE += board_external_native + +include $(RIOTBOARD)/native/Makefile.dep diff --git a/tests/external_board_native/external_boards/native/Makefile.features b/tests/external_board_native/external_boards/native/Makefile.features new file mode 100644 index 0000000000..a49f05c741 --- /dev/null +++ b/tests/external_board_native/external_boards/native/Makefile.features @@ -0,0 +1 @@ +include $(RIOTBOARD)/native/Makefile.features diff --git a/tests/external_board_native/external_boards/native/Makefile.include b/tests/external_board_native/external_boards/native/Makefile.include new file mode 100644 index 0000000000..0f5fad2779 --- /dev/null +++ b/tests/external_board_native/external_boards/native/Makefile.include @@ -0,0 +1,7 @@ +CFLAGS += -DTHIS_BOARD_IS='"external_native"' + +# We must duplicate the include done by $(RIOTBASE)/Makefile.include +# to also include the main board header +INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/native/include)) + +include $(RIOTBOARD)/native/Makefile.include diff --git a/tests/external_board_native/external_boards/native/external_native.c b/tests/external_board_native/external_boards/native/external_native.c new file mode 100644 index 0000000000..b8c96f82f4 --- /dev/null +++ b/tests/external_board_native/external_boards/native/external_native.c @@ -0,0 +1,3 @@ +#include "external_native.h" + +char* external_native_board_description = "An external extended native"; diff --git a/tests/external_board_native/external_boards/native/include/external_native.h b/tests/external_board_native/external_boards/native/include/external_native.h new file mode 100644 index 0000000000..870bbea268 --- /dev/null +++ b/tests/external_board_native/external_boards/native/include/external_native.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_external_native + * @{ + * + * @file + * @brief A header for an external native + * + * @author Gaëtan Harter + */ + +#ifndef EXTERNAL_NATIVE_H +#define EXTERNAL_NATIVE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** + * @brief A variable defined in the external header + */ +extern char* external_native_board_description; + +#ifdef __cplusplus +} +#endif + +#endif /* EXTERNAL_NATIVE_H */ +/** @} */ diff --git a/tests/external_board_native/main.c b/tests/external_board_native/main.c new file mode 100644 index 0000000000..0efb2e39d1 --- /dev/null +++ b/tests/external_board_native/main.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2019 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief External Native application + * + * @author Gaëtan Harter + * + * @} + */ + +#include +#include "external_native.h" + +int main(void) +{ + puts("Hello World!"); + + printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD); + printf("THIS_BOARD_IS %s\n", THIS_BOARD_IS); + printf("This board is '%s'\n", external_native_board_description); + + + return 0; +} diff --git a/tests/external_board_native/tests/01-run.py b/tests/external_board_native/tests/01-run.py new file mode 100755 index 0000000000..bc2ac219f4 --- /dev/null +++ b/tests/external_board_native/tests/01-run.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2019 Freie Universität Berlin +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact("Hello World!") + child.expect_exact("You are running RIOT on a(n) native board.") + child.expect_exact("THIS_BOARD_IS external_native") + child.expect_exact("This board is 'An external extended native") + print("Test successful!!") + + +if __name__ == "__main__": + sys.exit(run(testfunc)) From 387da5214f9fb1d674a44407a5752bcacf2c584d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:26:17 +0200 Subject: [PATCH 08/10] examples: update documentation to use 'BOARDSDIR' Replace uses of 'RIOTBOARD' by 'BOARDSDIR' in examples. --- examples/default/Makefile | 2 +- examples/riot_and_cpp/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/default/Makefile b/examples/default/Makefile index 56c4e65682..705ef541c8 100644 --- a/examples/default/Makefile +++ b/examples/default/Makefile @@ -10,7 +10,7 @@ RIOTBASE ?= $(CURDIR)/../.. # Uncomment these lines if you want to use platform support from external # repositories: #RIOTCPU ?= $(CURDIR)/../../RIOT/thirdparty_cpu -#RIOTBOARD ?= $(CURDIR)/../../RIOT/thirdparty_boards +#BOARDSDIR ?= $(CURDIR)/../../RIOT/thirdparty_boards # Uncomment this to enable scheduler statistics for ps: #USEMODULE += schedstatistics diff --git a/examples/riot_and_cpp/Makefile b/examples/riot_and_cpp/Makefile index 37de5c7646..146c8e5ecd 100644 --- a/examples/riot_and_cpp/Makefile +++ b/examples/riot_and_cpp/Makefile @@ -10,7 +10,7 @@ RIOTBASE ?= $(CURDIR)/../.. # Uncomment these lines if you want to use platform support from external # repositories: #RIOTCPU ?= $(CURDIR)/../../../thirdparty_cpu -#RIOTBOARD ?= $(CURDIR)/../../../thirdparty_boards +#BOARDSDIR ?= $(CURDIR)/../../../thirdparty_boards # Uncomment this to enable scheduler statistics for ps: #CFLAGS += -DSCHEDSTATISTICS From 418bcfb95da13dd4f91e122f9560e0a25202b5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 9 Sep 2019 17:29:06 +0200 Subject: [PATCH 09/10] makefiles: deprecate 'RIOTBOARD' for 'BOARDSDIR' Replace using 'RIOTBOARD' by 'BOARDSDIR' to define external boards. --- Makefile.include | 10 ++++++++-- makefiles/info.inc.mk | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index b2a269c2ef..7b551e44d8 100644 --- a/Makefile.include +++ b/Makefile.include @@ -24,6 +24,7 @@ include $(RIOT_MAKEFILES_GLOBAL_PRE) # set undefined variables RIOTBASE ?= $(_riotbase) RIOTCPU ?= $(RIOTBASE)/cpu +# Deprecated to set RIOTBOARD, use BOARDSDIR RIOTBOARD ?= $(RIOTBASE)/boards BOARDSDIR ?= $(RIOTBOARD) RIOTMAKE ?= $(RIOTBASE)/makefiles @@ -46,7 +47,6 @@ DLCACHE_DIR ?= $(RIOTBASE)/.dlcache __DIRECTORY_VARIABLES := \ RIOTBASE \ RIOTCPU \ - RIOTBOARD \ RIOTMAKE \ RIOTPKG \ RIOTTOOLS \ @@ -66,10 +66,16 @@ __OVERRIDE_DIRECTORY_VARIABLES := $(__DIRECTORY_VARIABLES) # Use absolute paths in recursive "make" even if overridden on command line. MAKEOVERRIDES += $(foreach v,$(__OVERRIDE_DIRECTORY_VARIABLES),$(v)=$($(v))) +# Deprecation of configuring 'RIOTBOARD' +ifneq ($(abspath $(RIOTBASE)/boards),$(abspath $(RIOTBOARD))) + $(warning overriding RIOTBOARD for external boards is deprecated, please use an absolute BOARDSDIR) + override RIOTBOARD := $(abspath $(RIOTBOARD)) + __DIRECTORY_VARIABLES += RIOTBOARD +endif + # Make all paths absolute. override RIOTBASE := $(abspath $(RIOTBASE)) override RIOTCPU := $(abspath $(RIOTCPU)) -override RIOTBOARD := $(abspath $(RIOTBOARD)) override RIOTMAKE := $(abspath $(RIOTMAKE)) override RIOTPKG := $(abspath $(RIOTPKG)) override RIOTTOOLS := $(abspath $(RIOTTOOLS)) diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index f8ee66741e..eb7f206b75 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -35,7 +35,6 @@ info-build: @echo 'MCU: $(MCU)' @echo '' @echo 'RIOTBASE: $(RIOTBASE)' - @echo 'RIOTBOARD: $(RIOTBOARD)' @echo 'BOARDSDIR: $(BOARDSDIR)' @echo 'RIOTCPU: $(RIOTCPU)' @echo 'RIOTPKG: $(RIOTPKG)' From 211cec8b3e194c9e9d4bf783dc2ed147a77df5f3 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 16 Dec 2019 15:35:00 +0100 Subject: [PATCH 10/10] tools/buildsystem_check: exclude tests/external_board_native path This test application must act as a regular application to showcase how to provide a board support from an external directory --- dist/tools/buildsystem_sanity_check/check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 4c88bf8ac9..011db079b4 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -196,6 +196,7 @@ checks_tests_application_not_defined_in_makefile() { patterns+=(-e '^[[:space:]]*APPLICATION[[:space:]:+]=') pathspec+=('tests/**/Makefile') + pathspec+=(':!tests/external_board_native/Makefile') git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ | error_with_message "Don't define APPLICATION in test Makefile"