diff --git a/Cargo.lock b/Cargo.lock index 197e204..5ac3fdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,9 +38,6 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "dylo" version = "1.0.0" -dependencies = [ - "rubicon", -] [[package]] name = "dylo-cli" diff --git a/dylo-cli/src/main.rs b/dylo-cli/src/main.rs index 3482305..b0a4b4d 100644 --- a/dylo-cli/src/main.rs +++ b/dylo-cli/src/main.rs @@ -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::().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 diff --git a/dylo-runtime/Cargo.toml b/dylo-runtime/Cargo.toml index 856463b..f0cd074 100644 --- a/dylo-runtime/Cargo.toml +++ b/dylo-runtime/Cargo.toml @@ -13,3 +13,7 @@ rust-version = "1.83" [dependencies] rubicon = "3.4.9" + +[features] +import-globals = ["rubicon/import-globals"] +export-globals = ["rubicon/export-globals"] diff --git a/dylo-runtime/README.md b/dylo-runtime/README.md index 41c20e4..568933b 100644 --- a/dylo-runtime/README.md +++ b/dylo-runtime/README.md @@ -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 diff --git a/dylo-runtime/src/details.rs b/dylo-runtime/src/details.rs index 1b90a9c..1bea895 100644 --- a/dylo-runtime/src/details.rs +++ b/dylo-runtime/src/details.rs @@ -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"); } diff --git a/dylo/Cargo.toml b/dylo/Cargo.toml index 92c6806..a29d6c7 100644 --- a/dylo/Cargo.toml +++ b/dylo/Cargo.toml @@ -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"]