Skip to content

Commit 43322c8

Browse files
wolfssl: try printing wolfssl config in CI summary
1 parent f2d3de0 commit 43322c8

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ jobs:
4242
submodules: true
4343
- name: Run +${{ matrix.target }} on Earthly
4444
run: earthly --ci +${{ matrix.target }}
45+
- name: Extract and display WolfSSL configuration (Linux)
46+
if: matrix.target == 'build-release'
47+
run: |
48+
if [ -f target/release/wolfssl_config.json ]; then
49+
echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY
50+
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
51+
cat target/release/wolfssl_config.json >> $GITHUB_STEP_SUMMARY
52+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
53+
else
54+
echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY
55+
echo "No configuration file found" >> $GITHUB_STEP_SUMMARY
56+
fi
4557
coverage:
4658
runs-on: ubuntu-latest
4759
env:
@@ -213,3 +225,22 @@ jobs:
213225
# Only run tests on native architecture (x64) since cross-compilation tests won't run
214226
if: matrix.target == 'x86_64-pc-windows-msvc'
215227
run: cargo test --release --target ${{ matrix.target }} -v -v
228+
- name: Extract and display WolfSSL configuration (Windows)
229+
run: |
230+
# Find the wolfssl config JSON file in the target directory
231+
$configFile = Get-ChildItem -Path target -Name "wolfssl_config.json" -Recurse -File | Select-Object -First 1
232+
if ($configFile) {
233+
$configPath = Join-Path "target" $configFile
234+
Write-Host "Found wolfssl config at: $configPath"
235+
$configContent = Get-Content $configPath -Raw
236+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})"
237+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```json'
238+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $configContent
239+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```'
240+
} else {
241+
Write-Host "No wolfssl config file found"
242+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})"
243+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "No configuration file found"
244+
}
245+
shell: pwsh
246+

Earthfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ build-dev:
5454
build-release:
5555
FROM +copy-src
5656
DO lib-rust+CARGO --args="build --release" --output="release/[^/]+"
57+
58+
# Display wolfssl configuration if available
59+
RUN if [ -f target/release/wolfssl_config.json ]; then \
60+
echo "=== WolfSSL Configuration ===" && \
61+
cat target/release/wolfssl_config.json && \
62+
echo "=== End Configuration ==="; \
63+
else \
64+
echo "No wolfssl config found"; \
65+
fi
66+
5767
SAVE ARTIFACT target/release /release AS LOCAL artifacts/release
5868

5969
# run-tests executes all unit and integration tests via Cargo
@@ -120,6 +130,7 @@ check-dependencies:
120130
FROM +copy-src
121131
DO lib-rust+CARGO --args="deny --all-features check --deny warnings bans license sources"
122132

133+
123134
# publish publishes the target crate to cargo.io. Must specify package by --PACKAGE=<package-name>
124135
publish:
125136
FROM +copy-src

wolfssl-sys/build.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,53 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf {
475475
conf.build()
476476
}
477477

478+
/**
479+
* Export WolfSSL configuration to JSON for CI consumption
480+
*/
481+
fn export_wolfssl_config(config_contents: &str, out_dir: &Path) -> std::io::Result<()> {
482+
use std::io::Write;
483+
484+
// Create a simple JSON structure with just the wolfssl configuration
485+
let config_file_path = out_dir.join("wolfssl_config.json");
486+
let mut config_file = File::create(&config_file_path)?;
487+
488+
// Write the configuration as a simple JSON object
489+
writeln!(config_file, "{{")?;
490+
writeln!(config_file, " \"wolfssl_configure_command\": {:?}", config_contents.trim())?;
491+
writeln!(config_file, "}}")?;
492+
493+
println!("cargo::warning=WolfSSL config exported to: {}", config_file_path.display());
494+
495+
// Also copy to target directory for Earthly/CI to pick up
496+
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| {
497+
// If no CARGO_TARGET_DIR is set, we need to go up one level from wolfssl-sys to the workspace root
498+
"../target".to_string()
499+
});
500+
501+
// Determine the build profile (debug or release)
502+
let profile = if cfg!(debug_assertions) { "debug" } else { "release" };
503+
504+
// For native builds, cargo puts artifacts directly in target/{profile}
505+
// For cross-compilation, it uses target/{target-triple}/{profile}
506+
// But we want to always put our config in target/{profile} for simplicity
507+
let target_config_path = PathBuf::from(&target_dir).join(&profile).join("wolfssl_config.json");
508+
509+
// Create target directory if it doesn't exist
510+
if let Some(parent) = target_config_path.parent() {
511+
if let Err(e) = fs::create_dir_all(parent) {
512+
println!("cargo::warning=Failed to create directory {}: {}", parent.display(), e);
513+
return Ok(());
514+
}
515+
}
516+
517+
match fs::copy(&config_file_path, &target_config_path) {
518+
Ok(_) => println!("cargo::warning=WolfSSL config also copied to: {}", target_config_path.display()),
519+
Err(e) => println!("cargo::warning=Failed to copy config to {}: {}", target_config_path.display(), e),
520+
}
521+
522+
Ok(())
523+
}
524+
478525
fn main() -> std::io::Result<()> {
479526
// Get the build directory
480527
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
@@ -492,6 +539,23 @@ fn main() -> std::io::Result<()> {
492539
// Configure and build WolfSSL
493540
let wolfssl_install_dir = build_wolfssl(&wolfssl_src);
494541

542+
// Export config for CI consumption (Unix builds only, Windows uses MSBuild)
543+
if build_target::target_os() != build_target::Os::Windows {
544+
let mut config_path = PathBuf::from(&wolfssl_install_dir);
545+
config_path.push("build/configure.prev");
546+
if let Ok(contents) = fs::read_to_string(config_path) {
547+
println!("cargo::warning=WolfSSL config:{}", contents);
548+
export_wolfssl_config(&contents, &out_dir)?;
549+
}
550+
} else {
551+
// For Windows builds, export the user_settings.h content as config
552+
let settings_path = wolfssl_install_dir.join("wolfssl").join("user_settings.h");
553+
if let Ok(contents) = fs::read_to_string(settings_path) {
554+
println!("cargo::warning=WolfSSL Windows config (user_settings.h):{}", contents);
555+
export_wolfssl_config(&contents, &out_dir)?;
556+
}
557+
}
558+
495559
// We want to block some macros as they are incorrectly creating duplicate values
496560
// https://github.com/rust-lang/rust-bindgen/issues/687
497561
// TODO: Reach out to tlspuffin and ask if we can incorporate this code and credit them

0 commit comments

Comments
 (0)