Skip to content

Commit 23e9a7c

Browse files
authored
Merge pull request #117 from roberthdevries/simplify-feature-enable-variable-string
Simplify generating feature enabled variables using an f-string.
2 parents d34abdb + 1723007 commit 23e9a7c

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

scripts/build_ffi.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -458,45 +458,45 @@ def build_ffi(local_wolfssl, features):
458458
#include <wolfssl/wolfcrypt/dilithium.h>
459459
"""
460460

461-
init_source_string = """
461+
init_source_string = f"""
462462
#ifdef __cplusplus
463-
extern "C" {
463+
extern "C" {{
464464
#endif
465-
""" + includes_string + """
465+
{includes_string}
466466
#ifdef __cplusplus
467-
}
467+
}}
468468
#endif
469469
470-
int ERROR_STRINGS_ENABLED = """ + str(features["ERROR_STRINGS"]) + """;
471-
int MPAPI_ENABLED = """ + str(features["MPAPI"]) + """;
472-
int SHA_ENABLED = """ + str(features["SHA"]) + """;
473-
int SHA256_ENABLED = """ + str(features["SHA256"]) + """;
474-
int SHA384_ENABLED = """ + str(features["SHA384"]) + """;
475-
int SHA512_ENABLED = """ + str(features["SHA512"]) + """;
476-
int SHA3_ENABLED = """ + str(features["SHA3"]) + """;
477-
int DES3_ENABLED = """ + str(features["DES3"]) + """;
478-
int AES_ENABLED = """ + str(features["AES"]) + """;
479-
int AES_SIV_ENABLED = """ + str(features["AES_SIV"]) + """;
480-
int CHACHA_ENABLED = """ + str(features["CHACHA"]) + """;
481-
int HMAC_ENABLED = """ + str(features["HMAC"]) + """;
482-
int RSA_ENABLED = """ + str(features["RSA"]) + """;
483-
int RSA_BLINDING_ENABLED = """ + str(features["RSA_BLINDING"]) + """;
484-
int ECC_TIMING_RESISTANCE_ENABLED = """ + str(features["ECC_TIMING_RESISTANCE"]) + """;
485-
int ECC_ENABLED = """ + str(features["ECC"]) + """;
486-
int ED25519_ENABLED = """ + str(features["ED25519"]) + """;
487-
int ED448_ENABLED = """ + str(features["ED448"]) + """;
488-
int KEYGEN_ENABLED = """ + str(features["KEYGEN"]) + """;
489-
int PWDBASED_ENABLED = """ + str(features["PWDBASED"]) + """;
490-
int FIPS_ENABLED = """ + str(features["FIPS"]) + """;
491-
int FIPS_VERSION = """ + str(features["FIPS_VERSION"]) + """;
492-
int ASN_ENABLED = """ + str(features["ASN"]) + """;
493-
int WC_RNG_SEED_CB_ENABLED = """ + str(features["WC_RNG_SEED_CB"]) + """;
494-
int AESGCM_STREAM_ENABLED = """ + str(features["AESGCM_STREAM"]) + """;
495-
int RSA_PSS_ENABLED = """ + str(features["RSA_PSS"]) + """;
496-
int CHACHA20_POLY1305_ENABLED = """ + str(features["CHACHA20_POLY1305"]) + """;
497-
int ML_KEM_ENABLED = """ + str(features["ML_KEM"]) + """;
498-
int ML_DSA_ENABLED = """ + str(features["ML_DSA"]) + """;
499-
int HKDF_ENABLED = """ + str(features["HKDF"]) + """;
470+
int ERROR_STRINGS_ENABLED = {features["ERROR_STRINGS"]};
471+
int MPAPI_ENABLED = {features["MPAPI"]};
472+
int SHA_ENABLED = {features["SHA"]};
473+
int SHA256_ENABLED = {features["SHA256"]};
474+
int SHA384_ENABLED = {features["SHA384"]};
475+
int SHA512_ENABLED = {features["SHA512"]};
476+
int SHA3_ENABLED = {features["SHA3"]};
477+
int DES3_ENABLED = {features["DES3"]};
478+
int AES_ENABLED = {features["AES"]};
479+
int AES_SIV_ENABLED = {features["AES_SIV"]};
480+
int CHACHA_ENABLED = {features["CHACHA"]};
481+
int HMAC_ENABLED = {features["HMAC"]};
482+
int RSA_ENABLED = {features["RSA"]};
483+
int RSA_BLINDING_ENABLED = {features["RSA_BLINDING"]};
484+
int ECC_TIMING_RESISTANCE_ENABLED = {features["ECC_TIMING_RESISTANCE"]};
485+
int ECC_ENABLED = {features["ECC"]};
486+
int ED25519_ENABLED = {features["ED25519"]};
487+
int ED448_ENABLED = {features["ED448"]};
488+
int KEYGEN_ENABLED = {features["KEYGEN"]};
489+
int PWDBASED_ENABLED = {features["PWDBASED"]};
490+
int FIPS_ENABLED = {features["FIPS"]};
491+
int FIPS_VERSION = {features["FIPS_VERSION"]};
492+
int ASN_ENABLED = {features["ASN"]};
493+
int WC_RNG_SEED_CB_ENABLED = {features["WC_RNG_SEED_CB"]};
494+
int AESGCM_STREAM_ENABLED = {features["AESGCM_STREAM"]};
495+
int RSA_PSS_ENABLED = {features["RSA_PSS"]};
496+
int CHACHA20_POLY1305_ENABLED = {features["CHACHA20_POLY1305"]};
497+
int ML_KEM_ENABLED = {features["ML_KEM"]};
498+
int ML_DSA_ENABLED = {features["ML_DSA"]};
499+
int HKDF_ENABLED = {features["HKDF"]};
500500
"""
501501

502502
ffibuilder.set_source( "wolfcrypt._ffi", init_source_string,

0 commit comments

Comments
 (0)