diff --git a/Cargo.lock b/Cargo.lock index 37de1f750..93ee4c3b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,9 +460,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.50" +version = "1.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c" +checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203" dependencies = [ "find-msvc-tools", "jobserver", @@ -489,7 +489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cbf41c6ec3c4b9eaf7f8f5c11a72cd7d3aa0428125c20d5ef4d09907a0f019" dependencies = [ "cfg-if", - "cipher 0.5.0-rc.2", + "cipher 0.5.0-rc.3", "cpufeatures", "rand_core 0.10.0-rc-2", ] @@ -543,13 +543,13 @@ dependencies = [ [[package]] name = "cipher" -version = "0.5.0-rc.2" +version = "0.5.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "155e4a260750fa4f7754649f049748aacc31db238a358d85fd721002f230f92f" +checksum = "98d708bac5451350d56398433b19a7889022fa9187df1a769c0edbc3b2c03167" dependencies = [ "block-buffer 0.11.0", - "crypto-common 0.2.0-rc.5", - "inout 0.2.1", + "crypto-common 0.2.0-rc.8", + "inout 0.2.2", ] [[package]] @@ -576,9 +576,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.62" +version = "4.5.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004eef6b14ce34759aa7de4aea3217e368f463f46a3ed3764ca4b5a4404003b4" +checksum = "4c0da80818b2d95eca9aa614a30783e42f62bf5fdfee24e68cfb960b071ba8d1" dependencies = [ "clap", ] @@ -859,9 +859,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.2.0-rc.5" +version = "0.2.0-rc.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919bd05924682a5480aec713596b9e2aabed3a0a6022fab6847f85a99e5f190a" +checksum = "e6165b8029cdc3e765b74d3548f85999ee799d5124877ce45c2c85ca78e4d4aa" dependencies = [ "hybrid-array", ] @@ -966,12 +966,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.11.0-rc.4" +version = "0.11.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea390c940e465846d64775e55e3115d5dc934acb953de6f6e6360bc232fe2bf7" +checksum = "ebf9423bafb058e4142194330c52273c343f8a5beb7176d052f0e73b17dd35b9" dependencies = [ "const-oid", - "crypto-common 0.2.0-rc.5", + "crypto-common 0.2.0-rc.8", ] [[package]] @@ -1162,9 +1162,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" [[package]] name = "flate2" @@ -1455,7 +1455,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hemtt" -version = "1.18.1" +version = "1.19.0" dependencies = [ "arma3-wiki", "byteorder", @@ -1474,6 +1474,7 @@ dependencies = [ "hemtt-paa", "hemtt-pbo", "hemtt-preprocessor", + "hemtt-rhai", "hemtt-signing", "hemtt-sqf", "hemtt-stringtable", @@ -1580,7 +1581,7 @@ dependencies = [ [[package]] name = "hemtt-language-server" -version = "1.18.1" +version = "1.19.0" dependencies = [ "arma3-wiki", "clap", @@ -1668,6 +1669,7 @@ dependencies = [ "dashmap 6.1.0", "fs-err", "hemtt-common", + "hemtt-rhai", "hemtt-workspace", "lsp-types 0.97.0", "paste", @@ -1679,6 +1681,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "hemtt-rhai" +version = "1.0.0" +dependencies = [ + "fs-err", + "fs_extra", + "hemtt-common", + "hemtt-workspace", + "rhai", + "time", + "tracing", + "vfs", +] + [[package]] name = "hemtt-signing" version = "1.0.0" @@ -2060,7 +2076,7 @@ dependencies = [ "rgb", "tiff", "zune-core 0.5.0", - "zune-jpeg 0.5.7", + "zune-jpeg 0.5.8", ] [[package]] @@ -2113,18 +2129,18 @@ dependencies = [ [[package]] name = "inout" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7357b6e7aa75618c7864ebd0634b115a7218b0615f4cb1df33ac3eca23943d4" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" dependencies = [ "hybrid-array", ] [[package]] name = "insta" -version = "1.45.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b76866be74d68b1595eb8060cb9191dca9c021db2316558e52ddc5d55d41b66c" +checksum = "983e3b24350c84ab8a65151f537d67afbbf7153bb9f1110e03e9fa9b07f67a5c" dependencies = [ "console 0.15.11", "once_cell", @@ -2182,9 +2198,9 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iri-string" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" dependencies = [ "memchr", "serde", @@ -2216,9 +2232,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jni" @@ -2338,13 +2354,13 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df15f6eac291ed1cf25865b1ee60399f57e7c227e7f51bdbd4c5270396a9ed50" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ "bitflags 2.10.0", "libc", - "redox_syscall 0.6.0", + "redox_syscall 0.7.0", ] [[package]] @@ -3037,9 +3053,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd" +checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" [[package]] name = "potential_utf" @@ -3095,9 +3111,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" dependencies = [ "unicode-ident", ] @@ -3359,9 +3375,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96166dafa0886eb81fe1c0a388bece180fbef2135f97c1e2cf8302e74b43b5" +checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" dependencies = [ "bitflags 2.10.0", ] @@ -3515,7 +3531,7 @@ dependencies = [ "const-oid", "crypto-bigint", "crypto-primes", - "digest 0.11.0-rc.4", + "digest 0.11.0-rc.5", "pkcs1", "pkcs8", "rand_core 0.10.0-rc-2", @@ -3562,9 +3578,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" dependencies = [ "bitflags 2.10.0", "errno", @@ -3626,9 +3642,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62049b2877bf12821e8f9ad256ee38fdc31db7387ec2d3b3f403024de2034aea" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" [[package]] name = "same-file" @@ -3749,15 +3765,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.146" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "217ca874ae0207aac254aa02c957ded05585a90892cc8d87f9e5fa49669dadd8" +checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da" dependencies = [ "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] @@ -3880,10 +3896,11 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.7" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] @@ -3893,7 +3910,7 @@ version = "3.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0251c9d6468f4ba853b6352b190fb7c1e405087779917c238445eb03993826" dependencies = [ - "digest 0.11.0-rc.4", + "digest 0.11.0-rc.5", "rand_core 0.10.0-rc-2", ] @@ -4132,9 +4149,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.23.0" +version = "3.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" dependencies = [ "fastrand", "getrandom 0.3.4", @@ -5487,9 +5504,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" dependencies = [ "proc-macro2", "quote", @@ -5563,6 +5580,12 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40990edd51aae2c2b6907af74ffb635029d5788228222c4bb811e9351c0caad3" +[[package]] +name = "zmij" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9747e91771f56fd7893e1164abd78febd14a670ceec257caad15e051de35f06" + [[package]] name = "zopfli" version = "0.8.3" @@ -5635,9 +5658,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d915729b0e7d5fe35c2f294c5dc10b30207cc637920e5b59077bfa3da63f28" +checksum = "e35aee689668bf9bd6f6f3a6c60bb29ba1244b3b43adfd50edd554a371da37d5" dependencies = [ "zune-core 0.5.0", ] diff --git a/Cargo.toml b/Cargo.toml index 8ba9cc50c..07ad852ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "libs/paa", "libs/pbo", "libs/preprocessor", + "libs/rhai", "libs/signing", "libs/sqf", "libs/stringtable", @@ -53,7 +54,7 @@ fs_extra = "1.3.0" fs-err = "=3.1.3" git2 = "0.20.2" indexmap = "2.12.1" -insta = "1.43.2" +insta = "1.45.1" interprocess = "2.2.3" linkme = "0.3.35" lsp-types = "0.97.0" @@ -63,6 +64,7 @@ pest = "2.8.4" pest_derive = "2.8.4" rand = "0.9.2" regex = "1.12.2" +rhai = "1.23.6" rustc-hash = "2.1.1" rustversion = "1.0.22" serde = { version = "1.0.228", features = ["derive"] } @@ -73,6 +75,7 @@ supports-hyperlinks = "3.1.0" tabled = "0.20.0" terminal-link = "0.1.0" thiserror = "2.0.17" +time = { version = "0.3.44", features = ["formatting"] } toml = "0.9.8" tower-lsp = "0.20.0" tracing = { version = "0.1.43", features = ["attributes"] } diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 011301635..4dccaf637 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hemtt" description = "HEMTT - Arma 3 Build Tool" -version = "1.18.1" +version = "1.19.0" edition = "2024" license = "GPL-2.0" authors = ["Brett Mayson "] @@ -26,6 +26,7 @@ hemtt-p3d = { path = "../libs/p3d" } hemtt-paa = { path = "../libs/paa", features = ["generate"] } hemtt-pbo = { path = "../libs/pbo" } hemtt-preprocessor = { path = "../libs/preprocessor" } +hemtt-rhai = { path = "../libs/rhai" } hemtt-signing = { path = "../libs/signing" } hemtt-sqf = { path = "../libs/sqf" } hemtt-stringtable = { path = "../libs/stringtable" } @@ -49,7 +50,7 @@ paste = { workspace = true } rayon = "1.11.0" regex = { workspace = true } reqwest = { version = "0.12.24", features = ["blocking", "json"] } -rhai = "1.23.6" +rhai = { workspace = true } rust-embed = "8.9.0" semver = "1.0.27" serde = { workspace = true, features = ["derive"] } @@ -60,7 +61,7 @@ supports-hyperlinks = { workspace = true } tabled = { workspace = true } terminal-link = { workspace = true } thiserror = { workspace = true } -time = { version = "0.3.44", features = ["formatting"] } +time = { workspace = true } tracing = { workspace = true } tracing-subscriber = { version = "0.3.20", features = ["json"] } vfs = { workspace = true } diff --git a/bin/src/commands/mod.rs b/bin/src/commands/mod.rs index 6d00c099f..f4b469b3e 100644 --- a/bin/src/commands/mod.rs +++ b/bin/src/commands/mod.rs @@ -24,6 +24,7 @@ pub mod photoshoot; pub fn global_modules(executor: &mut crate::executor::Executor) { executor.add_module(Box::::default()); executor.add_module(Box::::default()); + executor.add_module(Box::::default()); executor.add_module(Box::::default()); executor.add_module(Box::::default()); executor.add_module(Box::::default()); diff --git a/bin/src/context.rs b/bin/src/context.rs index fb9757018..3c61bb477 100644 --- a/bin/src/context.rs +++ b/bin/src/context.rs @@ -1,6 +1,7 @@ use std::{env::temp_dir, path::PathBuf, sync::Arc}; use hemtt_common::config::{GlobalConfig, ProjectConfig}; +use hemtt_rhai::libraries::project::RhaiProject; use hemtt_workspace::{LayerType, Workspace, WorkspacePath, addons::Addon}; use crate::error::Error; @@ -258,10 +259,36 @@ impl Context { pub fn state(&self) -> Arc { self.state.clone() } + #[must_use] pub fn with_config(self, config: ProjectConfig) -> Self { Self { config, ..self } } + + /// Convert the context to a [`RhaiProject`] + /// + /// # Panics + /// If the version config is invalid + pub fn as_rhai_project(&self) -> RhaiProject { + RhaiProject { + name: self.config().name().to_string(), + author: self + .config() + .author() + .map_or_else(String::new, std::string::ToString::to_string), + prefix: self.config().prefix().to_string(), + mainprefix: self + .config() + .mainprefix() + .map_or_else(String::new, std::string::ToString::to_string), + version: self + .config() + .version() + .get(self.workspace_path().vfs()) + .expect("version config is valid to get to rhai module"), + addons: self.addons().to_vec(), + } + } } fn version_check( diff --git a/bin/src/error.rs b/bin/src/error.rs index 2eb0ca327..4c1c1fefa 100644 --- a/bin/src/error.rs +++ b/bin/src/error.rs @@ -37,6 +37,13 @@ pub enum Error { #[error("Invalid value: {0}")] InvalidValueName(String), + #[error("Preprocessor not found: {0}")] + PreprocessorNotFound(String), + #[error("Preprocessor did not return a string: {0}")] + PreprocessorDidNotReturnString(String), + #[error("Preprocessor error in '{0}': {1}")] + PreprocessorError(String, String), + #[error("Dialoguer Error: {0}")] Dialoguer(#[from] dialoguer::Error), #[error("Git Error: {0}")] diff --git a/bin/src/modules/hook/error/bhe4_runtime_error.rs b/bin/src/modules/hook/error/bhe4_runtime_error.rs index 73cd12c86..0cc735dc3 100644 --- a/bin/src/modules/hook/error/bhe4_runtime_error.rs +++ b/bin/src/modules/hook/error/bhe4_runtime_error.rs @@ -16,7 +16,7 @@ pub struct RuntimeError { impl Code for RuntimeError { fn ident(&self) -> &'static str { - "BHE3" + "BHE4" } fn message(&self) -> String { diff --git a/bin/src/modules/hook/error/bhe5_runtime_fatal.rs b/bin/src/modules/hook/error/bhe5_runtime_fatal.rs new file mode 100644 index 000000000..4a4d58d9b --- /dev/null +++ b/bin/src/modules/hook/error/bhe5_runtime_fatal.rs @@ -0,0 +1,54 @@ +use std::sync::Arc; + +use hemtt_workspace::{ + WorkspacePath, + reporting::{Code, Diagnostic, Label}, +}; +use rhai::Position; + +use super::get_offset; + +pub struct RuntimeFatal { + script: WorkspacePath, + error: String, + location: Position, +} + +impl Code for RuntimeFatal { + fn ident(&self) -> &'static str { + "BHE5" + } + + fn message(&self) -> String { + format!("Script {} intentionally failed at runtime", self.script) + } + + fn diagnostic(&self) -> Option { + let content = self.script.read_to_string().ok()?; + Some( + Diagnostic::from_code(self).with_label( + Label::primary( + self.script.clone(), + get_offset(&content, self.location)..get_offset(&content, self.location), + ) + .with_message({ + let mut chars = self.error.chars(); + chars.next().map_or_else( + || self.error.clone(), + |first| first.to_lowercase().collect::() + chars.as_str(), + ) + }), + ), + ) + } +} + +impl RuntimeFatal { + pub fn code(script: WorkspacePath, error: String, location: Position) -> Arc { + Arc::new(Self { + script, + error, + location, + }) + } +} diff --git a/bin/src/modules/hook/error/mod.rs b/bin/src/modules/hook/error/mod.rs index 550499824..79a661e59 100644 --- a/bin/src/modules/hook/error/mod.rs +++ b/bin/src/modules/hook/error/mod.rs @@ -5,6 +5,7 @@ use rhai::Position; pub mod bhe1_script_not_found; pub mod bhe3_parse_error; pub mod bhe4_runtime_error; +pub mod bhe5_runtime_fatal; fn get_offset(content: &str, location: Position) -> usize { let mut offset = 0; diff --git a/bin/src/modules/hook/libraries/hemtt.rs b/bin/src/modules/hook/libraries/hemtt.rs index c97e6c98b..4e8feb302 100644 --- a/bin/src/modules/hook/libraries/hemtt.rs +++ b/bin/src/modules/hook/libraries/hemtt.rs @@ -1,4 +1,5 @@ use hemtt_common::version::Version; +use hemtt_rhai::libraries::project::RhaiProject; use rhai::plugin::{ Dynamic, FnNamespace, FuncRegistration, ImmutableString, Module, NativeCallContext, PluginFunc, RhaiResult, TypeId, export_module, mem, @@ -6,8 +7,6 @@ use rhai::plugin::{ use crate::context::Context; -use super::project::RhaiProject; - #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct RhaiHemtt { @@ -23,7 +22,7 @@ impl RhaiHemtt { ctx: ctx.clone(), version: Version::try_from(env!("HEMTT_VERSION")) .expect("hemtt version should be valid"), - project: RhaiProject::new(ctx), + project: ctx.as_rhai_project(), folder: ctx.folder().expect("folder exists").to_string(), } } diff --git a/bin/src/modules/hook/libraries/mod.rs b/bin/src/modules/hook/libraries/mod.rs index 3e0da69f7..359809eff 100644 --- a/bin/src/modules/hook/libraries/mod.rs +++ b/bin/src/modules/hook/libraries/mod.rs @@ -1,29 +1,11 @@ use rhai::{combine_with_exported_module, def_package}; pub mod hemtt; -mod project; -mod rfs; -mod version; -mod vfs; def_package! { pub HEMTTPackage(lib) { combine_with_exported_module!(lib, "hemtt", hemtt::project_functions); - combine_with_exported_module!(lib, "hemtt_version", version::version_functions); - combine_with_exported_module!(lib, "hemtt_project", project::project_functions); - } -} - -def_package! { - pub RfsPackage(lib) { - combine_with_exported_module!(lib, "hemtt_rfs_path", rfs::path::path_functions); - combine_with_exported_module!(lib, "hemtt_rfs_file", rfs::file::file_functions); - } -} - -def_package! { - pub VfsPackage(lib) { - combine_with_exported_module!(lib, "hemtt_vfs_path", vfs::path::path_functions); - combine_with_exported_module!(lib, "hemtt_vfs_file", vfs::file::file_functions); + combine_with_exported_module!(lib, "hemtt_version", hemtt_rhai::libraries::version::version_functions); + combine_with_exported_module!(lib, "hemtt_project", hemtt_rhai::libraries::project::project_functions); } } diff --git a/bin/src/modules/hook/mod.rs b/bin/src/modules/hook/mod.rs index 37d58e7e4..9bbb977ef 100644 --- a/bin/src/modules/hook/mod.rs +++ b/bin/src/modules/hook/mod.rs @@ -1,23 +1,25 @@ use ::rhai::{Engine, Scope, packages::Package}; +use hemtt_rhai::libraries::VfsPackage; use hemtt_workspace::WorkspacePath; -use rhai::{Dynamic, EvalAltResult}; +use rhai::Dynamic; use whoami::Result; -use crate::{context::Context, error::Error, report::Report}; +use crate::{ + context::Context, + error::Error, + modules::hook::{error::bhe5_runtime_fatal::RuntimeFatal, libraries::hemtt::RhaiHemtt}, + report::Report, +}; -use self::{ - error::{ - bhe1_script_not_found::ScriptNotFound, bhe3_parse_error::RhaiParseError, - bhe4_runtime_error::RuntimeError, - }, - libraries::hemtt::RhaiHemtt, +use self::error::{ + bhe1_script_not_found::ScriptNotFound, bhe3_parse_error::RhaiParseError, + bhe4_runtime_error::RuntimeError, }; use super::Module; mod error; mod libraries; -mod time; /// Creates a sccope for a Rhai script /// @@ -26,36 +28,35 @@ mod time; /// /// # Panics /// If the build folder does not exist -pub fn scope(ctx: &'_ Context, vfs: bool) -> Result, Error> { +pub fn scope(ctx: &'_ Context, hemtt: bool, vfs: bool) -> Result, Error> { let mut scope = Scope::new(); if vfs { scope.push_constant("HEMTT_VFS", ctx.workspace_path().vfs().clone()); } - scope.push_constant("HEMTT_DIRECTORY", ctx.project_folder().clone()); - scope.push_constant( - "HEMTT_OUTPUT", - ctx.build_folder().expect("build folder exists").clone(), - ); scope.push_constant("HEMTT_RFS", ctx.project_folder().clone()); - scope.push_constant( - "HEMTT_OUT", - ctx.build_folder().expect("build folder exists").clone(), - ); - scope.push_constant("HEMTT", RhaiHemtt::new(ctx)); + if hemtt { + scope.push_constant( + "HEMTT_OUTPUT", + ctx.build_folder().expect("build folder exists").clone(), + ); + scope.push_constant( + "HEMTT_OUT", + ctx.build_folder().expect("build folder exists").clone(), + ); + scope.push_constant("HEMTT", RhaiHemtt::new(ctx)); + } Ok(scope) } -fn engine(vfs: bool) -> Engine { - let mut engine = Engine::new(); +fn engine(name: String, vfs: bool) -> Engine { + let mut engine = hemtt_rhai::engine(name); if vfs { - let virt = libraries::VfsPackage::new(); + let virt = VfsPackage::new(); engine.register_static_module("hemtt_vfs", virt.as_shared_module()); } - engine.register_static_module("hemtt_rfs", libraries::RfsPackage::new().as_shared_module()); engine.register_static_module("hemtt", libraries::HEMTTPackage::new().as_shared_module()); - engine.register_fn("date", time::date); engine } @@ -104,6 +105,9 @@ impl Hooks { ); report.merge(Self::run(ctx, file, vfs)?.0); ctx.config().version().invalidate(); + if report.failed() { + break; + } } Ok(report) } @@ -134,45 +138,24 @@ impl Hooks { #[allow(clippy::needless_pass_by_value)] // rhai things fn run(ctx: &Context, path: WorkspacePath, vfs: bool) -> Result<(Report, Dynamic), Error> { let mut report = Report::new(); - let mut engine = engine(vfs); - let mut scope = scope(ctx, vfs)?; let parts = path.as_str().split('/'); let name = parts .clone() .skip(parts.count().saturating_sub(2)) .collect::>() .join("/"); - let inner_name = name.clone(); - engine.on_debug(move |x, _src, _pos| { - debug!("[{inner_name}] {x}"); - }); - let inner_name = name.clone(); - engine.on_print(move |s| { - info!("[{inner_name}] {s}"); - }); - let inner_name = name.clone(); - engine.register_fn("info", move |s: &str| { - info!("[{inner_name}] {s}"); - }); - let inner_name = name.clone(); - engine.register_fn("warn", move |s: &str| { - warn!("[{inner_name}] {s}"); - }); - let inner_name = name.clone(); - engine.register_fn("error", move |s: &str| { - error!("[{inner_name}] {s}"); - }); - let inner_name = name; - engine.register_fn("fatal", move |s: &str| -> Result<(), Box> { - error!("[{inner_name}] {s}"); - Err(Box::new(EvalAltResult::ErrorRuntime( - "Script called fatal".into(), - rhai::Position::NONE, - ))) - }); + let engine = engine(name, vfs); + let mut scope = scope(ctx, true, vfs)?; match engine.eval_with_scope(&mut scope, &path.read_to_string()?) { Err(e) => { - report.push(RuntimeError::code(path, &e)); + match *e { + rhai::EvalAltResult::ErrorTerminated(message, pos) => { + report.push(RuntimeFatal::code(path, message.to_string(), pos)); + } + _ => { + report.push(RuntimeError::code(path, &e)); + } + } Ok((report, Dynamic::UNIT)) } Ok(ret) => Ok((report, ret)), @@ -190,7 +173,7 @@ impl Module for Hooks { self.0 = ctx.hemtt_folder().join("hooks").exists(); if self.0 { for phase in &["pre_build", "post_build", "pre_release", "post_release"] { - let engine = engine(phase != &"post_release"); + let engine = engine(String::from(*phase), phase != &"post_release"); let dir = ctx.hemtt_folder().join("hooks").join(phase); if !dir.exists() { continue; diff --git a/bin/src/modules/mod.rs b/bin/src/modules/mod.rs index 181f41d3c..a95818a47 100644 --- a/bin/src/modules/mod.rs +++ b/bin/src/modules/mod.rs @@ -14,6 +14,7 @@ pub mod fnl; pub mod hook; pub mod meta; pub mod pbo; +pub mod preprocess; pub(crate) mod sign; pub mod summary; pub mod tex_headers; @@ -32,7 +33,7 @@ pub trait Module { fn name(&self) -> &'static str; /// priority (lower goes first) fn priority(&self) -> i32 { - 0 + 100 } /// Executes the module's `init` phase /// diff --git a/bin/src/modules/preprocess.rs b/bin/src/modules/preprocess.rs new file mode 100644 index 000000000..1f848108a --- /dev/null +++ b/bin/src/modules/preprocess.rs @@ -0,0 +1,133 @@ +use std::{collections::HashMap, sync::RwLock}; + +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; + +use crate::{ + context::Context, + modules::{Module, hook::scope}, +}; + +#[derive(Debug, Default)] +pub struct PreProcess { + preprocessors: RwLock>, +} + +impl Module for PreProcess { + fn name(&self) -> &'static str { + "preprocess" + } + + fn priority(&self) -> i32 { + 0 + } + + fn check(&self, ctx: &Context) -> Result { + for patterns in ctx.config().preprocess().preprocessors().values() { + for pattern in patterns { + if let Err(e) = glob::Pattern::new(pattern) { + return Err(crate::Error::GlobPattern(e)); + } + } + } + let mut preprocessors = HashMap::new(); + for preprocessor in ctx.config().preprocess().preprocessors().keys() { + if preprocessors.contains_key(preprocessor) { + continue; + } + let preprocessor_path = ctx + .workspace_path() + .join(".hemtt/preprocessors")? + .join(preprocessor)? + .with_extension("rhai")?; + if !preprocessor_path.exists()? { + return Err(crate::Error::PreprocessorNotFound((*preprocessor).clone())); + } + preprocessors.insert(preprocessor.clone(), preprocessor_path.read_to_string()?); + } + *self + .preprocessors + .write() + .expect("Failed to acquire write lock on preprocessors") = preprocessors; + Ok(crate::report::Report::new()) + } + + fn pre_build(&self, ctx: &Context) -> Result { + let files = ctx + .workspace_path() + .walk_dir()? + .into_iter() + .filter(|e| e.is_file().unwrap_or(false)) + .filter(|e| !e.as_str().contains(".hemttout")) + .filter_map(|e| { + let preprocessors = ctx + .config() + .preprocess() + .preprocessors() + .iter() + .filter(|(_, ps)| { + ps.iter().any(|p| { + glob::Pattern::new(p) + .expect("pattern checked") + .matches(e.as_str()) + }) + }) + .collect::>(); + if preprocessors.is_empty() { + return None; + } + Some(( + e, + preprocessors + .iter() + .map(|(p, _)| p.to_owned()) + .collect::>(), + )) + }) + .collect::>(); + files + .par_iter() + .map(|(path, preprocessors)| { + let mut content = path.read_to_string()?; + for preprocessor in preprocessors { + let binding = self + .preprocessors + .read() + .expect("Failed to acquire read lock on preprocessors"); + let script = binding.get(*preprocessor).ok_or_else(|| { + crate::Error::PreprocessorNotFound((*preprocessor).to_owned()) + })?; + trace!( + "Preprocessing file: {} with {}", + path.as_str(), + preprocessor, + ); + content = hemtt_rhai::preprocess( + scope(ctx, false, false)?, + format!("{}:{}", preprocessor, path.as_str()), + script, + path.as_str().to_string(), + content, + ) + .map_err(|e| { + if e.ends_with("(expecting string)") { + crate::Error::PreprocessorDidNotReturnString(format!( + "{}:{}", + preprocessor, + path.as_str() + )) + } else { + crate::Error::PreprocessorError( + format!("{}:{}", preprocessor, path.as_str()), + e, + ) + } + })?; + drop(binding); + } + path.create_file()?.write_all(content.as_bytes())?; + Ok(()) + }) + .collect::, crate::Error>>()?; + Ok(crate::report::Report::new()) + } +} diff --git a/book/rhai/library/hemtt.md b/book/rhai/library/hemtt.md index 2e140c15d..cdc85bfbb 100644 --- a/book/rhai/library/hemtt.md +++ b/book/rhai/library/hemtt.md @@ -7,10 +7,10 @@ The `HEMTT` constant gives access to information and the ability to modify the b Returns the version of HEMTT. ```js -HEMTT.version().to_string(); // "1.18.1" +HEMTT.version().to_string(); // "1.19.0" HEMTT.version().major(); // 1 -HEMTT.version().minor(); // 18 -HEMTT.version().patch(); // 1 +HEMTT.version().minor(); // 19 +HEMTT.version().patch(); // 0 HEMTT.version().build(); // "" ``` diff --git a/book/rhai/library/logging.md b/book/rhai/library/logging.md index 204a2d254..d648ec26f 100644 --- a/book/rhai/library/logging.md +++ b/book/rhai/library/logging.md @@ -26,7 +26,7 @@ debug(HEMTT.project().version.major()); ``` ```sh -DEBUG [post_release/test.rhai] "1.18.1" +DEBUG [post_release/test.rhai] "1.19.0" DEBUG [post_release/test.rhai] 1 ``` diff --git a/hls/Cargo.toml b/hls/Cargo.toml index 93ac9d173..a8d25c140 100644 --- a/hls/Cargo.toml +++ b/hls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hemtt-language-server" -version = "1.18.1" +version = "1.19.0" edition = "2024" [lints] diff --git a/hls/package.json b/hls/package.json index b46390547..1afc15a77 100644 --- a/hls/package.json +++ b/hls/package.json @@ -2,7 +2,7 @@ "name": "hemtt", "description": "HEMTT Language Server & Utils", "license": "MIT", - "version": "1.18.1", + "version": "1.19.0", "publisher": "brettmayson", "icon": "icon.png", "categories": [], diff --git a/libs/common/src/config/project/mod.rs b/libs/common/src/config/project/mod.rs index aad4aaab1..bfab8e1ef 100644 --- a/libs/common/src/config/project/mod.rs +++ b/libs/common/src/config/project/mod.rs @@ -13,6 +13,7 @@ use super::deprecated; pub mod files; pub mod hemtt; pub mod lint; +pub mod preprocess; pub mod preprocessor; pub mod signing; pub mod version; @@ -48,6 +49,9 @@ pub struct ProjectConfig { // Preprocessor options preprocessor: preprocessor::PreprocessorOptions, + // Preprocess options + preprocess: preprocess::PreprocessOptions, + /// Signing specific configuration signing: signing::SigningConfig, @@ -119,6 +123,12 @@ impl ProjectConfig { &self.preprocessor } + #[must_use] + /// Preprocess specific configuration + pub const fn preprocess(&self) -> &preprocess::PreprocessOptions { + &self.preprocess + } + #[must_use] /// Signing specific configuration pub const fn signing(&self) -> &signing::SigningConfig { @@ -199,6 +209,9 @@ pub struct ProjectFile { #[serde(default)] preprocessor: preprocessor::PreprocessorOptionsFile, + #[serde(default)] + preprocess: preprocess::PreprocessOptionsFile, + #[serde(default)] signing: signing::SigningSectionFile, @@ -257,6 +270,7 @@ impl TryFrom for ProjectConfig { files: file.files.into(), lints: file.lints.into(), preprocessor: file.preprocessor.into(), + preprocess: file.preprocess.into(), signing: file.signing.into(), runtime: RuntimeArguments::default(), expected_path, @@ -290,7 +304,7 @@ impl TryFrom for ProjectConfig { mod test_helper { use std::collections::HashMap; - use super::{files, hemtt, lint, preprocessor, signing, version}; + use super::{files, hemtt, lint, preprocess, preprocessor, signing, version}; impl super::ProjectConfig { #[must_use] @@ -310,6 +324,7 @@ mod test_helper { lints: lint::LintSectionFile::default(), hemtt: hemtt::HemttSectionFile::default(), preprocessor: preprocessor::PreprocessorOptionsFile::default(), + preprocess: preprocess::PreprocessOptionsFile::default(), signing: signing::SigningSectionFile::default(), meta_path: std::path::PathBuf::default(), } diff --git a/libs/common/src/config/project/preprocess.rs b/libs/common/src/config/project/preprocess.rs new file mode 100644 index 000000000..5a6fd02dc --- /dev/null +++ b/libs/common/src/config/project/preprocess.rs @@ -0,0 +1,58 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +#[allow(clippy::module_name_repetitions)] +#[derive(PartialEq, Eq, Debug, Clone, Default)] +/// Configuration for the HEMTT preprocess Rhai module +pub struct PreprocessOptions { + preprocessors: HashMap>, +} + +impl PreprocessOptions { + #[must_use] + /// Get the list of preprocessors + pub const fn preprocessors(&self) -> &HashMap> { + &self.preprocessors + } +} + +#[allow(clippy::module_name_repetitions)] +#[derive(PartialEq, Eq, Debug, Default, Clone, Serialize, Deserialize)] +pub struct PreprocessOptionsFile { + #[serde(default)] + preprocessors: HashMap>, +} + +impl From for PreprocessOptions { + fn from(file: PreprocessOptionsFile) -> Self { + Self { + preprocessors: file.preprocessors, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_preprocessor_options_file() { + let toml: &'static str = r#" + [preprocessors] + processor1 = ["path1", "path2"] + processor2 = ["path3"] + "#; + let file: PreprocessOptionsFile = toml::from_str(toml).expect("Failed to parse TOML"); + let options: PreprocessOptions = file.into(); + assert_eq!(options.preprocessors(), &{ + let mut map = HashMap::new(); + map.insert( + "processor1".to_string(), + vec!["path1".to_string(), "path2".to_string()], + ); + map.insert("processor2".to_string(), vec!["path3".to_string()]); + map + }); + } +} diff --git a/libs/preprocessor/Cargo.toml b/libs/preprocessor/Cargo.toml index d4a31e29d..73c3c3a4e 100644 --- a/libs/preprocessor/Cargo.toml +++ b/libs/preprocessor/Cargo.toml @@ -14,6 +14,7 @@ bench = false [dependencies] hemtt-common = { path = "../common" } hemtt-workspace = { path = "../workspace" } +hemtt-rhai = { path = "../rhai", optional = true } automod = { workspace = true } dashmap = { workspace = true } @@ -31,7 +32,7 @@ fs-err = { workspace = true } paste = { workspace = true } [features] -lsp = ["hemtt-workspace/lsp", "lsp-types"] +lsp = ["hemtt-workspace/lsp", "lsp-types", "hemtt-rhai"] [[bench]] name = "ace_dogtags" diff --git a/libs/preprocessor/src/parse/mod.rs b/libs/preprocessor/src/parse/mod.rs index 17c915464..c5a765d6e 100644 --- a/libs/preprocessor/src/parse/mod.rs +++ b/libs/preprocessor/src/parse/mod.rs @@ -46,6 +46,9 @@ pub fn file(path: &WorkspacePath) -> Result>, Error> { dashmap::mapref::entry::Entry::Occupied(entry) => Ok(entry.get().clone()), dashmap::mapref::entry::Entry::Vacant(entry) => { let source = path.read_to_string()?; + + // TODO preprocess + let res = str(&source, path)?; // The LSP manages its own caches, having this enabled would cause the LSP to never see any changes diff --git a/libs/rhai/Cargo.toml b/libs/rhai/Cargo.toml new file mode 100644 index 000000000..b86155c03 --- /dev/null +++ b/libs/rhai/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "hemtt-rhai" +version = "1.0.0" +edition = "2024" +description = "Rhai scripting library for hemtt" +license = "GPL-2.0" + +[lints] +workspace = true + +[dependencies] +hemtt-common = { path = "../common" } +hemtt-workspace = { path = "../workspace" } + +fs_extra = { workspace = true } +fs-err = { workspace = true } +rhai = { workspace = true } +time = { workspace = true } +tracing = { workspace = true } +vfs = { workspace = true } diff --git a/libs/rhai/src/lib.rs b/libs/rhai/src/lib.rs new file mode 100644 index 000000000..c51c2a51c --- /dev/null +++ b/libs/rhai/src/lib.rs @@ -0,0 +1,60 @@ +pub use rhai::{EvalAltResult, Scope, packages::Package as _}; + +use crate::libraries::RfsPackage; + +pub mod libraries; + +pub fn engine(name: String) -> rhai::Engine { + let mut engine = rhai::Engine::new(); + engine.register_static_module("hemtt_rfs", RfsPackage::new().as_shared_module()); + engine.register_fn("date", libraries::time::date); + let inner_name = name.clone(); + engine.on_debug(move |x, _src, _pos| { + tracing::debug!("[{inner_name}] {x}"); + }); + let inner_name = name.clone(); + engine.on_print(move |s| { + tracing::info!("[{inner_name}] {s}"); + }); + let inner_name = name.clone(); + engine.register_fn("info", move |s: &str| { + tracing::info!("[{inner_name}] {s}"); + }); + let inner_name = name.clone(); + engine.register_fn("warn", move |s: &str| { + tracing::warn!("[{inner_name}] {s}"); + }); + let inner_name = name.clone(); + engine.register_fn("error", move |s: &str| { + tracing::error!("[{inner_name}] {s}"); + }); + let inner_name = name; + engine.register_fn("fatal", move |s: &str| -> Result<(), Box> { + tracing::error!("[{inner_name}] {s}"); + Err(Box::new(EvalAltResult::ErrorTerminated( + "Script called fatal".into(), + rhai::Position::NONE, + ))) + }); + engine +} + +/// Preprocess a Rhai script with SOURCE and PATH constants +/// +/// # Errors +/// If there is an error during preprocessing +pub fn preprocess( + mut scope: Scope, + script_name: String, + script_source: &str, + target_path: String, + target_source: String, +) -> Result { + scope.push_constant("SOURCE", target_source); + scope.push_constant("PATH", target_path); + + match engine(script_name).eval_with_scope::(&mut scope, script_source) { + Ok(result) => Ok(result), + Err(err) => Err(format!("Error during preprocessing: {err}")), + } +} diff --git a/libs/rhai/src/libraries/mod.rs b/libs/rhai/src/libraries/mod.rs new file mode 100644 index 000000000..b18bb26e0 --- /dev/null +++ b/libs/rhai/src/libraries/mod.rs @@ -0,0 +1,21 @@ +use rhai::{combine_with_exported_module, def_package}; + +pub mod project; +mod rfs; +pub mod time; +pub mod version; +mod vfs; + +def_package! { + pub RfsPackage(lib) { + combine_with_exported_module!(lib, "hemtt_rfs_path", rfs::path::path_functions); + combine_with_exported_module!(lib, "hemtt_rfs_file", rfs::file::file_functions); + } +} + +def_package! { + pub VfsPackage(lib) { + combine_with_exported_module!(lib, "hemtt_vfs_path", vfs::path::path_functions); + combine_with_exported_module!(lib, "hemtt_vfs_file", vfs::file::file_functions); + } +} diff --git a/bin/src/modules/hook/libraries/project.rs b/libs/rhai/src/libraries/project.rs similarity index 55% rename from bin/src/modules/hook/libraries/project.rs rename to libs/rhai/src/libraries/project.rs index f888c3851..84895b72a 100644 --- a/bin/src/modules/hook/libraries/project.rs +++ b/libs/rhai/src/libraries/project.rs @@ -5,47 +5,22 @@ use rhai::plugin::{ TypeId, export_module, }; -use crate::context::Context; - #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct RhaiProject { - name: String, - author: String, - prefix: String, - mainprefix: String, - version: Version, - addons: Vec, -} - -impl RhaiProject { - pub fn new(ctx: &Context) -> Self { - Self { - name: ctx.config().name().to_string(), - author: ctx - .config() - .author() - .map_or_else(String::new, std::string::ToString::to_string), - prefix: ctx.config().prefix().to_string(), - mainprefix: ctx - .config() - .mainprefix() - .map_or_else(String::new, std::string::ToString::to_string), - version: ctx - .config() - .version() - .get(ctx.workspace_path().vfs()) - .expect("version config is valid to get to rhai module"), - addons: ctx.addons().to_vec(), - } - } + pub name: String, + pub author: String, + pub prefix: String, + pub mainprefix: String, + pub version: Version, + pub addons: Vec, } #[allow(clippy::needless_pass_by_ref_mut)] #[allow(clippy::unwrap_used)] // coming from rhai codegen #[export_module] pub mod project_functions { - use crate::modules::hook::libraries::project::RhaiProject; + use super::RhaiProject; #[rhai_fn(global, pure)] pub fn name(project: &mut RhaiProject) -> String { diff --git a/bin/src/modules/hook/libraries/rfs/file.rs b/libs/rhai/src/libraries/rfs/file.rs similarity index 100% rename from bin/src/modules/hook/libraries/rfs/file.rs rename to libs/rhai/src/libraries/rfs/file.rs diff --git a/bin/src/modules/hook/libraries/rfs/mod.rs b/libs/rhai/src/libraries/rfs/mod.rs similarity index 100% rename from bin/src/modules/hook/libraries/rfs/mod.rs rename to libs/rhai/src/libraries/rfs/mod.rs diff --git a/bin/src/modules/hook/libraries/rfs/path.rs b/libs/rhai/src/libraries/rfs/path.rs similarity index 94% rename from bin/src/modules/hook/libraries/rfs/path.rs rename to libs/rhai/src/libraries/rfs/path.rs index c30287953..d3c18a6a1 100644 --- a/bin/src/modules/hook/libraries/rfs/path.rs +++ b/libs/rhai/src/libraries/rfs/path.rs @@ -12,11 +12,16 @@ pub mod path_functions { use rhai::EvalAltResult; - #[rhai_fn(global, pure)] + #[rhai_fn(global, pure, name = "join")] pub fn join(path: &mut PathBuf, other: &str) -> PathBuf { path.join(other) } + #[rhai_fn(global, pure, name = "join")] + pub fn join_immutable(path: &mut PathBuf, other: ImmutableString) -> PathBuf { + path.join(other.as_str()) + } + #[rhai_fn(global, pure)] pub fn exists(path: &mut PathBuf) -> bool { path.exists() diff --git a/bin/src/modules/hook/time.rs b/libs/rhai/src/libraries/time.rs similarity index 67% rename from bin/src/modules/hook/time.rs rename to libs/rhai/src/libraries/time.rs index b89027d69..c81b9ff14 100644 --- a/bin/src/modules/hook/time.rs +++ b/libs/rhai/src/libraries/time.rs @@ -3,6 +3,10 @@ use std::time::SystemTime; use rhai::EvalAltResult; use time::{OffsetDateTime, format_description}; +/// Rhai function to get the current date/time formatted according to the given format string. +/// +/// # Errors +/// If the format string is invalid or if formatting fails. pub fn date(format: &str) -> Result> { let now: OffsetDateTime = SystemTime::now().into(); let fmt = format_description::parse(format).map_err(|e| e.to_string())?; diff --git a/bin/src/modules/hook/libraries/version.rs b/libs/rhai/src/libraries/version.rs similarity index 100% rename from bin/src/modules/hook/libraries/version.rs rename to libs/rhai/src/libraries/version.rs diff --git a/bin/src/modules/hook/libraries/vfs/file.rs b/libs/rhai/src/libraries/vfs/file.rs similarity index 100% rename from bin/src/modules/hook/libraries/vfs/file.rs rename to libs/rhai/src/libraries/vfs/file.rs diff --git a/bin/src/modules/hook/libraries/vfs/mod.rs b/libs/rhai/src/libraries/vfs/mod.rs similarity index 100% rename from bin/src/modules/hook/libraries/vfs/mod.rs rename to libs/rhai/src/libraries/vfs/mod.rs diff --git a/bin/src/modules/hook/libraries/vfs/path.rs b/libs/rhai/src/libraries/vfs/path.rs similarity index 100% rename from bin/src/modules/hook/libraries/vfs/path.rs rename to libs/rhai/src/libraries/vfs/path.rs diff --git a/libs/signing/Cargo.toml b/libs/signing/Cargo.toml index faa7ddd7d..d8a39214c 100644 --- a/libs/signing/Cargo.toml +++ b/libs/signing/Cargo.toml @@ -13,7 +13,6 @@ bench = false [dependencies] hemtt-common = { path = "../common" } - hemtt-pbo = { path = "../pbo" } byteorder = { workspace = true }