From ae7e093c4d75b6aa133753cac3911eb74908e205 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 1 Dec 2025 18:45:14 -0500 Subject: rust doc generation script --- scripts/build-rust-docs.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 scripts/build-rust-docs.sh (limited to 'scripts') diff --git a/scripts/build-rust-docs.sh b/scripts/build-rust-docs.sh new file mode 100755 index 00000000..1c18071d --- /dev/null +++ b/scripts/build-rust-docs.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Build Rust documentation and create redirect index.html +# Note that you should make sure "import binaryninja" will return the +# correct version for the docs you want to upload. + +set -e + +CARGO_TOML="rust/Cargo.toml" +CARGO_LOCK="Cargo.lock" + +# Check for uncommitted changes to Cargo.toml or Cargo.lock +if ! git diff --quiet "$CARGO_TOML" "$CARGO_LOCK" 2>/dev/null; then + echo "Error: Uncommitted changes detected in $CARGO_TOML or $CARGO_LOCK" + echo "Please commit or stash your changes before running this script." + exit 1 +fi + +# Get Binary Ninja version from Python one-liner +echo "Getting Binary Ninja version..." +BN_VERSION=$(python3 -c "import binaryninja; v = binaryninja.core_version_info(); print(f'{v.major}.{v.minor}.{v.build}')") +echo "Binary Ninja version: $BN_VERSION" + +# Function to restore Cargo.toml and Cargo.lock on exit +cleanup() { + echo "Restoring $CARGO_TOML and $CARGO_LOCK..." + git checkout "$CARGO_TOML" "$CARGO_LOCK" 2>/dev/null || true +} +trap cleanup EXIT + +# Update version in Cargo.toml +echo "Updating version to $BN_VERSION in $CARGO_TOML..." +sed -i '' "s/^version = \".*\"/version = \"$BN_VERSION\"/" "$CARGO_TOML" + +# Clean out old docs +echo "Cleaning target/doc directory..." +rm -rf target/doc + +# Build the documentation (without dependencies by default) +echo "Building documentation..." +cargo doc --no-deps "$@" + +# Create redirect index.html +echo "Creating redirect index.html..." +cat > target/doc/index.html <<'EOF' + + + + + + Binary Ninja Rust Documentation + + + +

Redirecting to Binary Ninja Rust documentation...

+ + +EOF + +echo "Documentation built successfully with redirect at target/doc/index.html" -- cgit v1.3.1