Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ 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: |
if [ -f target/release/wolfssl_config.json ]; then
echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
cat target/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:
Expand Down Expand Up @@ -213,3 +225,22 @@ jobs:
# Only run tests on native architecture (x64) since cross-compilation tests won't run
if: matrix.target == 'x86_64-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

11 changes: 11 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ build-dev:
build-release:
FROM +copy-src
DO lib-rust+CARGO --args="build --release" --output="release/[^/]+"

# Display wolfssl configuration if available
RUN if [ -f target/release/wolfssl_config.json ]; then \
echo "=== WolfSSL Configuration ===" && \
cat target/release/wolfssl_config.json && \
echo "=== End Configuration ==="; \
else \
echo "No wolfssl config found"; \
fi

SAVE ARTIFACT target/release /release AS LOCAL artifacts/release

# run-tests executes all unit and integration tests via Cargo
Expand Down Expand Up @@ -120,6 +130,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=<package-name>
publish:
FROM +copy-src
Expand Down
64 changes: 64 additions & 0 deletions wolfssl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,53 @@ 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());

// Also copy to target directory for Earthly/CI to pick up
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| {
// If no CARGO_TARGET_DIR is set, we need to go up one level from wolfssl-sys to the workspace root
"../target".to_string()
});

// Determine the build profile (debug or release)
let profile = if cfg!(debug_assertions) { "debug" } else { "release" };

// For native builds, cargo puts artifacts directly in target/{profile}
// For cross-compilation, it uses target/{target-triple}/{profile}
// But we want to always put our config in target/{profile} for simplicity
let target_config_path = PathBuf::from(&target_dir).join(&profile).join("wolfssl_config.json");

// Create target directory if it doesn't exist
if let Some(parent) = target_config_path.parent() {
if let Err(e) = fs::create_dir_all(parent) {
println!("cargo::warning=Failed to create directory {}: {}", parent.display(), e);
return Ok(());
}
}

match fs::copy(&config_file_path, &target_config_path) {
Ok(_) => println!("cargo::warning=WolfSSL config also copied to: {}", target_config_path.display()),
Err(e) => println!("cargo::warning=Failed to copy config to {}: {}", target_config_path.display(), e),
}

Ok(())
}

fn main() -> std::io::Result<()> {
// Get the build directory
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
Expand All @@ -492,6 +539,23 @@ 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
Expand Down
Loading