Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken documentation build #67

Merged
merged 4 commits into from
Jul 14, 2022
Merged
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
28 changes: 16 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,31 @@ jobs:
command: fmt
args: --all -- --check

doc_format:
name: Doc format
docs_rs:
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
Expand All @@ -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:
Expand Down
15 changes: 9 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ 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.
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");
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
Expand Down
4 changes: 3 additions & 1 deletion src/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ extern "C" {
#endif

CXmpFile() {
f.SetErrorCallback(xmpFileErrorCallback, &err, 0xffffffff);
#ifndef NOOP_FFI
f.SetErrorCallback(xmpFileErrorCallback, &err, 0xffffffff);
#endif
}
} CXmpFile;

Expand Down