Skip to content

Commit c57a501

Browse files
Yeah ok we need to expose rubicon features through dylo-runtime, a non-proc-macro crate
1 parent 21c905e commit c57a501

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dylo-cli/src/main.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,32 @@ fn process_mod(mod_info: ModInfo, force: bool) -> std::io::Result<()> {
363363

364364
// Generate files for mod version
365365
let mut mod_files = FileSet::new();
366+
367+
// Check and add "dylo-runtime" dependency to Cargo.toml if needed
368+
let cargo_toml = fs_err::read_to_string(mod_info.mod_path.join("Cargo.toml"))?;
369+
let mut doc = cargo_toml.parse::<toml_edit::DocumentMut>().unwrap();
370+
371+
let mut need_dylo_runtime = true;
372+
if let Some(deps) = doc.get("dependencies") {
373+
if deps.is_table() {
374+
let deps_table = deps.as_table().unwrap();
375+
if deps_table.contains_key("dylo-runtime") {
376+
need_dylo_runtime = false;
377+
}
378+
}
379+
}
380+
381+
if need_dylo_runtime {
382+
tracing::info!("Adding dylo-runtime dependency to {}", mod_info.name);
383+
if let Some(deps) = doc.get_mut("dependencies") {
384+
if deps.is_table() {
385+
let deps_table = deps.as_table_mut().unwrap();
386+
deps_table.insert("dylo-runtime", toml_edit::value(DYLO_RUNTIME_VERSION));
387+
mod_files.files.insert("Cargo.toml".into(), doc.to_string());
388+
}
389+
}
390+
}
391+
366392
// Add spec.rs to mod version
367393
mod_files
368394
.files

dylo-runtime/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ rust-version = "1.83"
1313

1414
[dependencies]
1515
rubicon = "3.4.9"
16+
17+
[features]
18+
import-globals = ["rubicon/import-globals"]
19+
export-globals = ["rubicon/export-globals"]

dylo-runtime/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In production, you probably want `DYLO_BUILD` to be set to 0, as your mods
1919
should be pre-built, and put in the right place, next to the executable.
2020

2121
> **Warning**
22-
> Make sure to build your mods with the `dylo/import-globals` and `impl`
22+
> Make sure to build your mods with the `dylo-runtime/import-globals` and `impl`
2323
> features enabled, just like `dylo-runtime` would do.
2424
>
2525
> See the [rubicon docs](https://crates.io/crates/rubicon) for more details: essentially, your

dylo-runtime/src/details.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn build_mod(mod_name: &'static str) {
184184
cmd.env("CARGO_TARGET_DIR", &paths.cargo_target_dir);
185185
cmd.arg("build");
186186
cmd.arg("--verbose");
187-
cmd.arg("--features=impl,dylo/import-globals");
187+
cmd.arg("--features=impl,dylo-runtime/import-globals");
188188
if build_profile == "release" {
189189
cmd.arg("--release");
190190
}

dylo/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,3 @@ rust-version = "1.83"
1313

1414
[lib]
1515
proc-macro = true
16-
17-
[dependencies]
18-
rubicon = { version = "3.4.9" }
19-
20-
[features]
21-
import-globals = ["rubicon/import-globals"]
22-
export-globals = ["rubicon/export-globals"]

0 commit comments

Comments
 (0)