FPC currently supports using board aliases which then loads the underlying controller unit automatically (see e.g.
ARDUINO_DUE and
ARDIUNO_LEONARDO}. Unfortunately (in my opinion) the board alias is currently treated as another separate controller type (see
ct_arduinoleonardo vs
ct_atmega32u4).
This leads to redundant checks, for example the usb.pas unit written for the atmega32u4 (MCU on the Arduino Leonardo and Pro Micro boards) contain checks for
FPC_MCU_ARDUINOLEONARDO. This unit does not compile correctly if the user specifies that the
atmega32u4 controller is used, even though it should. The workaround is to include all possible board aliases and the MCU in the conditional check, which is redundant since the board definition implicitly encapsulates the controller type.
My proposal is to remove board aliases from the list of controller types, moving board aliases to a separate list that contains a reference to the underlying controller. When a user then specifies a board alias, the compiler should then generate the controller define (e.g. FPC_MCU_ATMEGA32U4) when the board alias is specified, and the board alias should then be defined as a separate value (e.g. FPC_BOARD_LEONARDO).
To not add yet another command line option, I also propose to re-use the -Wp command line option to specify either the board alias or the controller name.
Any comments on this suggestion?