Skip to content

Makefile.include: default to RIOTBOARD when BOARD not in BOARDSDIR #12972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 31, 2019

Conversation

fjmolinas
Copy link
Contributor

@fjmolinas fjmolinas commented Dec 17, 2019

Contribution description

#12183 defined BOARDSDIR as a new variable to allow setting external directories where to set a BOARD.

But when BOARDSDIR is set to an external directory it wont see BOARDS that are not in BORDSDIR, so no BOARD in RIOTBOARD.

BOARD=samr21-xpro make -C tests/external_board_native/
make: Entering directory '/home/francisco/workspace/RIOT-test/tests/external_board_native'
/home/francisco/workspace/RIOT-test/tests/external_board_native/../..//Makefile.include:269: *** The specified board samr21-xpro does not exist..  Stop.
make: Leaving directory '/home/francisco/workspace/RIOT-test/tests/external_board_native'

This PR wants to use RIOTBOARD as a fallback for BOARDSDIR when the BOARD is not found in the external directory. The handling is replicated in info-global.inc.mk so info-boards-supported would see BOARDS in BOARDSDIR and RIOTBOARD.

Testing procedure

  • Finds the samr21-xpro (this fails in master)
BOARDSDIR=/home/ BOARD=samr21-xpro make -C examples/hello-world/
make: Entering directory '/home/francisco/workspace/RIOT-test/examples/hello-world'
Building application "hello-world" for "samr21-xpro" with MCU "samd21".

"make" -C /home/francisco/workspace/RIOT-test/boards/samr21-xpro
"make" -C /home/francisco/workspace/RIOT-test/core
"make" -C /home/francisco/workspace/RIOT-test/cpu/samd21
BOARDSDIR=/home/ BOARD=samr21-xpro make -C examples/hello-world
BOARDSDIR=/home/ BOARD=samr21-xpro make -C examples/hello-world/ info-boards-supported 
make: Entering directory '/home/francisco/workspace/RIOT-test/examples/hello-world'
acd52832 airfy-beacon arduino-due arduino-duemilanove arduino-leonardo arduino-mega2560 arduino-mkr1000 arduino-mkrfox1200 arduino-mkrwan1300 arduino-mkrzero arduino-nano arduino-uno arduino-zero atmega1284p atmega256rfr2-xpro atmega328p avr-rss2 avsextrem b-l072z-lrwan1 b-l475e-iot01a blackpill blackpill-128kib bluepill bluepill-128kib calliope-mini cc1352-launchpad cc2538dk cc2650-launchpad cc2650stk chronos derfmega128 derfmega256 ek-lm4f120xl esp32-mh-et-live-minikit esp32-olimex-evb esp32-wemos-lolin-d32-pro esp32-wroom-32 esp32-wrover-kit esp8266-esp-12x esp8266-olimex-mod esp8266-sparkfun-thing f4vi1 feather-m0 firefly fox frdm-k22f frdm-k64f frdm-kw41z hamilton hifive1 hifive1b i-nucleo-lrwan1 ikea-tradfri iotlab-a8-m3 iotlab-m3 limifrog-v1 lobaro-lorabox lsn50 maple-mini mbed_lpc1768 mega-xplained microbit microduino-corerf msb-430 msb-430h msba2 msbiot mulle native nrf51dk nrf51dongle nrf52832-mdk nrf52840-mdk nrf52840dk nrf52dk nrf6310 nucleo-f030r8 nucleo-f031k6 nucleo-f042k6 nucleo-f070rb nucleo-f072rb nucleo-f091rc nucleo-f103rb nucleo-f207zg nucleo-f302r8 nucleo-f303k8 nucleo-f303re nucleo-f303ze nucleo-f334r8 nucleo-f401re nucleo-f410rb nucleo-f411re nucleo-f412zg nucleo-f413zh nucleo-f429zi nucleo-f446re nucleo-f446ze nucleo-f722ze nucleo-f746zg nucleo-f767zi nucleo-l031k6 nucleo-l053r8 nucleo-l073rz nucleo-l152re nucleo-l432kc nucleo-l433rc nucleo-l452re nucleo-l476rg nucleo-l496zg nucleo-l4r5zi nz32-sc151 opencm904 openmote-b openmote-cc2538 p-l496g-cell02 particle-argon particle-boron particle-xenon pba-d-01-kw2x phynode-kw41z pic32-clicker pic32-wifire pyboard reel remote-pa remote-reva remote-revb ruuvitag samd21-xpro same54-xpro saml10-xpro saml11-xpro saml21-xpro samr21-xpro samr30-xpro samr34-xpro seeeduino_arch-pro sensebox_samd21 slstk3401a slstk3402a sltb001a slwstk6000b-slwrb4150a slwstk6000b-slwrb4162a slwstk6220a sodaq-autonomo sodaq-explorer sodaq-one sodaq-sara-aff spark-core stk3600 stk3700 stm32f030f4-demo stm32f0discovery stm32f3discovery stm32f429i-disc1 stm32f4discovery stm32f723e-disco stm32f769i-disco stm32l0538-disco stm32l476g-disco teensy31 telosb thingy52 ublox-c030-u201 udoo usb-kw41z waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
make: Leaving directory '/home/francisco/workspace/RIOT-test/examples/hello-world
  • Test with an external BOARD, easy way just copy the current external native to an external directory:
mkdir <your-dir>
cp -r tests/external_board_native/external_boards/native/ <your-dir>/native-2/
BOARDSDIR=/home/francisco/workspace/external-boards/ BOARD=native-2 make -C examples/hello-world

Issues/PRs references

@fjmolinas fjmolinas added Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 17, 2019
Makefile.include Outdated
# e.g. when set by the environment fallback to searching in RIOTBOARD
ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)))
ifneq ($(RIOTBOARD),$(BOARDSDIR))
# The specified board $(BOARD) was not found in $(BOARDSDIR) fallback to RIOTBOARD)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I didn't use a warning or info here since a lot of the code using info-boards-supported expects a clean output, only the boardslist (e.g. compile_and_test_for_board).

@fjmolinas
Copy link
Contributor Author

@cladmi might have good advice on this one.

Makefile.include Outdated
@@ -95,6 +95,20 @@ __DIRECTORY_VARIABLES += \

BOARDSDIR := $(abspath $(BOARDSDIR))

# Include Board and CPU configuration, if BOARD is not found in BOARDSDIR
# e.g. when set by the environment fallback to searching in RIOTBOARD
ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the wildcard,this does not check for a directory, see what was done with ALLBOARDS should be $(wildcard $(BOARDSDIR)/$(BOARD)/.) I think.
However it's better to use wildcard than the old $(shell test -d).

This was moved before the global goals separate handling, so the handling does not seem correct for global targets.
A test with an external board (different name) should show this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this do you mean that it could ignore the external-boards? This is true, if calling for example info-board with and an external BOARDSDIR and BOARDS set to an internal board, then all BOARDS in the external BOARDSDIR would be ignored, is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as it is done too early, it would overwrite BOARDSDIR for the multiple boards case. And so make all the handling done in makefiles/info-global.inc.mk and boards.inc.mk useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and fixed.

@kaspar030 kaspar030 changed the title Makefile.include: defualt to RIOTBOARD when BOARD not in BOARDSDIR Makefile.include: default to RIOTBOARD when BOARD not in BOARDSDIR Dec 17, 2019
Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick overview, looks good. I'll try to test it asap.

@dylad
Copy link
Member

dylad commented Dec 19, 2019

I tested this PR and it works as intended.
Current master:

$ BOARDSDIR=/home/dylan/software/mesotic/boards make BOARD=saml21-xpro -C tests/leds clean all
make : on entre dans le répertoire « /home/dylan/software/RIOT/tests/leds »
/home/dylan/software/RIOT/tests/leds/../../Makefile.include:267: *** The specified board saml21-xpro does not exist.. Arrêt.
make : on quitte le répertoire « /home/dylan/software/RIOT/tests/leds »

With this PR:

BOARDSDIR=/home/dylan/software/mesotic/boards make BOARD=saml21-xpro -C tests/leds clean all
make : on entre dans le répertoire « /home/dylan/software/RIOT/tests/leds »
Building application "tests_leds" for "saml21-xpro" with MCU "saml21".

"make" -C /home/dylan/software/RIOT/boards/saml21-xpro
"make" -C /home/dylan/software/RIOT/core
"make" -C /home/dylan/software/RIOT/cpu/saml21
"make" -C /home/dylan/software/RIOT/cpu/cortexm_common
"make" -C /home/dylan/software/RIOT/cpu/cortexm_common/periph
"make" -C /home/dylan/software/RIOT/cpu/sam0_common
"make" -C /home/dylan/software/RIOT/cpu/sam0_common/periph
"make" -C /home/dylan/software/RIOT/cpu/saml21/periph
"make" -C /home/dylan/software/RIOT/drivers
"make" -C /home/dylan/software/RIOT/drivers/periph_common
"make" -C /home/dylan/software/RIOT/sys
"make" -C /home/dylan/software/RIOT/sys/auto_init
"make" -C /home/dylan/software/RIOT/sys/isrpipe
"make" -C /home/dylan/software/RIOT/sys/newlib_syscalls_default
"make" -C /home/dylan/software/RIOT/sys/pm_layered
"make" -C /home/dylan/software/RIOT/sys/stdio_uart
"make" -C /home/dylan/software/RIOT/sys/test_utils/interactive_sync
"make" -C /home/dylan/software/RIOT/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
   9388	    140	   2612	  12140	   2f6c	/home/dylan/software/RIOT/tests/leds/bin/saml21-xpro/tests_leds.elf
make : on quitte le répertoire « /home/dylan/software/RIOT/tests/leds »

I'll let build system experts discuss the syntax introduces by this PR ;)

@dylad dylad added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Dec 19, 2019
@dylad dylad added this to the Release 2020.01 milestone Dec 19, 2019
@dylad dylad added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Dec 19, 2019
@fjmolinas
Copy link
Contributor Author

I'll let build system experts discuss the syntax introduces by this PR ;)

Maybe @kaspar030 or @smlng might take a look at that?

@fjmolinas fjmolinas force-pushed the pr_boardsdir_riotboard branch from f70a7da to 2102184 Compare December 20, 2019 17:35
@fjmolinas fjmolinas added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 22, 2019
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. I'll test in the coming days.

ifneq ($(RIOTBOARD),$(BOARDSDIR))
# The specified board $(BOARD) was not found in $(BOARDSDIR) fallback to RIOTBOARD)
BOARDSDIR = $(RIOTBOARD)
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
endif
else
ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)/.))
$(error The specified board $(BOARD) does not exist.)
endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was on purpose. If the first statement is fulfilled the second one will never be evaluated if else is used, but I want it to be evaluated in any case since BOARDSDIR value will have changed to RIOTBOARD, I can think of other ways of evaluating the conditional but it always ends in evaluating something twice. I could change it to:

ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)/.))
  ifneq ($(RIOTBOARD),$(BOARDSDIR))
    ifeq (,$(wildcard $(RIOTBOARD)/$(BOARD)/.))
      $(error The specified board $(BOARD) is not in RIOTBOARD or BOARDSDIR)
    else
      # The specified board $(BOARD) was not found in $(BOARDSDIR) but in $(RIOTBOARD)
      BOARDSDIR = $(RIOTBOARD)
    endif
  else
    $(error The specified board $(BOARD) is not in RIOTBOARD)
  endif
endif

or something like that if you prefer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, ok I see.

@fjmolinas fjmolinas removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 30, 2019
@fjmolinas
Copy link
Contributor Author

@aabadie I updates the testing procedure to use an external BOARD, you will need #12999 for this.

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments were addressed and the code looks good now. It was tested by @dylad.

ACK, please squash.

@fjmolinas fjmolinas force-pushed the pr_boardsdir_riotboard branch from f809f92 to 33dbf9d Compare December 30, 2019 16:15
@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 30, 2019
@fjmolinas
Copy link
Contributor Author

@aabadie I guess we are good to go here?

@aabadie aabadie merged commit 68210fe into RIOT-OS:master Dec 31, 2019
@fjmolinas fjmolinas deleted the pr_boardsdir_riotboard branch December 31, 2019 10:05
@fjmolinas
Copy link
Contributor Author

@aabadie @dylad @cladmi thanks for the review and testing! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR Reviewed: 3-testing The PR was tested according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants