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

Offline mode #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

lexi-the-cute
Copy link

This needs to be tested. I'm going to spend some time testing to see if it builds in offline mode under normal build circumstances. I still have to figure out how to test it against the script at #21 (comment) for simulating docs.rs

@lexi-the-cute
Copy link
Author

So, apparently I somehow managed to partially edit my cargo copy and partially edit my local fork 🤦‍♀️

@lexi-the-cute
Copy link
Author

lexi-the-cute commented Mar 14, 2024

this is the result of testing it locally. not the docs.rs true test cause i need to somehow get it uploaded to crates.io for the way the true test is currently setup

fake docs_rs

 alexis@framework  ~/Desktop/catgirl-engine  ↱ main  DOCS_RS=test cargo run -- --version
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `target/debug/catgirl-engine --version`
catgirl-engine v0.12.10 built with rustc 1.78.0-nightly (b6d2d841b 2024-03-05) at 2024-03-14 07:36:53.284957516 UTC
Copyright (C) 2024 Alexis <@alexis@foxgirl.land> - Zlib License

no docs_rs

 alexis@framework  ~/Desktop/catgirl-engine  ↱ main  cargo run -- --version                                 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/catgirl-engine --version`
catgirl-engine v0.12.10 built with rustc 1.78.0-nightly (b6d2d841b 2024-03-05) at 2024-03-14 07:49:40.104455176 UTC
Copyright (C) 2024 Alexis <@alexis@foxgirl.land> - Zlib License

build-info v0.0.37 - License MIT OR Apache-2.0
cfg-if v1.0.0 - License MIT/Apache-2.0
clap v4.5.2 - License MIT OR Apache-2.0
ctrlc v3.4.2 - License MIT/Apache-2.0
futures v0.3.30 - License MIT OR Apache-2.0
image v0.24.9 - License MIT OR Apache-2.0
pretty_env_logger v0.5.0 - License MIT/Apache-2.0
rhai v1.17.1 - License MIT OR Apache-2.0
tracing v0.1.40 - License MIT
wasm-bindgen v0.2.92 - License MIT OR Apache-2.0
wgpu v0.19.3 - License MIT OR Apache-2.0
winit v0.29.14 - License Apache-2.0

my build scripts calls the set_offline(true) function when the DOCS_RS environment variable is set

use build_info_build::DependencyDepth;
use std::env;

fn main() {
    // Generate build info
    generate_build_info();
}

fn matches_environment_var(key: &str, value: &str) -> bool {
    let environment_var: Result<String, env::VarError> = env::var(key);
    environment_var.is_ok() && environment_var.unwrap() == value
}

fn generate_build_info() {
    let mut depth: DependencyDepth = DependencyDepth::Depth(0);

    // Custom environment variable to speed up writing code
    let rust_analyzer: bool = matches_environment_var("RUST_ANALYZER", "true");
    let docs_rs: bool = env::var("DOCS_RS").is_ok();
    if rust_analyzer || docs_rs {
        depth = DependencyDepth::None;
    }

    let options: build_info_build::BuildScriptOptions =
        build_info_build::build_script().collect_runtime_dependencies(depth);
    if docs_rs {
        options.set_offline(true);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant