Skip to content

Commit 1c0fe95

Browse files
committed
Split common.mk into common.mk and common_features.mk
To support including keyboard/keymap specific rules before it
1 parent d29906c commit 1c0fe95

File tree

6 files changed

+164
-142
lines changed

6 files changed

+164
-142
lines changed

build_full_test.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ include tests/$(TEST)/rules.mk
1818

1919
TEST_PATH=tests/$(TEST)
2020

21-
$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC)
21+
$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(QUANTUM_SRC)
2222
$(TEST)_DEFS=$(TMK_COMMON_DEFS)
2323
$(TEST)_CONFIG=$(TEST_PATH)/config.h

build_keyboard.mk

+3-12
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ $(error MASTER does not have a valid value(left/right))
3131
endif
3232
endif
3333

34-
35-
3634
KEYBOARD_PATH := keyboards/$(KEYBOARD)
3735
KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c
3836

@@ -42,7 +40,6 @@ else
4240
$(error "$(KEYBOARD_C)" does not exist)
4341
endif
4442

45-
4643
ifneq ($(SUBPROJECT),)
4744
SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT)
4845
SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c
@@ -118,19 +115,12 @@ endif
118115
# # project specific files
119116
SRC += $(KEYBOARD_C) \
120117
$(KEYMAP_C) \
121-
$(QUANTUM_DIR)/quantum.c \
122-
$(QUANTUM_DIR)/keymap_common.c \
123-
$(QUANTUM_DIR)/keycode_config.c \
124-
$(QUANTUM_DIR)/process_keycode/process_leader.c
118+
$(QUANTUM_SRC)
125119

126120
ifneq ($(SUBPROJECT),)
127121
SRC += $(SUBPROJECT_C)
128122
endif
129123

130-
ifndef CUSTOM_MATRIX
131-
SRC += $(QUANTUM_DIR)/matrix.c
132-
endif
133-
134124
# Optimize size but this may cause error "relocation truncated to fit"
135125
#EXTRALDFLAGS = -Wl,--relax
136126

@@ -142,9 +132,10 @@ endif
142132
VPATH += $(KEYBOARD_PATH)
143133
VPATH += $(COMMON_VPATH)
144134

135+
include common_features.mk
145136
include $(TMK_PATH)/protocol.mk
146-
147137
include $(TMK_PATH)/common.mk
138+
148139
SRC += $(TMK_COMMON_SRC)
149140
OPT_DEFS += $(TMK_COMMON_DEFS)
150141
EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)

build_test.mk

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ all: elf
4242
VPATH += $(COMMON_VPATH)
4343
PLATFORM:=TEST
4444

45+
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
46+
include tests/$(TEST)/rules.mk
47+
endif
48+
49+
include common_features.mk
4550
include $(TMK_PATH)/common.mk
4651
include $(QUANTUM_PATH)/serial_link/tests/rules.mk
4752
ifneq ($(filter $(FULL_TESTS),$(TEST)),)

common.mk

-128
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR)
1111

1212
BUILD_DIR := $(TOP_DIR)/.build
1313

14-
SERIAL_DIR := $(QUANTUM_DIR)/serial_link
15-
SERIAL_PATH := $(QUANTUM_PATH)/serial_link
16-
SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
17-
SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
18-
SERIAL_DEFS += -DSERIAL_LINK_ENABLE
19-
2014
COMMON_VPATH := $(TOP_DIR)
2115
COMMON_VPATH += $(TMK_PATH)
2216
COMMON_VPATH += $(QUANTUM_PATH)
@@ -25,125 +19,3 @@ COMMON_VPATH += $(QUANTUM_PATH)/audio
2519
COMMON_VPATH += $(QUANTUM_PATH)/process_keycode
2620
COMMON_VPATH += $(QUANTUM_PATH)/api
2721
COMMON_VPATH += $(SERIAL_PATH)
28-
29-
ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
30-
OPT_DEFS += -DAPI_SYSEX_ENABLE
31-
SRC += $(QUANTUM_DIR)/api/api_sysex.c
32-
OPT_DEFS += -DAPI_ENABLE
33-
SRC += $(QUANTUM_DIR)/api.c
34-
MIDI_ENABLE=yes
35-
endif
36-
37-
MUSIC_ENABLE := 0
38-
39-
ifeq ($(strip $(AUDIO_ENABLE)), yes)
40-
OPT_DEFS += -DAUDIO_ENABLE
41-
MUSIC_ENABLE := 1
42-
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
43-
SRC += $(QUANTUM_DIR)/audio/audio.c
44-
SRC += $(QUANTUM_DIR)/audio/voices.c
45-
SRC += $(QUANTUM_DIR)/audio/luts.c
46-
endif
47-
48-
ifeq ($(strip $(MIDI_ENABLE)), yes)
49-
OPT_DEFS += -DMIDI_ENABLE
50-
MUSIC_ENABLE := 1
51-
SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
52-
endif
53-
54-
ifeq ($(MUSIC_ENABLE), 1)
55-
SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
56-
endif
57-
58-
ifeq ($(strip $(COMBO_ENABLE)), yes)
59-
OPT_DEFS += -DCOMBO_ENABLE
60-
SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
61-
endif
62-
63-
ifeq ($(strip $(VIRTSER_ENABLE)), yes)
64-
OPT_DEFS += -DVIRTSER_ENABLE
65-
endif
66-
67-
ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
68-
OPT_DEFS += -DFAUXCLICKY_ENABLE
69-
SRC += $(QUANTUM_DIR)/fauxclicky.c
70-
endif
71-
72-
ifeq ($(strip $(UCIS_ENABLE)), yes)
73-
OPT_DEFS += -DUCIS_ENABLE
74-
UNICODE_COMMON = yes
75-
SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
76-
endif
77-
78-
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
79-
OPT_DEFS += -DUNICODEMAP_ENABLE
80-
UNICODE_COMMON = yes
81-
SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
82-
endif
83-
84-
ifeq ($(strip $(UNICODE_ENABLE)), yes)
85-
OPT_DEFS += -DUNICODE_ENABLE
86-
UNICODE_COMMON = yes
87-
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
88-
endif
89-
90-
ifeq ($(strip $(UNICODE_COMMON)), yes)
91-
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
92-
endif
93-
94-
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
95-
OPT_DEFS += -DRGBLIGHT_ENABLE
96-
SRC += $(QUANTUM_DIR)/light_ws2812.c
97-
SRC += $(QUANTUM_DIR)/rgblight.c
98-
CIE1931_CURVE = yes
99-
LED_BREATHING_TABLE = yes
100-
endif
101-
102-
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
103-
OPT_DEFS += -DTAP_DANCE_ENABLE
104-
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
105-
endif
106-
107-
ifeq ($(strip $(PRINTING_ENABLE)), yes)
108-
OPT_DEFS += -DPRINTING_ENABLE
109-
SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
110-
SRC += $(TMK_DIR)/protocol/serial_uart.c
111-
endif
112-
113-
ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
114-
SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
115-
OPT_DEFS += $(SERIAL_DEFS)
116-
VAPTH += $(SERIAL_PATH)
117-
endif
118-
119-
ifneq ($(strip $(VARIABLE_TRACE)),)
120-
SRC += $(QUANTUM_DIR)/variable_trace.c
121-
OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
122-
ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
123-
OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
124-
endif
125-
endif
126-
127-
ifeq ($(strip $(LCD_ENABLE)), yes)
128-
CIE1931_CURVE = yes
129-
endif
130-
131-
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
132-
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
133-
CIE1931_CURVE = yes
134-
endif
135-
endif
136-
137-
ifeq ($(strip $(CIE1931_CURVE)), yes)
138-
OPT_DEFS += -DUSE_CIE1931_CURVE
139-
LED_TABLES = yes
140-
endif
141-
142-
ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
143-
OPT_DEFS += -DUSE_LED_BREATHING_TABLE
144-
LED_TABLES = yes
145-
endif
146-
147-
ifeq ($(strip $(LED_TABLES)), yes)
148-
SRC += $(QUANTUM_DIR)/led_tables.c
149-
endif

common_features.mk

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Copyright 2017 Fred Sundvik
2+
#
3+
# This program is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation, either version 2 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
SERIAL_DIR := $(QUANTUM_DIR)/serial_link
17+
SERIAL_PATH := $(QUANTUM_PATH)/serial_link
18+
SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
19+
SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
20+
SERIAL_DEFS += -DSERIAL_LINK_ENABLE
21+
22+
ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
23+
OPT_DEFS += -DAPI_SYSEX_ENABLE
24+
SRC += $(QUANTUM_DIR)/api/api_sysex.c
25+
OPT_DEFS += -DAPI_ENABLE
26+
SRC += $(QUANTUM_DIR)/api.c
27+
MIDI_ENABLE=yes
28+
endif
29+
30+
MUSIC_ENABLE := 0
31+
32+
ifeq ($(strip $(AUDIO_ENABLE)), yes)
33+
OPT_DEFS += -DAUDIO_ENABLE
34+
MUSIC_ENABLE := 1
35+
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
36+
SRC += $(QUANTUM_DIR)/audio/audio.c
37+
SRC += $(QUANTUM_DIR)/audio/voices.c
38+
SRC += $(QUANTUM_DIR)/audio/luts.c
39+
endif
40+
41+
ifeq ($(strip $(MIDI_ENABLE)), yes)
42+
OPT_DEFS += -DMIDI_ENABLE
43+
MUSIC_ENABLE := 1
44+
SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
45+
endif
46+
47+
ifeq ($(MUSIC_ENABLE), 1)
48+
SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
49+
endif
50+
51+
ifeq ($(strip $(COMBO_ENABLE)), yes)
52+
OPT_DEFS += -DCOMBO_ENABLE
53+
SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
54+
endif
55+
56+
ifeq ($(strip $(VIRTSER_ENABLE)), yes)
57+
OPT_DEFS += -DVIRTSER_ENABLE
58+
endif
59+
60+
ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
61+
OPT_DEFS += -DFAUXCLICKY_ENABLE
62+
SRC += $(QUANTUM_DIR)/fauxclicky.c
63+
endif
64+
65+
ifeq ($(strip $(UCIS_ENABLE)), yes)
66+
OPT_DEFS += -DUCIS_ENABLE
67+
UNICODE_COMMON = yes
68+
SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
69+
endif
70+
71+
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
72+
OPT_DEFS += -DUNICODEMAP_ENABLE
73+
UNICODE_COMMON = yes
74+
SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
75+
endif
76+
77+
ifeq ($(strip $(UNICODE_ENABLE)), yes)
78+
OPT_DEFS += -DUNICODE_ENABLE
79+
UNICODE_COMMON = yes
80+
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
81+
endif
82+
83+
ifeq ($(strip $(UNICODE_COMMON)), yes)
84+
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
85+
endif
86+
87+
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
88+
OPT_DEFS += -DRGBLIGHT_ENABLE
89+
SRC += $(QUANTUM_DIR)/light_ws2812.c
90+
SRC += $(QUANTUM_DIR)/rgblight.c
91+
CIE1931_CURVE = yes
92+
LED_BREATHING_TABLE = yes
93+
endif
94+
95+
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
96+
OPT_DEFS += -DTAP_DANCE_ENABLE
97+
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
98+
endif
99+
100+
ifeq ($(strip $(PRINTING_ENABLE)), yes)
101+
OPT_DEFS += -DPRINTING_ENABLE
102+
SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
103+
SRC += $(TMK_DIR)/protocol/serial_uart.c
104+
endif
105+
106+
ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
107+
SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
108+
OPT_DEFS += $(SERIAL_DEFS)
109+
VAPTH += $(SERIAL_PATH)
110+
endif
111+
112+
ifneq ($(strip $(VARIABLE_TRACE)),)
113+
SRC += $(QUANTUM_DIR)/variable_trace.c
114+
OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
115+
ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
116+
OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
117+
endif
118+
endif
119+
120+
ifeq ($(strip $(LCD_ENABLE)), yes)
121+
CIE1931_CURVE = yes
122+
endif
123+
124+
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
125+
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
126+
CIE1931_CURVE = yes
127+
endif
128+
endif
129+
130+
ifeq ($(strip $(CIE1931_CURVE)), yes)
131+
OPT_DEFS += -DUSE_CIE1931_CURVE
132+
LED_TABLES = yes
133+
endif
134+
135+
ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
136+
OPT_DEFS += -DUSE_LED_BREATHING_TABLE
137+
LED_TABLES = yes
138+
endif
139+
140+
ifeq ($(strip $(LED_TABLES)), yes)
141+
SRC += $(QUANTUM_DIR)/led_tables.c
142+
endif
143+
144+
QUANTUM_SRC:= \
145+
$(QUANTUM_DIR)/quantum.c \
146+
$(QUANTUM_DIR)/keymap_common.c \
147+
$(QUANTUM_DIR)/keycode_config.c \
148+
$(QUANTUM_DIR)/process_keycode/process_leader.c
149+
150+
ifndef CUSTOM_MATRIX
151+
QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
152+
endif

tests/basic/rules.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
# GNU General Public License for more details.
1212
#
1313
# You should have received a copy of the GNU General Public License
14-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
CUSTOM_MATRIX=yes

0 commit comments

Comments
 (0)