Skip to content

Commit e8307a4

Browse files
committed
enable-if-any/all deserve some commentary.
1 parent 020e4d2 commit e8307a4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

py/circuitpy_mpconfig.mk

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@
2626
# Boards default to all modules enabled (with exceptions)
2727
# Manually disable by overriding in #mpconfigboard.mk
2828

29+
# These Makefile variables are used to implement the "any" and "all" functions.
30+
# Make's "sort" will transform a mixed sequence of 0s and 1s to "0 1" (because
31+
# it also eliminates duplicates), or a non-mixed sequence of "0" or "1" to just
32+
# itself. Thus, if all the inputs are 1 then the first word will be 1; if any
33+
# of the inputs are 1, then the last word will be 1.
2934
enable-if-any=$(lastword $(sort $(1) 0))
3035
enable-if-all=$(firstword $(sort $(1) 1))
3136

32-
#$(info enable-if-any 0 1 -> $(call enable-if-any,0 1))
33-
#$(info enable-if-any 1 0 -> $(call enable-if-any,1 0))
34-
#$(info enable-if-any 1 1 -> $(call enable-if-any,1 1))
35-
#$(info enable-if-any 0 0 -> $(call enable-if-any,0 0))
36-
#$(info enable-if-all 0 1 -> $(call enable-if-all,0 1))
37-
#$(info enable-if-all 1 0 -> $(call enable-if-all,1 0))
38-
#$(info enable-if-all 1 1 -> $(call enable-if-all,1 1))
39-
#$(info enable-if-all 0 0 -> $(call enable-if-all,0 0))
37+
# To use any/all, you "$(call)" it, with the values to test after a comma.
38+
# Usually the values are other $(CIRCUITPY_foo) variables. The definition
39+
# of CIRCUITPY_AUDIOCORE and CIRCUITPY_AUDIOMP3 below are typical of how
40+
# any/all are expected to be used.
4041

4142
# Always on. Present here to help generate documentation module support matrix for "builtins".
4243
CIRCUITPY = 1

0 commit comments

Comments
 (0)