Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks: archive phase #903

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading