diff --git a/build_keyboard.mk b/build_keyboard.mk index 5252499efb85..d9ab05649b2c 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -286,6 +286,10 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","") POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h endif +# Disable features that a keyboard doesn't support +# Process after keyboard, userspace and keymap, but before post_keymap +-include disable_features.mk + # Userspace makefile second pass -include $(USER_PATH)/post_keymap.mk # Userspace config.h first pass @@ -293,9 +297,6 @@ ifneq ("$(wildcard $(USER_PATH)/config.h)","") CONFIG_H += $(USER_PATH)/config.h endif -# Disable features that a keyboard doesn't support --include disable_features.mk - # Object files directory # To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! diff --git a/keyboards/maartenwut/wasdat/rules.mk b/keyboards/maartenwut/wasdat/rules.mk index 822baf5ed845..850ca2403379 100644 --- a/keyboards/maartenwut/wasdat/rules.mk +++ b/keyboards/maartenwut/wasdat/rules.mk @@ -24,6 +24,7 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = yes # USB Nkey Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +BACKLIGHT_SUPPORTED = no RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow MIDI_ENABLE = no # MIDI support BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID diff --git a/users/konstantin/my_backlight.c b/users/konstantin/my_backlight.c new file mode 100644 index 000000000000..032d6b2ebdcb --- /dev/null +++ b/users/konstantin/my_backlight.c @@ -0,0 +1 @@ +This will error out if it gets included in the build. diff --git a/users/konstantin/post_keymap.mk b/users/konstantin/post_keymap.mk index a762a3699af4..e88d50500017 100644 --- a/users/konstantin/post_keymap.mk +++ b/users/konstantin/post_keymap.mk @@ -12,3 +12,14 @@ endif ifneq (,$(filter yes,$(UNICODE_ENABLE) $(UNICODEMAP_ENABLE))) SRC += unicode.c endif +# Context: The user konstantin has `BACKLIGHT_ENABLE = yes` in their userspace, +# and is trying to build `make maartenwut/wasdat:konstantin`, a keyboard that +# has `BACKLIGHT_SUPPORTED = no` declared. +# If everything works correctly, at this point in the build (post_keymap.mk), +# the supported flag will have overridden the enable flag and set it to no, so +# the .c file will NOT be included and the build will finish successfully. +# The keyboard's "backlight not supported" flag is respected by default, +# without requiring extra checks in the makefile. +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) + SRC += my_backlight.c +endif diff --git a/users/konstantin/rules.mk b/users/konstantin/rules.mk index 475e930861d8..d43a9702f07b 100644 --- a/users/konstantin/rules.mk +++ b/users/konstantin/rules.mk @@ -9,7 +9,7 @@ TAP_DANCE_ENABLE = yes UNICODEMAP_ENABLE = yes # Keyboard-specific feature defaults -BACKLIGHT_ENABLE = no +BACKLIGHT_ENABLE = yes # Enabled in userspace, but keyboard has BACKLIGHT_SUPPORTED = no RGBLIGHT_ENABLE = no RGB_MATRIX_ENABLE = no