-
Notifications
You must be signed in to change notification settings - Fork 2.1k
makefiles: remove exports so that PORT is not evaluated if it's not needed. #10440
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why including boards/cc2538dk
and murdock.inc.mk
in this one ?
There are also other boards that export the variables.
If they are required, maybe split them in different commits with justification.
I will add some testing procedure in an upcoming comment.
makefiles/vars.inc.mk
Outdated
@@ -69,7 +69,7 @@ export WERROR # Treat all compiler warnings as errors if set to 1 | |||
export GITCACHE # path to git-cache executable | |||
export GIT_CACHE_DIR # path to git-cache cache directory | |||
export FLASHER # The command to call on "make flash". | |||
export FFLAGS # The parameters to supply to FLASHER. | |||
# FFLAGS # The parameters to supply to FLASHER. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a tab included instead of spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
I looked at the usages of But in the implementation So everything should be ok with git grep PORT | grep -e '{PORT}' -e '(PORT)' | grep -v -e '\.h' -e '\.c'
boards/cc2538dk/Makefile.include: export FFLAGS = -p "$(PORT)" -e -w -v $(HEXFILE)
boards/common/arduino-atmega/Makefile.include:export PROGRAMMER_FLAGS = -P $(PORT) -b $(PROGRAMMER_SPEED)
boards/common/msb-430/Makefile.include: export MSPDEBUGFLAGS += -d $(PORT)
boards/common/msba2/Makefile.include:export TERMFLAGS += -tg -p "$(PORT)"
boards/common/msba2/Makefile.include:ifeq ($(PORT),)
boards/common/msba2/Makefile.include:export FFLAGS = $(PORT) $(HEXFILE)
boards/common/msba2/tools/flashutil.sh: if [ "${PORT}" = "openocd" ]; then
boards/common/msba2/tools/flashutil.sh: windows_flash_fm ${PORT}
boards/common/msba2/tools/flashutil.sh: if [ "${PORT}" = "openocd" ]; then
boards/common/msba2/tools/flashutil.sh: echo Flashing ${HEXFILE} to ${PORT}
boards/common/msba2/tools/flashutil.sh: ${FLASHUTIL_SHELL} "${BASEDIR}/bin/lpc2k_pgm ${PORT} ${HEXFILE}; sleep 2" &
boards/common/wsn430/Makefile.include:export FFLAGS = -d $(PORT) -j uif "prog $(HEXFILE)"
boards/lobaro-lorabox/Makefile.include:FFLAGS += -p $(PORT) -e -u -S -l 0x1ff -w $(BINFILE)
boards/mulle/Makefile.include:ifeq ($(PORT),)
boards/mulle/Makefile.include:ifeq ($(PORT),)
boards/native/Makefile.include:export TERMFLAGS := $(PORT) $(TERMFLAGS)
boards/native/Makefile.include: $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
boards/native/Makefile.include: $(VALGRIND) $(VALGRIND_FLAGS) $(ELFFILE) $(PORT)
boards/native/Makefile.include: $(VALGRIND) $(CACHEGRIND_FLAGS) $(ELFFILE) $(PORT)
boards/nz32-sc151/Makefile.include:export TERMFLAGS = -p $(PORT)
boards/openmote-cc2538/Makefile.include: export FFLAGS = -p "$(PORT)" -e -w -v -b 460800 $(HEXFILE)
boards/telosb/Makefile.include:export FFLAGS = --telosb -c $(PORT) -r -e -I -p $(HEXFILE)
boards/waspmote-pro/Makefile.include: export PROGRAMMER_FLAGS = -P $(PORT) -b 115200
boards/z1/Makefile.include:export FFLAGS = --z1 -I -c $(PORT) -r -e -p $(HEXFILE)
cpu/esp32/Makefile.include: export FFLAGS += --chip esp32 -p $(PORT) -b $(PROGRAMMER_SPEED)
cpu/esp8266/Makefile.include: export FFLAGS += -p $(PORT) -b $(PROGRAMMER_SPEED) write_flash
dist/tools/ethos/start_network.sh:[ -z "${PORT}" -o -z "${TAP}" -o -z "${PREFIX}" ] && {
dist/tools/ethos/start_network.sh:create_tap && start_uhcpd && "${ETHOS_DIR}/ethos" ${TAP} ${PORT} ${BAUDRATE}
dist/tools/usb-serial/README.md: ifeq ($(PORT),)
dist/tools/usb-serial/README.md: ifeq ($(PORT),)
dist/tools/usb-serial/README.md: ifeq ($(PORT),)
examples/gnrc_border_router/Makefile:TERMFLAGS ?= $(PORT) $(TAP) $(IPV6_PREFIX)
makefiles/info.inc.mk: @echo 'PORT: $(PORT)'
makefiles/tools/bossa.inc.mk:export FFLAGS ?= -p $(PORT) -e -i -w -v -b -R $(HEXFILE)
makefiles/tools/bossa.inc.mk: PREFFLAGS ?= $(STTY_FLAG) $(PORT) raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
makefiles/tools/serial.inc.mk:ifeq ($(PORT),)
makefiles/tools/serial.inc.mk: export TERMFLAGS ?= -p "$(PORT)" -b "$(BAUD)"
makefiles/tools/serial.inc.mk: export TERMFLAGS ?= --nolock --imap lfcrlf --echo --baud "$(BAUD)" "$(PORT)" |
git grep TERMPROG | grep -e '{TERMPROG}' -e '(TERMPROG)' | grep -v -e '\.h' -e '\.c'
Makefile.include: $(call check_cmd,$(TERMPROG),Terminal program)
Makefile.include: $(TERMPROG) $(TERMFLAGS)
makefiles/info.inc.mk: @echo 'TERMPROG: $(TERMPROG)'
git grep TERMFLAGS | grep -e '{TERMFLAGS}' -e '(TERMFLAGS)' | grep -v -e '\.h' -e '\.c'
Makefile.include: $(TERMPROG) $(TERMFLAGS)
boards/native/Makefile.include:export TERMFLAGS := $(PORT) $(TERMFLAGS)
boards/native/Makefile.include: export DEBUGGER_FLAGS = -- $(ELFFILE) $(TERMFLAGS)
boards/native/Makefile.include: export DEBUGGER_FLAGS = -q --args $(ELFFILE) $(TERMFLAGS)
makefiles/info.inc.mk: @echo 'TERMFLAGS: $(TERMFLAGS)' |
|
|
a248c47
to
83825b6
Compare
@cladmi What is the status here? |
For the moment, there are still many exported Only removing the current ones will not be enough for #7695. |
83825b6
to
39c3931
Compare
I rebased on top of master to solve the conflicts. |
My comment #10440 (comment) still holds. |
I rebased on master and added one more commit to remove one more evaluation. |
@cladmi #10342 happened so long ago that I forgot, I'm rebasing. One thing I noticed is that PORT_LINUX and PORT_DARWIN are exported in several places: RIOT/boards/sodaq-explorer/Makefile.include Lines 5 to 7 in 68dc5b0
Should these be banned too? Another thing: look at this doc, it is telling people to do things wrong. I'm fixing it as part of this PR, it thats Ok: https://github.com/RIOT-OS/RIOT/blob/2ba303bc8452d72122d1d82b889bf1fb1f9fcb12/dist/tools/usb-serial/README.md |
Yes the I would indeed like to have the documentation updated at the same time too. Having the variable in |
That's exactly how I found it. |
This variable is only used for the term recipe (and maybe for flashing). They should not be evaluated if they are not needed and the user should not see a warning that the port is not set if he does not use port (for example in make all.)
The example in the tool documentation contains several things that are wrong: - exports PORT. - Defines the port using :=. - Defines PORT instead of PORT_LINUX, PORT_DARWIN - ifeq-based logic (which will force an evaluation). I have not tested the new example script.
I rebased #10342 and then took the first two commits for this PR. I cannot add PORT to the check script untill all "export PORT_DARWIN/PORT_LINUX" is fixed as the regex for PORT also catches those. |
It does not if you do |
PORT := $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1) | ||
endif | ||
endif | ||
PORT_LINUX_EXACT = $(if $(PROGRAMMER_SERIAL),$(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh "^$(PROGRAMMER_SERIAL)$$")),) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes more than removing exports
. Only remove the mention to export
here I would say.
When changing this one, the files using the pattern will also need to be updated, and even put in common which was somehow done in #7695 (with other issues)
git grep 'usb-serial/find-tty.sh'
boards/cc2538dk/Makefile.include:PORT_LINUX ?= $(word 2,$(shell $(RIOTTOOLS)/usb-serial/find-tty.sh '^$(PROGRAMMER_SERIAL)'))
boards/mulle/Makefile.include: PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh '^$(DEBUG_ADAPTER_ID)$$'))
boards/mulle/Makefile.include: PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh))
boards/pba-d-01-kw2x/Makefile.include: SERIAL_TTY = $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh $(SERIAL)))
dist/tools/usb-serial/README.md: PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh "^$(PROGRAMMER_SERIAL)$$"))
dist/tools/usb-serial/README.md: PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh))
makefiles/boards/sam0.inc.mk: SERIAL_TTY = $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh $(SERIAL)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ifeqs should also go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, we still kept it in the serial.inc.mk
for this PR as it only remove exports
as removing this warning is done by #10342
ifeq ($(PORT),)
$(info Warning: no PORT set!)
endif
Otherwise, the whole change should be consistent globally and may require other dependencies to fix boards.
@cladmi Does your #10440 (comment) still stand here? |
From the Makefile only it is good like this. My remark is about the whole change in the documentation that for me should be done in #10342, expect removing 'export PORT' that should stay there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good and murdock takes care of testing. ACK
Contribution description
Remove instances of
:=
and export that were causing $(PORT) to be evaluated where it was not needed.This is needed for #10342 (it verifies if port is not set). If
term
is not specified as a target, then PORT is not evaluated and no error will be produced.Testing procedure
If I'm not mistaken, the test for this is already carried out by murdock.
Issues/PRs references
Split from: #10342