From ba1797509da4611c4e45928fe0beebc4bded894a Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 14 Sep 2026 13:08:39 -0700 Subject: [PATCH] Key the STM32CubeMX2 configuration off a macro the pack declares --- .wolfssl_known_macro_extras | 1 + IDE/STM32Cube/MX2/README.md | 9 ++++++--- wolfssl/wolfcrypt/settings.h | 22 +++++----------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 25e01d94ea..1c2dfd2763 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -1001,6 +1001,7 @@ WOLFSSL_MONT_RED_CT WOLFSSL_MP_COND_COPY WOLFSSL_MP_INVMOD_CONSTANT_TIME WOLFSSL_MULTICIRCULATE_ALTNAMELIST +WOLFSSL_MX2_CONF_INCLUDE WOLFSSL_NETX_DUO WOLFSSL_NEW_PRIME_CHECK WOLFSSL_NOISE_SRC diff --git a/IDE/STM32Cube/MX2/README.md b/IDE/STM32Cube/MX2/README.md index 050302fab7..4e4b2345d9 100644 --- a/IDE/STM32Cube/MX2/README.md +++ b/IDE/STM32Cube/MX2/README.md @@ -14,9 +14,12 @@ rendered by a Handlebars template through `cube codegen`, producing - `mx_wolfSSL_conf_template.h.hbs` - the Handlebars template that renders `mx_wolfSSL_conf.h`. -`wolfssl/wolfcrypt/settings.h` picks the generated header up automatically -via `__has_include("mx_wolfSSL_conf.h")` (HAL2 projects have no global -define like HAL1's `USE_HAL_DRIVER`). +`wolfssl/wolfcrypt/settings.h` includes the generated header when +`WOLFSSL_MX2_CONF_INCLUDE` is defined. HAL2 projects have no global define +like HAL1's `USE_HAL_DRIVER`, so the pack's configuration component declares +that macro through the generated `Pre_Include_Global.h` that STM32CubeMX2 +force-includes. A project that adds these sources by hand, without the pack, +must define `WOLFSSL_MX2_CONF_INCLUDE` itself. These files are packaged into the `wolfSSL.wolfSSL_middlewares` pack for STM32CubeMX2 by the wolfSSL pack tooling; the pack build prefers the copies diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 870c2d856e..08096df290 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -356,19 +356,6 @@ #endif #endif -/* Probe for the STM32CubeMX2 generated configuration ahead of the chain - * below. __has_include must stay inside its own guarded block: preprocessors - * without it would otherwise fail parsing the #elif expression (the header - * name string is illegal in an integer constant expression), which the - * defined() short-circuit does not prevent. */ -#if !defined(HAVE_CONFIG_H) && !defined(WOLFSSL_USER_SETTINGS) && \ - !defined(WOLFSSL_OPTIONS_H) && !defined(WOLFSSL_NO_OPTIONS_H) && \ - !defined(WOLFSSL_CUSTOM_CONFIG) && defined(__has_include) - #if __has_include("mx_wolfSSL_conf.h") - #define WOLFSSL_MX2_CONF_INCLUDE - #endif -#endif - #ifdef WOLFSSL_USER_SETTINGS #if defined(BUILDING_WOLFSSL_ASM) && defined(WOLFSSL_USER_SETTINGS_ASM) /* @@ -390,10 +377,11 @@ #elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H) /* STM Configuration File (generated by CubeMX) */ #include "wolfSSL.I-CUBE-wolfSSL_conf.h" -#elif defined(WOLFSSL_MX2_CONF_INCLUDE) - /* STM Configuration File (generated by STM32CubeMX2). HAL2 projects - * have no global define like HAL1's USE_HAL_DRIVER, so the probe - * above detects the generated configuration header itself. */ +#elif defined(WOLFSSL_MX2_CONF_INCLUDE) && !defined(HAVE_CONFIG_H) + /* STM Configuration File (generated by STM32CubeMX2). HAL2 projects have + * no global define like HAL1's USE_HAL_DRIVER, so the wolfSSL pack's + * configuration component declares WOLFSSL_MX2_CONF_INCLUDE through the + * generated Pre_Include_Global.h, which the tool force-includes. */ #include "mx_wolfSSL_conf.h" #elif defined(NUCLEUS_PLUS_2_3) /* NOTE: cyassl_nucleus_defs.h is akin to user_settings.h */