Skip to content

Commit

Permalink
Infer more when building features (qmk#13890)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored Oct 17, 2021
1 parent 0422fb8 commit 037428b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 83 deletions.
1 change: 1 addition & 0 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ VPATH += $(KEYBOARD_PATHS)
VPATH += $(COMMON_VPATH)

include common_features.mk
include generic_features.mk
include $(TMK_PATH)/protocol.mk
include $(TMK_PATH)/common.mk
include bootloader.mk
Expand Down
1 change: 1 addition & 0 deletions build_test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ include tests/$(TEST)/rules.mk
endif

include common_features.mk
include generic_features.mk
include $(TMK_PATH)/common.mk
include $(QUANTUM_PATH)/debounce/tests/rules.mk
include $(QUANTUM_PATH)/sequencer/tests/rules.mk
Expand Down
83 changes: 0 additions & 83 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ else ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), api)
OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
endif

ifeq ($(strip $(COMMAND_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/command.c
OPT_DEFS += -DCOMMAND_ENABLE
endif

AUDIO_ENABLE ?= no
ifeq ($(strip $(AUDIO_ENABLE)), yes)
ifeq ($(PLATFORM),CHIBIOS)
Expand Down Expand Up @@ -118,12 +113,6 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/pointing_device.c
endif

ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes)
OPT_DEFS += -DPROGRAMMABLE_BUTTON_ENABLE
SRC += $(QUANTUM_DIR)/programmable_button.c
SRC += $(QUANTUM_DIR)/process_keycode/process_programmable_button.c
endif

VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi
EEPROM_DRIVER ?= vendor
ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
Expand Down Expand Up @@ -419,21 +408,6 @@ ifeq ($(strip $(TERMINAL_ENABLE)), yes)
OPT_DEFS += -DUSER_PRINT
endif

ifeq ($(strip $(WPM_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/wpm.c
OPT_DEFS += -DWPM_ENABLE
endif

ifeq ($(strip $(ENCODER_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/encoder.c
OPT_DEFS += -DENCODER_ENABLE
endif

ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
OPT_DEFS += -DVELOCIKEY_ENABLE
SRC += $(QUANTUM_DIR)/velocikey.c
endif

ifeq ($(strip $(VIA_ENABLE)), yes)
DYNAMIC_KEYMAP_ENABLE := yes
RAW_ENABLE := yes
Expand All @@ -442,16 +416,6 @@ ifeq ($(strip $(VIA_ENABLE)), yes)
OPT_DEFS += -DVIA_ENABLE
endif

ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
SRC += $(QUANTUM_DIR)/dynamic_keymap.c
endif

ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
OPT_DEFS += -DDIP_SWITCH_ENABLE
SRC += $(QUANTUM_DIR)/dip_switch.c
endif

VALID_MAGIC_TYPES := yes lite
BOOTMAGIC_ENABLE ?= no
ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
Expand Down Expand Up @@ -602,54 +566,12 @@ ifeq ($(strip $(UNICODE_COMMON)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
endif

SPACE_CADET_ENABLE ?= yes
ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
OPT_DEFS += -DSPACE_CADET_ENABLE
endif

MAGIC_ENABLE ?= yes
ifeq ($(strip $(MAGIC_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
endif

GRAVE_ESC_ENABLE ?= yes
ifeq ($(strip $(GRAVE_ESC_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_grave_esc.c
OPT_DEFS += -DGRAVE_ESC_ENABLE
endif

ifeq ($(strip $(DYNAMIC_MACRO_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_dynamic_macro.c
OPT_DEFS += -DDYNAMIC_MACRO_ENABLE
endif

ifeq ($(strip $(COMBO_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
OPT_DEFS += -DCOMBO_ENABLE
endif

ifeq ($(strip $(KEY_OVERRIDE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_key_override.c
OPT_DEFS += -DKEY_OVERRIDE_ENABLE
endif

ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
OPT_DEFS += -DTAP_DANCE_ENABLE
endif

ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
OPT_DEFS += -DKEY_LOCK_ENABLE
endif

ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
OPT_DEFS += -DLEADER_ENABLE
endif

ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
OPT_DEFS += -DAUTO_SHIFT_ENABLE
Expand Down Expand Up @@ -678,11 +600,6 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
endif
endif

DIGITIZER_ENABLE ?= no
ifneq ($(strip $(DIGITIZER_ENABLE)), no)
SRC += $(QUANTUM_DIR)/digitizer.c
endif

USBPD_ENABLE ?= no
VALID_USBPD_DRIVER_TYPES = custom vendor
USBPD_DRIVER ?= vendor
Expand Down
48 changes: 48 additions & 0 deletions generic_features.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2021 QMK
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

SPACE_CADET_ENABLE ?= yes
GRAVE_ESC_ENABLE ?= yes

GENERIC_FEATURES = \
COMBO \
COMMAND \
DIGITIZER \
DIP_SWITCH \
DYNAMIC_KEYMAP \
DYNAMIC_MACRO \
ENCODER \
GRAVE_ESC \
KEY_LOCK \
KEY_OVERRIDE \
LEADER \
PROGRAMMABLE_BUTTON \
SPACE_CADET \
TAP_DANCE \
VELOCIKEY \
WPM \

define HANDLE_GENERIC_FEATURE
# $$(info "Processing: $1_ENABLE $2.c")
SRC += $$(wildcard $$(QUANTUM_DIR)/process_keycode/process_$2.c)
SRC += $$(wildcard $$(QUANTUM_DIR)/$2.c)
OPT_DEFS += -D$1_ENABLE
endef

$(foreach F,$(GENERIC_FEATURES),\
$(if $(filter yes, $(strip $($(F)_ENABLE))),\
$(eval $(call HANDLE_GENERIC_FEATURE,$(F),$(shell echo $(F) | tr '[:upper:]' '[:lower:]'))) \
) \
)

0 comments on commit 037428b

Please sign in to comment.