From 7b5d3e9833399f68e78e9f2fe83ba93be7241d8c Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Thu, 14 Jul 2022 09:08:38 -0700 Subject: [PATCH 1/4] Update PR validation to more closely mimic docs.rs environment --- .github/workflows/ci.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 883dc4c..c1f7214 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,26 +125,30 @@ jobs: args: --all -- --check doc_format: - name: Doc format + name: Preflight docs.rs build runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Install Rust toolchain + - name: Install nightly Rust toolchain + # Nightly is used here because the docs.rs build + # uses nightly and we use doc_cfg features that are + # not in stable Rust as of this writing (Rust 1.62). uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly override: true - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v1 - - name: Run cargo docs - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps + # This is intended to mimic the docs.rs build + # environment. The goal is to fail PR validation + # if the subsequent release would result in a failed + # documentation build on docs.rs. + run: cargo +nightly doc --all-features + env: + RUSTDOCFLAGS: --cfg docsrs + DOCS_RS: 1 cargo-deny: name: License / vulnerability audit @@ -157,7 +161,7 @@ jobs: - advisories - bans licenses sources - # Prevent sudden announcement of a new advisory from failing ci: + # Prevent sudden announcement of a new advisory from failing CI: continue-on-error: ${{ matrix.checks == 'advisories' }} steps: From 189bb4de188b49f772e20ab76b17bfb973000cd8 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Thu, 14 Jul 2022 09:23:06 -0700 Subject: [PATCH 2/4] Debug log to verify that we've chosen the no-op FFI path when doing PR validation --- .github/workflows/ci.yml | 2 +- build.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1f7214..0766d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,7 +124,7 @@ jobs: command: fmt args: --all -- --check - doc_format: + docs_rs: name: Preflight docs.rs build runs-on: ubuntu-latest steps: diff --git a/build.rs b/build.rs index 75ca08e..ea5bc08 100644 --- a/build.rs +++ b/build.rs @@ -21,8 +21,11 @@ fn main() { // so we do a specialized build that makes all the FFIs into no-ops. let docs_rs = env::var("DOCS_RS"); if docs_rs == Ok("1".to_string()) { + eprintln!("INFO: building no-op FFI for docs.rs"); compile_for_docs(); return; + } else { + eprintln!("INFO: building standard FFI for crate"); } println!("> git submodule init\n"); From 9d803186fa9a8faae0dff493bbc0899a11d44a9e Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Thu, 14 Jul 2022 09:37:50 -0700 Subject: [PATCH 3/4] Try updating git submodules first --- build.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index ea5bc08..c7481ee 100644 --- a/build.rs +++ b/build.rs @@ -16,6 +16,12 @@ use std::{env, ffi::OsStr, path::PathBuf}; fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("> git submodule init\n"); + git_command(&["submodule", "init"]); + + println!("> git submodule update\n"); + git_command(&["submodule", "update"]); + // docs.rs builds in an environment that doesn't allow us to modify // the underlying source. We don't actually need to fully compile, // so we do a specialized build that makes all the FFIs into no-ops. @@ -28,12 +34,6 @@ fn main() { eprintln!("INFO: building standard FFI for crate"); } - println!("> git submodule init\n"); - git_command(&["submodule", "init"]); - - println!("> git submodule update\n"); - git_command(&["submodule", "update"]); - // Special note: Because of the post-processing we're doing here, // you must specify the `--no-verify` option when invoking `cargo publish`. // This is unfortunately necessary because the original XMP Toolkit requires From bfe86181843f9445d56d99e158ffe81491c455c6 Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Thu, 14 Jul 2022 09:42:36 -0700 Subject: [PATCH 4/4] Guard the reference to f.SetErrorCallback with #ifndef NOOP_FFI --- src/ffi.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ffi.cpp b/src/ffi.cpp index ddf6374..f6e65ef 100644 --- a/src/ffi.cpp +++ b/src/ffi.cpp @@ -120,7 +120,9 @@ extern "C" { #endif CXmpFile() { - f.SetErrorCallback(xmpFileErrorCallback, &err, 0xffffffff); + #ifndef NOOP_FFI + f.SetErrorCallback(xmpFileErrorCallback, &err, 0xffffffff); + #endif } } CXmpFile;