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

router-bridge: Disable Deno snapshotting when docs.rs builds docs #185

Merged
merged 3 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions federation-2/router-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ tracing-test = "0.2.1"
[build-dependencies]
deno_core = "0.142.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should deno_core be marked as optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because cargo doc runs the equivalent of cargo check. It’s only the C++ bits of V8 that are disabled apparently, all the Rust bits of Deno and rusty_v8 and still there.

which = "4.2.2"

[features]
# "fake" feature to disable V8 usage when building on docs.rs
# See ./build.rs
docsrs = []
SimonSapin marked this conversation as resolved.
Show resolved Hide resolved

[package.metadata.docs.rs]
features = ["docsrs"]
16 changes: 13 additions & 3 deletions federation-2/router-bridge/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use deno_core::{JsRuntime, RuntimeOptions};
use std::fs::{read_to_string, File};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -69,7 +66,20 @@ fn update_bridge(current_dir: &Path) {
.success());
}

#[cfg(feature = "docsrs")]
fn create_snapshot(out_dir: &Path) {
// If we're building on docs.rs we just create
// and empty snapshot file and return, because `rusty_v8`
SimonSapin marked this conversation as resolved.
Show resolved Hide resolved
// doesn't actually compile on docs.rs
std::fs::write(out_dir.join("query_runtime.snap"), &[]).unwrap();
}

#[cfg(not(feature = "docsrs"))]
fn create_snapshot(out_dir: &Path) {
use deno_core::{JsRuntime, RuntimeOptions};
use std::fs::{read_to_string, File};
use std::io::Write;

let options = RuntimeOptions {
will_snapshot: true,
..Default::default()
Expand Down