From 42a04d57f71b40f6c8dfe63953802b01c73ea245 Mon Sep 17 00:00:00 2001 From: BrettMayson Date: Sun, 15 Oct 2023 15:17:46 -0600 Subject: [PATCH] make consistent preprocess in binary --- bin/src/modules/rapifier.rs | 10 +++--- book/commands/build.md | 6 ++-- book/configuration/addon.md | 12 ++++---- book/installation.md | 16 ++++++---- libs/common/src/project/addon/mod.rs | 46 +++++++++------------------- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/bin/src/modules/rapifier.rs b/bin/src/modules/rapifier.rs index 8c4a9760..40baba96 100644 --- a/bin/src/modules/rapifier.rs +++ b/bin/src/modules/rapifier.rs @@ -34,11 +34,11 @@ impl Module for Rapifier { .map(|addon| { let mut globs = Vec::new(); if let Some(config) = addon.config() { - if !config.preprocess().enabled() { - debug!("preprocessing disabled for {}", addon.name()); + if !config.rapify().enabled() { + debug!("rapify disabled for {}", addon.name()); return Ok((vec![], Ok(()))); } - for file in config.preprocess().exclude() { + for file in config.rapify().exclude() { globs.push(glob::Pattern::new(file)?); } } @@ -46,7 +46,7 @@ impl Module for Rapifier { let mut res = Ok(()); for entry in ctx.workspace().join(addon.folder())?.walk_dir()? { if entry.metadata()?.file_type == VfsFileType::File - && can_preprocess(entry.as_str()) + && can_rapify(entry.as_str()) { if globs .iter() @@ -159,7 +159,7 @@ pub fn rapify(path: WorkspacePath, ctx: &Context) -> (Vec, Result<(), Er (messages, Ok(())) } -pub fn can_preprocess(path: &str) -> bool { +pub fn can_rapify(path: &str) -> bool { let path = PathBuf::from(path); let name = path .extension() diff --git a/book/commands/build.md b/book/commands/build.md index 0b2ecb5a..7476b2a1 100644 --- a/book/commands/build.md +++ b/book/commands/build.md @@ -1,5 +1,3 @@ -# build - # hemtt build
Build your project
@@ -47,6 +45,10 @@ By default, `hemtt build` will create separate mods for each optional mod folder
 
 Do not binarize any files. They will be copied directly into the PBO. `config.cpp`, `*.rvmat`, `*.ext` will still be rapified.
 
+This can be configured per addon in [`addon.toml`](../configuration/addon.md#binarize).
+
 ### --no-rap
 
 Do not rapify any files. They will be copied directly into the PBO.
+
+This can be configured per addon in [`addon.toml`](../configuration/addon.md#rapify).
diff --git a/book/configuration/addon.md b/book/configuration/addon.md
index 37138c8c..683e5fd6 100644
--- a/book/configuration/addon.md
+++ b/book/configuration/addon.md
@@ -12,7 +12,7 @@ exclude = [
     "data/anim/chop.rtm",
 ]
 
-[preprocess]
+[rapify]
 enabled = false # Default: true
 exclude = [
     "missions/**/description.ext",
@@ -29,7 +29,7 @@ iso = "14001"
 
 ## binarize
 
-HEMTT's binarization of addons can be disabled entirely by setting `binarize.enabled` to `false`, or disabled for specific files by adding glob patterns to `binarize.exclude`.
+HEMTT's binarization of addons can be disabled for the addon by setting `binarize.enabled` to `false`, or disabled for specific files by adding glob patterns to `binarize.exclude`.
 
 **_/addons/banana/addon.toml_**
 
@@ -42,16 +42,16 @@ exclude = [
 ]
 ```
 
-## preprocess
+## rapify
 
-HEMTT's preprocessing of addons can be disabled entirely by setting `preprocess.enabled` to `false`, or disabled for specific files by adding glob patterns to `preprocess.exclude`.
+HEMTT's preprocessing & rapifying of addon configs can be disabled for the addon by setting `rapify.enabled` to `false`, or disabled for specific files by adding glob patterns to `rapify.exclude`.
 
-When it is required to disable preprocessing of `config.cpp`, it is recommended to create a separate addon to house any optional config, with the minimum amount of code required to make it work. Disabling preprocessing will allow you to ship invalid config, which could cause issues for your players. It will also cause slower load times when the config is valid.
+When it is required to disable preprocessing & rapifying of `config.cpp`, it is recommended to create a separate addon to house any optional config, with the minimum amount of code required to make it work. Disabling preprocessing & rapifying will allow you to ship invalid config, which could cause issues for your players. It will also cause slower load times when the config is valid.
 
 **_/addons/banana/addon.toml_**
 
 ```toml
-[preprocess]
+[rapify]
 enabled = false # Default: true
 exclude = [
     "missions/**/description.ext",
diff --git a/book/installation.md b/book/installation.md
index 5f1081a0..c39b6c9a 100644
--- a/book/installation.md
+++ b/book/installation.md
@@ -6,13 +6,15 @@ The latest HEMTT release can be downloaded from the [GitHub releases page](https
 
 Builds are available for Windows and Linux.
 
-## Installation (Project Local)
+## Installation (Winget)
 
-The HEMTT executable can be placed in the root of your project, and used from there. It is strongly recommended not to add it to your version control system.
+HEMTT can be installed using [Winget](https://github.com/microsoft/winget-cli).
 
-HEMTT can then be ran from a terminal in the root of your project with `.\hemtt.exe` on Windows, or `./hemtt` on Linux.
+```powershell
+winget install hemtt
+```
 
-## Installation (Global)
+## Manual Installation (Global)
 
 HEMTT can be installed globally on your system, and used from anywhere.
 
@@ -20,9 +22,11 @@ The HEMTT executable can be placed in any directory on your system, and added to
 
 HEMTT can then be ran from any terminal with `hemtt`.
 
-## Crates
+## Manual Installation (Project Local)
 
-If you have [Rust](https://www.rust-lang.org/) installed, you can install HEMTT from [crates.io](https://crates.io/crates/hemtt) with `cargo install hemtt`.
+The HEMTT executable can be placed in the root of your project, and used from there. It is strongly recommended not to add it to your version control system.
+
+HEMTT can then be ran from a terminal in the root of your project with `.\hemtt.exe` on Windows, or `./hemtt` on Linux.
 
 ## Compile from Source
 
diff --git a/libs/common/src/project/addon/mod.rs b/libs/common/src/project/addon/mod.rs
index b1bc3ca8..f9f579b3 100644
--- a/libs/common/src/project/addon/mod.rs
+++ b/libs/common/src/project/addon/mod.rs
@@ -10,12 +10,14 @@ use crate::error::Error;
 /// Configuration for an addon
 pub struct AddonConfig {
     #[serde(default)]
+    #[serde(alias = "preprocess")]
     /// Preprocess config
-    preprocess: Option,
+    rapify: RapifyConfig,
 
     #[serde(default)]
     /// A list of files to skip binarizing
     no_bin: Vec,
+
     #[serde(default)]
     /// Binarze config
     binarize: BinarizeConfig,
@@ -35,19 +37,9 @@ pub struct AddonConfig {
 
 impl AddonConfig {
     #[must_use]
-    /// Preprocess config
-    pub fn preprocess(&self) -> PreprocessConfig {
-        match &self.preprocess {
-            Some(PreprocessCompatibility::Deprecated(enabled)) => PreprocessConfig {
-                enabled: *enabled,
-                exclude: Vec::new(),
-            },
-            Some(PreprocessCompatibility::New(config)) => config.clone(),
-            None => PreprocessConfig {
-                enabled: false,
-                exclude: Vec::new(),
-            },
-        }
+    /// Rapify config
+    pub const fn rapify(&self) -> &RapifyConfig {
+        &self.rapify
     }
 
     #[must_use]
@@ -66,6 +58,9 @@ impl AddonConfig {
     /// file does not contain a valid configuration, an error is returned.
     pub fn from_file(path: &Path) -> Result {
         let file = std::fs::read_to_string(path)?;
+        if file.contains("[preprocess]") {
+            warn!("`[preprocess]` is deprecated, use `[rapify]` instead. See  for more information.");
+        }
         let config = Self::from_str(&file);
         if let Ok(inner) = config.as_ref() {
             if !inner.exclude.is_empty() {
@@ -74,9 +69,6 @@ impl AddonConfig {
             if !inner.no_bin.is_empty() {
                 warn!("`no_bin` is deprecated, use `binarize.exclude` instead. See  for more information.");
             }
-            if let Some(PreprocessCompatibility::Deprecated(_)) = inner.preprocess {
-                warn!("`preprocess` as a field is deprecated, use a `preprocess` object instead. See  for more information.");
-            }
         }
         config
     }
@@ -104,30 +96,20 @@ impl FromStr for AddonConfig {
     }
 }
 
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(untagged)]
-/// Preprocess compatibility config
-pub enum PreprocessCompatibility {
-    /// Deprecated bool
-    Deprecated(bool),
-    /// New config
-    New(PreprocessConfig),
-}
-
 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
 /// Preprocess config
-pub struct PreprocessConfig {
+pub struct RapifyConfig {
     #[serde(default)]
-    enabled: bool,
+    enabled: Option,
     #[serde(default)]
     exclude: Vec,
 }
 
-impl PreprocessConfig {
+impl RapifyConfig {
     #[must_use]
     /// Is preprocess enabled
-    pub const fn enabled(&self) -> bool {
-        self.enabled
+    pub fn enabled(&self) -> bool {
+        self.enabled.unwrap_or(true)
     }
 
     #[must_use]