From 87773f9cbce831258d61235da4eeaf1f58e43c1c Mon Sep 17 00:00:00 2001 From: Mariappan Ramasamy <142216110+kp-mariappan-ramasamy@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:13:34 +0800 Subject: [PATCH 1/2] wolfssl: make ProtocolVersion::{is_dtls_13,is_tls_13} public --- wolfssl/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfssl/src/lib.rs b/wolfssl/src/lib.rs index 6610b6e6..c90163ab 100644 --- a/wolfssl/src/lib.rs +++ b/wolfssl/src/lib.rs @@ -165,12 +165,12 @@ impl ProtocolVersion { } /// Checks if the protocol version is compatible with TLS 1.3 - fn is_tls_13(&self) -> bool { + pub fn is_tls_13(&self) -> bool { matches!(self, Self::TlsV1_3) } /// Checks if the protocol version is compatible with DTLS 1.3 - fn is_dtls_13(&self) -> bool { + pub fn is_dtls_13(&self) -> bool { matches!(self, Self::DtlsV1_3) } } From afb3f2932b5cf272f21e89c0e130f3a4ad32be4a Mon Sep 17 00:00:00 2001 From: Mariappan Ramasamy <142216110+kp-mariappan-ramasamy@users.noreply.github.com> Date: Tue, 15 Apr 2025 14:23:13 +0800 Subject: [PATCH 2/2] wolfssl: try printing wolfssl config in CI summary --- .github/workflows/ci.yaml | 34 ++++++++++++++++++++++++++++ Earthfile | 10 ++++++++- wolfssl-sys/build.rs | 47 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c672bc64..b5e90b32 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,6 +43,21 @@ jobs: submodules: true - name: Run +${{ matrix.target }} on Earthly run: earthly --ci +${{ matrix.target }} + - name: Extract and display WolfSSL configuration (Linux) + if: matrix.target == 'build-release' + run: | + echo "DEBUG: Listing artifacts directory" + find artifacts/ -name "wolfssl_config.json" -type f 2>/dev/null || echo "DEBUG: No wolfssl_config.json found under artifacts/" + ls -la artifacts/release/ 2>/dev/null | head -20 || echo "DEBUG: artifacts/release/ does not exist" + if [ -f artifacts/release/wolfssl_config.json ]; then + echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY + cat artifacts/release/wolfssl_config.json >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + else + echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY + echo "No configuration file found" >> $GITHUB_STEP_SUMMARY + fi coverage: runs-on: ubuntu-latest env: @@ -284,3 +299,22 @@ jobs: # Only run tests on native architecture (x64/ARM64) since cross-compilation tests won't run if: matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'aarch64-pc-windows-msvc' run: cargo test --release --target ${{ matrix.target }} -v -v + - name: Extract and display WolfSSL configuration (Windows) + run: | + # Find the wolfssl config JSON file in the target directory + $configFile = Get-ChildItem -Path target -Name "wolfssl_config.json" -Recurse -File | Select-Object -First 1 + if ($configFile) { + $configPath = Join-Path "target" $configFile + Write-Host "Found wolfssl config at: $configPath" + $configContent = Get-Content $configPath -Raw + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})" + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```json' + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $configContent + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```' + } else { + Write-Host "No wolfssl config file found" + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})" + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "No configuration file found" + } + shell: pwsh + diff --git a/Earthfile b/Earthfile index 84713ddb..083e5e65 100644 --- a/Earthfile +++ b/Earthfile @@ -67,7 +67,14 @@ build-dev: # build-release builds with the Cargo release profile and produces release artifacts build-release: FROM +copy-src - DO lib-rust+CARGO --args="build --release" --output="release/[^/]+" + DO lib-rust+CARGO --args="build --release" --output="(release/[^/]+|.*/build/.*/out/wolfssl_config\.json)" + + # Copy wolfssl configuration to release directory so it gets saved as an artifact + RUN find target -name "wolfssl_config.json" -type f && \ + find target -name "wolfssl_config.json" -type f -exec cp {} target/release/wolfssl_config.json \; && \ + echo "Config file copied successfully" && ls -la target/release/wolfssl_config.json || \ + echo "WARNING: wolfssl_config.json not found in target" + SAVE ARTIFACT target/release /release AS LOCAL artifacts/release # run-tests executes all unit and integration tests via Cargo @@ -138,6 +145,7 @@ check-dependencies: FROM +copy-src DO lib-rust+CARGO --args="deny --all-features check --deny warnings bans license sources" + # publish publishes the target crate to cargo.io. Must specify package by --PACKAGE= publish: FROM +copy-src diff --git a/wolfssl-sys/build.rs b/wolfssl-sys/build.rs index 7b965abf..d8775469 100644 --- a/wolfssl-sys/build.rs +++ b/wolfssl-sys/build.rs @@ -553,6 +553,33 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf { conf.build() } +/** + * Export WolfSSL configuration to JSON for CI consumption + */ +fn export_wolfssl_config(config_contents: &str, out_dir: &Path) -> std::io::Result<()> { + use std::io::Write; + + // Create a simple JSON structure with just the wolfssl configuration + let config_file_path = out_dir.join("wolfssl_config.json"); + let mut config_file = File::create(&config_file_path)?; + + // Write the configuration as a simple JSON object + writeln!(config_file, "{{")?; + writeln!( + config_file, + " \"wolfssl_configure_command\": {:?}", + config_contents.trim() + )?; + writeln!(config_file, "}}")?; + + println!( + "cargo::warning=WolfSSL config exported to: {}", + config_file_path.display() + ); + + Ok(()) +} + fn main() -> std::io::Result<()> { // Get the build directory let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); @@ -570,6 +597,26 @@ fn main() -> std::io::Result<()> { // Configure and build WolfSSL let wolfssl_install_dir = build_wolfssl(&wolfssl_src); + // Export config for CI consumption (Unix builds only, Windows uses MSBuild) + if build_target::target_os() != build_target::Os::Windows { + let mut config_path = PathBuf::from(&wolfssl_install_dir); + config_path.push("build/configure.prev"); + if let Ok(contents) = fs::read_to_string(config_path) { + println!("cargo::warning=WolfSSL config:{}", contents); + export_wolfssl_config(&contents, &out_dir)?; + } + } else { + // For Windows builds, export the user_settings.h content as config + let settings_path = wolfssl_install_dir.join("wolfssl").join("user_settings.h"); + if let Ok(contents) = fs::read_to_string(settings_path) { + println!( + "cargo::warning=WolfSSL Windows config (user_settings.h):{}", + contents + ); + export_wolfssl_config(&contents, &out_dir)?; + } + } + // We want to block some macros as they are incorrectly creating duplicate values // https://github.com/rust-lang/rust-bindgen/issues/687 // TODO: Reach out to tlspuffin and ask if we can incorporate this code and credit them