From db4ebfb77e053e3e3e032bcb4fd02af957cfb5ca Mon Sep 17 00:00:00 2001 From: mgrojo Date: Fri, 28 Mar 2025 18:16:06 +0100 Subject: [PATCH] Allow use of the library with an Alire pin - Allow enabling WOLFSSL_STATIC_PSK via an Alire configuration variable - `gnat.adc` applies unconditionally when using the library through Alire, so it has been renamed and used only in the default project file. - Clean-up of the Alire project file `wolfssl.gpr`. --- wrapper/Ada/alire.toml | 3 ++ wrapper/Ada/default.gpr | 4 +++ wrapper/Ada/{gnat.adc => restricted.adc} | 0 wrapper/Ada/wolfssl.gpr | 45 +++++++++++------------- 4 files changed, 27 insertions(+), 25 deletions(-) rename wrapper/Ada/{gnat.adc => restricted.adc} (100%) diff --git a/wrapper/Ada/alire.toml b/wrapper/Ada/alire.toml index 0334e4a11..025f0b5a5 100644 --- a/wrapper/Ada/alire.toml +++ b/wrapper/Ada/alire.toml @@ -9,3 +9,6 @@ licenses = "GPL-2.0-only" website = "https://www.wolfssl.com/" project-files = ["wolfssl.gpr"] tags = ["ssl", "tls", "embedded", "spark"] + +[configuration.variables] +STATIC_PSK = {type = "Boolean", default = false} \ No newline at end of file diff --git a/wrapper/Ada/default.gpr b/wrapper/Ada/default.gpr index 42dcd745c..c59c3e347 100644 --- a/wrapper/Ada/default.gpr +++ b/wrapper/Ada/default.gpr @@ -26,6 +26,10 @@ project Default is for Spec_Suffix ("C") use ".h"; end Naming; + package Builder is + for Global_Configuration_Pragmas use "restricted.adc"; + end Builder; + package Compiler is for Switches ("C") use ("-DWOLFSSL_USER_SETTINGS", -- Use the user_settings.h file. diff --git a/wrapper/Ada/gnat.adc b/wrapper/Ada/restricted.adc similarity index 100% rename from wrapper/Ada/gnat.adc rename to wrapper/Ada/restricted.adc diff --git a/wrapper/Ada/wolfssl.gpr b/wrapper/Ada/wolfssl.gpr index 65d8cce6f..060c2bc6a 100644 --- a/wrapper/Ada/wolfssl.gpr +++ b/wrapper/Ada/wolfssl.gpr @@ -1,10 +1,8 @@ +with "config/wolfssl_config.gpr"; + library project WolfSSL is for Library_Name use "wolfssl"; - -- for Library_Version use Project'Library_Name & ".so"; - type OS_Kind is ("Windows", "Linux_Or_Mac"); - - OS : OS_Kind := external ("OS", "Linux_Or_Mac"); for Languages use ("C", "Ada"); @@ -15,12 +13,13 @@ library project WolfSSL is -- Don't build the tls client or server application. -- They are not needed in order to build the library. - for Excluded_Source_Files use ("tls_client_main.adb", - "tls_client.ads", - "tls_client.adb", - "tls_server_main.adb", - "tls_server.ads", - "tls_server.adb"); + for Excluded_Source_Files use + ("tls_client_main.adb", + "tls_client.ads", + "tls_client.adb", + "tls_server_main.adb", + "tls_server.ads", + "tls_server.adb"); for Object_Dir use "obj"; for Library_Dir use "lib"; @@ -34,12 +33,19 @@ library project WolfSSL is for Spec_Suffix ("C") use ".h"; end Naming; - package Builder is - for Global_Configuration_Pragmas use "gnat.adc"; - end Builder; + C_Compiler_Config := (); + + case Wolfssl_Config.STATIC_PSK is + when "True" => + C_Compiler_Config := + ("-DWOLFSSL_STATIC_PSK" -- Enable the static PSK cipher support + ); + when others => + C_Compiler_Config := (); + end case; package Compiler is - for Switches ("C") use + for Switches ("C") use C_Compiler_Config & ("-DWOLFSSL_USER_SETTINGS", -- Use the user_settings.h file. "-Wno-pragmas", "-Wall", @@ -81,16 +87,5 @@ library project WolfSSL is package Binder is for Switches ("Ada") use ("-Es"); -- To include stack traces. end Binder; - --- case OS is --- when "Windows" => --- for Library_Options use ("-lm", -- To include the math library (used by WolfSSL). --- "-lcrypt32"); -- Needed on Windows. --- when "Linux_Or_Mac" => --- for Library_Options use ("-lm"); -- To include the math library (used by WolfSSL). --- end case; --- --- -- Put user options in front, for options like --as-needed. --- for Leading_Library_Options use External_As_List ("LDFLAGS", " "); end WolfSSl;