1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00
RIOT/makefiles/utils/test-variables.mk
Gaëtan Harter fcf8c4782d
makefiles/utils: function to export variables for a target
This allows exporting variables only for some target.
It will allow not exporting variables when not needed, and so prevent
unnecessary evaluation.
2019-06-28 11:33:54 +02:00

20 lines
880 B
Makefile

include variables.mk
# Timestamp in nanoseconds (to be an integer)
# OSx 'date' does not support 'date +%s%N' so rely on python instead
# It could be OSx specific but we do not have 'OS' defined here to differentiate
date_nanoseconds = $(shell python -c 'import time; print(int(time.time() * 1000000000))')
EXPORTED_VARIABLES = MY_VARIABLE CURRENT_TIME
MY_VARIABLE = my_variable
# Defered evaluation to the test
CURRENT_TIME = $(call date_nanoseconds)
$(call target-export-variables,test-exported-variables,$(EXPORTED_VARIABLES))
test-exported-variables:
$(Q)bash -c 'test "$(MY_VARIABLE)" = "$${MY_VARIABLE}" || { echo ERROR: "$(MY_VARIABLE)" != "$${MY_VARIABLE}"; exit 1; }'
$(Q)bash -c 'test $(PARSE_TIME) -lt $${CURRENT_TIME} || { echo ERROR: $(PARSE_TIME) \>= $${CURRENT_TIME} >&2; exit 1; }'
# Immediate evaluation for comparing
PARSE_TIME := $(call date_nanoseconds)