1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12183 from cladmi/pr/boardsdir

Makefile.include: introduce 'BOARDSDIR' for boards directory
This commit is contained in:
Dylan Laduranty 2019-12-16 21:06:00 +01:00 committed by GitHub
commit c839bb809a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 200 additions and 28 deletions

View File

@ -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

View File

@ -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))

View File

@ -24,7 +24,9 @@ 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
RIOTPKG ?= $(RIOTBASE)/pkg
RIOTTOOLS ?= $(RIOTBASE)/dist/tools
@ -45,7 +47,6 @@ DLCACHE_DIR ?= $(RIOTBASE)/.dlcache
__DIRECTORY_VARIABLES := \
RIOTBASE \
RIOTCPU \
RIOTBOARD \
RIOTMAKE \
RIOTPKG \
RIOTTOOLS \
@ -59,10 +60,22 @@ __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)))
# 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))
@ -75,6 +88,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.)
@ -82,9 +102,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)/)
@ -248,7 +265,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
@ -306,8 +323,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

2
dist/gdbinit-docker vendored
View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 <basstottelaar@gmail.com>
# 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -35,7 +35,7 @@ info-build:
@echo 'MCU: $(MCU)'
@echo ''
@echo 'RIOTBASE: $(RIOTBASE)'
@echo 'RIOTBOARD: $(RIOTBOARD)'
@echo 'BOARDSDIR: $(BOARDSDIR)'
@echo 'RIOTCPU: $(RIOTCPU)'
@echo 'RIOTPKG: $(RIOTPKG)'
@echo ''

View File

@ -7,6 +7,7 @@ SCANBUILD_ENV_VARS := \
BINDIR \
BINDIRBASE \
BOARD \
BOARDSDIR \
BUILD_DIR \
BUILDRELPATH \
CC \

View File

@ -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 ?=

View File

@ -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

View File

@ -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

View File

@ -25,7 +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 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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -0,0 +1 @@
include $(RIOTBOARD)/native/Makefile.features

View File

@ -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

View File

@ -0,0 +1,3 @@
#include "external_native.h"
char* external_native_board_description = "An external extended native";

View File

@ -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 <gaetan.harter@fu-berlin.de>
*/
#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 */
/** @} */

View File

@ -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 <gaetan.harter@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#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;
}

View File

@ -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))