Skip to content

Commit

Permalink
hooks: archive phase (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson authored Feb 27, 2025
1 parent e569bde commit fbae240
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ impl Executor {
"post_build" => self.run_modules("post_build")?,
"pre_release" => self.run_modules("pre_release")?,
"archive" => {
trace!("phase: release (start)");
trace!("phase: archive (start)");
self.run_modules("archive")?;
let report = modules::archive::release(&self.ctx)?;
trace!("phase: release (done)");
trace!("phase: archive (done)");
report
}
"post_release" => self.run_modules("post_release")?,
Expand All @@ -124,6 +125,7 @@ impl Executor {
"pre_build" => module.pre_build(&self.ctx)?,
"post_build" => module.post_build(&self.ctx)?,
"pre_release" => module.pre_release(&self.ctx)?,
"archive" => module.archive(&self.ctx)?,
"post_release" => module.post_release(&self.ctx)?,
_ => unreachable!(),
});
Expand Down
4 changes: 4 additions & 0 deletions bin/src/modules/hook/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ impl Module for Hooks {
self.run_folder(ctx, "pre_release", true)
}

fn archive(&self, ctx: &Context) -> Result<Report, Error> {
self.run_folder(ctx, "archive", false)
}

fn post_release(&self, ctx: &Context) -> Result<Report, Error> {
self.run_folder(ctx, "post_release", false)
}
Expand Down
7 changes: 7 additions & 0 deletions bin/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ pub trait Module {
fn pre_release(&self, _ctx: &Context) -> Result<Report, Error> {
Ok(Report::new())
}
/// Executes the module's `archive` phase
///
/// # Errors
/// Any error that the module encounters
fn archive(&self, _ctx: &Context) -> Result<Report, Error> {
Ok(Report::new())
}
/// Executes the module's `post_release` phase
///
/// # Errors
Expand Down
5 changes: 5 additions & 0 deletions book/rhai/hooks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ There are 4 phases of the build process that can be hooked into:
| `pre_build` | [Virtual](library/filesystem.md#hemtt_vfs---virtual-file-system) |
| `post_build` | [Virtual](library/filesystem.md#hemtt_vfs---virtual-file-system) |
| `pre_release` | [Real](library/filesystem.md#hemtt_rfs---real-file-system) |
| `archive` | [Real](library/filesystem.md#hemtt_rfs---real-file-system) |
| `post_release` | [Real](library/filesystem.md#hemtt_rfs---real-file-system) |

### `pre_build`
Expand All @@ -42,6 +43,10 @@ The `post_build` hook is run after all preprocessing, binarization, and packing

The `pre_release` hook is run before any release tasks. It is only run during the [hemtt release](../../commands/release.md) command.

### `archive`

The `archive` hook is run after HEMTT is done modifying the PBOs or other files, but before they are archived. If you need to rename or move files, this is the place to do it.

### `post_release`

The `post_release` hook is run after all release tasks, and archives have been created. It is only run during the [hemtt release](../../commands/release.md) command.

0 comments on commit fbae240

Please sign in to comment.