Skip to content

Commit

Permalink
Yeah ok we need to expose rubicon features through dylo-runtime, a no…
Browse files Browse the repository at this point in the history
…n-proc-macro crate
  • Loading branch information
fasterthanlime committed Dec 5, 2024
1 parent 21c905e commit c57a501
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions dylo-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ fn process_mod(mod_info: ModInfo, force: bool) -> std::io::Result<()> {

// Generate files for mod version
let mut mod_files = FileSet::new();

// Check and add "dylo-runtime" dependency to Cargo.toml if needed
let cargo_toml = fs_err::read_to_string(mod_info.mod_path.join("Cargo.toml"))?;
let mut doc = cargo_toml.parse::<toml_edit::DocumentMut>().unwrap();

let mut need_dylo_runtime = true;
if let Some(deps) = doc.get("dependencies") {
if deps.is_table() {
let deps_table = deps.as_table().unwrap();
if deps_table.contains_key("dylo-runtime") {
need_dylo_runtime = false;
}
}
}

if need_dylo_runtime {
tracing::info!("Adding dylo-runtime dependency to {}", mod_info.name);
if let Some(deps) = doc.get_mut("dependencies") {
if deps.is_table() {
let deps_table = deps.as_table_mut().unwrap();
deps_table.insert("dylo-runtime", toml_edit::value(DYLO_RUNTIME_VERSION));
mod_files.files.insert("Cargo.toml".into(), doc.to_string());
}
}
}

// Add spec.rs to mod version
mod_files
.files
Expand Down
4 changes: 4 additions & 0 deletions dylo-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ rust-version = "1.83"

[dependencies]
rubicon = "3.4.9"

[features]
import-globals = ["rubicon/import-globals"]
export-globals = ["rubicon/export-globals"]
2 changes: 1 addition & 1 deletion dylo-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In production, you probably want `DYLO_BUILD` to be set to 0, as your mods
should be pre-built, and put in the right place, next to the executable.

> **Warning**
> Make sure to build your mods with the `dylo/import-globals` and `impl`
> Make sure to build your mods with the `dylo-runtime/import-globals` and `impl`
> features enabled, just like `dylo-runtime` would do.
>
> See the [rubicon docs](https://crates.io/crates/rubicon) for more details: essentially, your
Expand Down
2 changes: 1 addition & 1 deletion dylo-runtime/src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn build_mod(mod_name: &'static str) {
cmd.env("CARGO_TARGET_DIR", &paths.cargo_target_dir);
cmd.arg("build");
cmd.arg("--verbose");
cmd.arg("--features=impl,dylo/import-globals");
cmd.arg("--features=impl,dylo-runtime/import-globals");
if build_profile == "release" {
cmd.arg("--release");
}
Expand Down
7 changes: 0 additions & 7 deletions dylo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ rust-version = "1.83"

[lib]
proc-macro = true

[dependencies]
rubicon = { version = "3.4.9" }

[features]
import-globals = ["rubicon/import-globals"]
export-globals = ["rubicon/export-globals"]

0 comments on commit c57a501

Please sign in to comment.