Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-duplicate platform detection #19603

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions builddefs/build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ include $(BUILDDEFS_PATH)/converters.mk

include $(BUILDDEFS_PATH)/mcu_selection.mk

# PLATFORM_KEY should be detected in info.json via key 'processor' (or rules.mk 'MCU')
ifeq ($(PLATFORM_KEY),)
$(call CATASTROPHIC_ERROR,Platform not defined)
endif
PLATFORM=$(shell echo $(PLATFORM_KEY) | tr '[:lower:]' '[:upper:]')

# Find all the C source files to be compiled in subfolders.
KEYBOARD_SRC :=

Expand Down Expand Up @@ -257,24 +263,6 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).h)","")
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h
endif

# Determine and set parameters based on the keyboard's processor family.
# We can assume a ChibiOS target When MCU_FAMILY is defined since it's
# not used for LUFA
ifdef MCU_FAMILY
PLATFORM=CHIBIOS
PLATFORM_KEY=chibios
FIRMWARE_FORMAT?=bin
OPT_DEFS += -DMCU_$(MCU_FAMILY)
else ifdef ARM_ATSAM
PLATFORM=ARM_ATSAM
PLATFORM_KEY=arm_atsam
FIRMWARE_FORMAT=bin
else
PLATFORM=AVR
PLATFORM_KEY=avr
FIRMWARE_FORMAT?=hex
endif

# Find all of the config.h files and add them to our CONFIG_H define.
CONFIG_H :=
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","")
Expand Down
1 change: 1 addition & 0 deletions builddefs/converters.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ifneq ($(CONVERT_TO),)

-include $(CONVERTER)/pre_converter.mk

PLATFORM_KEY = $(shell echo $(CONVERTER) | rev | cut -d "/" -f4 | rev)
TARGET := $(TARGET)_$(CONVERT_TO)

# Configure any defaults
Expand Down
2 changes: 2 additions & 0 deletions data/mappings/info_rules.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"PS2_MOUSE_ENABLE": {"info_key": "ps2.mouse_enabled", "value_type": "bool"},
"PS2_DRIVER": {"info_key": "ps2.driver"},

"PLATFORM_KEY": {"info_key": "platform_key", "to_json": false},

// Items we want flagged in lint
"CTPC": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"},
"CONVERT_TO_PROTON_C": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"},
Expand Down
3 changes: 3 additions & 0 deletions lib/python/qmk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,15 @@ def arm_processor_rules(info_data, rules):
"""
info_data['processor_type'] = 'arm'
info_data['protocol'] = 'ChibiOS'
info_data['platform_key'] = 'chibios'

if 'STM32' in info_data['processor']:
info_data['platform'] = 'STM32'
elif 'MCU_SERIES' in rules:
info_data['platform'] = rules['MCU_SERIES']
elif 'ARM_ATSAM' in rules:
info_data['platform'] = 'ARM_ATSAM'
info_data['platform_key'] = 'arm_atsam'

return info_data

Expand All @@ -767,6 +769,7 @@ def avr_processor_rules(info_data, rules):
"""
info_data['processor_type'] = 'avr'
info_data['platform'] = rules['ARCH'] if 'ARCH' in rules else 'unknown'
info_data['platform_key'] = 'avr'
info_data['protocol'] = 'V-USB' if info_data['processor'] in VUSB_PROCESSORS else 'LUFA'

# FIXME(fauxpark/anyone): Eventually we should detect the protocol by looking at PROTOCOL inherited from mcu_selection.mk:
Expand Down
2 changes: 2 additions & 0 deletions platforms/arm_atsam/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
# which functions may be overridden.

FIRMWARE_FORMAT?=bin

ifeq ($(strip $(BOOTLOADER)), custom)
OPT_DEFS += -DBOOTLOADER_CUSTOM
BOOTLOADER_TYPE = custom
Expand Down
2 changes: 2 additions & 0 deletions platforms/avr/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# BOOTLOADER_SIZE can still be defined manually, but it's recommended
# you add any possible configuration to this list

FIRMWARE_FORMAT?=hex

ifeq ($(strip $(BOOTLOADER)), custom)
OPT_DEFS += -DBOOTLOADER_CUSTOM
BOOTLOADER_TYPE = custom
Expand Down
2 changes: 2 additions & 0 deletions platforms/chibios/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
# which functions may be overridden.

FIRMWARE_FORMAT?=bin

ifeq ($(strip $(BOOTLOADER)), custom)
OPT_DEFS += -DBOOTLOADER_CUSTOM
BOOTLOADER_TYPE = custom
Expand Down
3 changes: 3 additions & 0 deletions platforms/chibios/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ LDFLAGS += $(SHARED_LDFLAGS) $(SHARED_LDSYMBOLS) $(TOOLCHAIN_LDFLAGS) $(TOOLCHA
# Tell QMK that we are hosting it on ChibiOS.
OPT_DEFS += -DPROTOCOL_CHIBIOS

# And what flavor of MCU
OPT_DEFS += -DMCU_$(MCU_FAMILY)

# ChibiOS supports synchronization primitives like a Mutex
OPT_DEFS += -DPLATFORM_SUPPORTS_SYNCHRONIZATION

Expand Down