diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index e32ff71..8d148d8 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -7,6 +7,10 @@ - dtmt: split `build` into `build` and `package` - dtmt: implement deploying built bundles +=== Fixed + +- all: force unix path separators for engine values + == 2023-03-01 === Added diff --git a/Cargo.lock b/Cargo.lock index 6e8ff1d..af5a5f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -676,6 +676,7 @@ dependencies = [ "dtmt-shared", "futures", "oodle-sys", + "path-slash", "sdk", "serde", "serde_sjson", @@ -704,6 +705,7 @@ dependencies = [ "nanorand", "oodle-sys", "path-clean", + "path-slash", "pin-project-lite", "promptly", "sdk", @@ -1699,6 +1701,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -2045,6 +2053,7 @@ dependencies = [ "luajit2-sys", "nanorand", "oodle-sys", + "path-slash", "pin-project-lite", "serde", "serde_sjson", diff --git a/crates/dtmm/Cargo.toml b/crates/dtmm/Cargo.toml index 6516bcc..4719234 100644 --- a/crates/dtmm/Cargo.toml +++ b/crates/dtmm/Cargo.toml @@ -23,3 +23,4 @@ tracing-error = "0.2.0" tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } zip = "0.6.4" tokio-stream = { version = "0.1.12", features = ["fs"] } +path-slash = "0.2.1" diff --git a/crates/dtmm/src/controller/game.rs b/crates/dtmm/src/controller/game.rs index 508e84a..a9db26b 100644 --- a/crates/dtmm/src/controller/game.rs +++ b/crates/dtmm/src/controller/game.rs @@ -8,6 +8,7 @@ use color_eyre::eyre::Context; use color_eyre::{eyre, Help, Result}; use futures::stream; use futures::StreamExt; +use path_slash::PathBufExt; use sdk::filetype::lua; use sdk::filetype::package::Package; use sdk::murmur::Murmur64; @@ -153,22 +154,22 @@ fn build_mod_data_lua(state: Arc) -> String { lua.push_str(" new_mod(\""); lua.push_str(&mod_info.id); lua.push_str("\", {\n mod_script = \""); - lua.push_str(&resources.init.to_string_lossy()); + lua.push_str(&resources.init.to_slash_lossy()); if let Some(data) = resources.data.as_ref() { lua.push_str("\",\n mod_data = \""); - lua.push_str(&data.to_string_lossy()); + lua.push_str(&data.to_slash_lossy()); } if let Some(localization) = &resources.localization { lua.push_str("\",\n mod_localization = \""); - lua.push_str(&localization.to_string_lossy()); + lua.push_str(&localization.to_slash_lossy()); } lua.push_str("\",\n })\n"); } else { lua.push_str(" return dofile(\""); - lua.push_str(&resources.init.to_string_lossy()); + lua.push_str(&resources.init.to_slash_lossy()); lua.push_str("\")\n"); } diff --git a/crates/dtmt/Cargo.toml b/crates/dtmt/Cargo.toml index 9067ae8..8b210e5 100644 --- a/crates/dtmt/Cargo.toml +++ b/crates/dtmt/Cargo.toml @@ -29,6 +29,7 @@ tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } tracing = { version = "0.1.37", features = ["async-await"] } zip = "0.6.3" path-clean = "1.0.1" +path-slash = "0.2.1" [dev-dependencies] tempfile = "3.3.0" diff --git a/crates/dtmt/src/cmd/build.rs b/crates/dtmt/src/cmd/build.rs index f0f6b41..a49c9a1 100644 --- a/crates/dtmt/src/cmd/build.rs +++ b/crates/dtmt/src/cmd/build.rs @@ -9,6 +9,7 @@ use color_eyre::{Help, Report}; use dtmt_shared::ModConfig; use futures::future::try_join_all; use futures::StreamExt; +use path_slash::PathExt; use sdk::filetype::package::Package; use sdk::murmur::IdString64; use sdk::{Bundle, BundleFile}; @@ -134,7 +135,7 @@ where path.set_extension(""); BundleFile::from_sjson( - path.to_string_lossy().to_string(), + path.to_slash_lossy().to_string(), file_type, sjson, root.as_ref(), @@ -176,7 +177,7 @@ where .await .wrap_err_with(|| format!("failed to read file {}", path.display()))?; - let pkg_name = package.to_string_lossy().to_string(); + let pkg_name = package.to_slash_lossy().to_string(); let pkg = Package::from_sjson(sjson, pkg_name.clone(), root) .await .wrap_err_with(|| format!("invalid package file {}", &pkg_name))?; diff --git a/crates/dtmt/src/cmd/package.rs b/crates/dtmt/src/cmd/package.rs index 44184f6..2a64a9f 100644 --- a/crates/dtmt/src/cmd/package.rs +++ b/crates/dtmt/src/cmd/package.rs @@ -5,6 +5,7 @@ use std::path::PathBuf; use clap::{value_parser, Arg, ArgMatches, Command}; use color_eyre::eyre::{Context, Result}; use color_eyre::Help; +use path_slash::PathBufExt; use tokio::fs::{self, DirEntry}; use tokio_stream::wrappers::ReadDirStream; use tokio_stream::StreamExt; @@ -88,7 +89,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()> .await .wrap_err_with(|| format!("failed to read mod config at {}", path.display()))?; - zip.start_file(name.to_string_lossy(), Default::default())?; + zip.start_file(name.to_slash_lossy(), Default::default())?; zip.write_all(&data)?; } @@ -111,7 +112,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()> let (name, data) = res?; let name = base_path.join(name); - zip.start_file(name.to_string_lossy(), Default::default())?; + zip.start_file(name.to_slash_lossy(), Default::default())?; zip.write_all(&data)?; } }; diff --git a/lib/sdk/Cargo.toml b/lib/sdk/Cargo.toml index d85b26f..8df7524 100644 --- a/lib/sdk/Cargo.toml +++ b/lib/sdk/Cargo.toml @@ -24,3 +24,4 @@ tracing = { version = "0.1.37", features = ["async-await"] } tracing-error = "0.2.0" luajit2-sys = "0.0.2" async-recursion = "1.0.2" +path-slash = "0.2.1" diff --git a/lib/sdk/src/filetype/package.rs b/lib/sdk/src/filetype/package.rs index 338cc8e..9545677 100644 --- a/lib/sdk/src/filetype/package.rs +++ b/lib/sdk/src/filetype/package.rs @@ -7,6 +7,7 @@ use std::str::FromStr; use async_recursion::async_recursion; use color_eyre::eyre::{self, Context}; use color_eyre::Result; +use path_slash::PathBufExt; use tokio::fs; use crate::binary::sync::{ReadExt, WriteExt}; @@ -258,7 +259,7 @@ impl Package { for path in paths.iter() { w.write_u64(t.hash().into())?; - let hash = Murmur64::hash(path.to_string_lossy().as_bytes()); + let hash = Murmur64::hash(path.to_slash_lossy().as_bytes()); w.write_u64(hash.into())?; } }