Skip to content

Commit 2cc5ea3

Browse files
wolfssl: try printing wolfssl config in CI summary
1 parent f2d3de0 commit 2cc5ea3

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717

1818
jobs:
1919
ci:
20-
needs: [earthly, coverage, build-ios, build-tvos, build-windows]
20+
needs: [earthly, coverage, build-ios, build-tvos, build-windows, wolfssl-config]
2121
runs-on: ubuntu-latest
2222
if: always()
2323
steps:
@@ -213,3 +213,40 @@ jobs:
213213
# Only run tests on native architecture (x64) since cross-compilation tests won't run
214214
if: matrix.target == 'x86_64-pc-windows-msvc'
215215
run: cargo test --release --target ${{ matrix.target }} -v -v
216+
wolfssl-config:
217+
runs-on: ubuntu-latest
218+
env:
219+
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
220+
FORCE_COLOR: 1
221+
steps:
222+
- uses: earthly/actions-setup@v1
223+
with:
224+
version: v0.8.3
225+
github-token: ${{ secrets.GITHUB_TOKEN }}
226+
- uses: actions/checkout@v4
227+
with:
228+
submodules: true
229+
- name: Extract and display WolfSSL configuration
230+
id: config
231+
run: |
232+
earthly --ci --artifact +extract-wolfssl-config/wolfssl_config.json config.json
233+
echo "WolfSSL Configuration:"
234+
cat config.json
235+
236+
# Format for GitHub Actions output
237+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
238+
echo "config<<$EOF" >> "$GITHUB_OUTPUT"
239+
cat config.json >> "$GITHUB_OUTPUT"
240+
echo "$EOF" >> "$GITHUB_OUTPUT"
241+
- uses: actions/upload-artifact@v4
242+
with:
243+
name: wolfssl-config
244+
path: config.json
245+
if-no-files-found: error
246+
- name: Display config summary
247+
run: |
248+
echo "## WolfSSL Build Configuration" >> $GITHUB_STEP_SUMMARY
249+
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
250+
cat config.json >> $GITHUB_STEP_SUMMARY
251+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
252+

Earthfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ check-dependencies:
120120
FROM +copy-src
121121
DO lib-rust+CARGO --args="deny --all-features check --deny warnings bans license sources"
122122

123+
# extract-wolfssl-config builds and extracts the wolfssl configuration used in the build
124+
extract-wolfssl-config:
125+
FROM +copy-src
126+
127+
DO lib-rust+SET_CACHE_MOUNTS_ENV
128+
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \
129+
cargo build --package wolfssl-sys
130+
131+
# Find the wolfssl config JSON file in the target directory
132+
RUN find target -name "wolfssl_config.json" -type f -exec cat {} \; > /tmp/wolfssl_config.json
133+
134+
# Display the configuration
135+
RUN echo "=== WolfSSL Configuration ===" && \
136+
cat /tmp/wolfssl_config.json && \
137+
echo "=== End Configuration ==="
138+
139+
SAVE ARTIFACT /tmp/wolfssl_config.json wolfssl_config.json AS LOCAL artifacts/config/
140+
123141
# publish publishes the target crate to cargo.io. Must specify package by --PACKAGE=<package-name>
124142
publish:
125143
FROM +copy-src

wolfssl-sys/build.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,26 @@ 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+
Ok(())
496+
}
497+
478498
fn main() -> std::io::Result<()> {
479499
// Get the build directory
480500
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
@@ -492,6 +512,23 @@ fn main() -> std::io::Result<()> {
492512
// Configure and build WolfSSL
493513
let wolfssl_install_dir = build_wolfssl(&wolfssl_src);
494514

515+
// Export config for CI consumption (Unix builds only, Windows uses MSBuild)
516+
if build_target::target_os() != build_target::Os::Windows {
517+
let mut config_path = PathBuf::from(&wolfssl_install_dir);
518+
config_path.push("build/configure.prev");
519+
if let Ok(contents) = fs::read_to_string(config_path) {
520+
println!("cargo::warning=WolfSSL config:{}", contents);
521+
export_wolfssl_config(&contents, &out_dir)?;
522+
}
523+
} else {
524+
// For Windows builds, export the user_settings.h content as config
525+
let settings_path = wolfssl_install_dir.join("wolfssl").join("user_settings.h");
526+
if let Ok(contents) = fs::read_to_string(settings_path) {
527+
println!("cargo::warning=WolfSSL Windows config (user_settings.h):{}", contents);
528+
export_wolfssl_config(&contents, &out_dir)?;
529+
}
530+
}
531+
495532
// We want to block some macros as they are incorrectly creating duplicate values
496533
// https://github.com/rust-lang/rust-bindgen/issues/687
497534
// TODO: Reach out to tlspuffin and ask if we can incorporate this code and credit them

0 commit comments

Comments
 (0)