Skip to content

Commit

Permalink
Demo <FEATURE>_SUPPORTED flags working with post_keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
vomindoraan committed May 13, 2020
1 parent 757ceeb commit deb080b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
7 changes: 4 additions & 3 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,17 @@ 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
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!
Expand Down
1 change: 1 addition & 0 deletions keyboards/maartenwut/wasdat/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions users/konstantin/my_backlight.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This will error out if it gets included in the build.
11 changes: 11 additions & 0 deletions users/konstantin/post_keymap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion users/konstantin/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit deb080b

Please sign in to comment.