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

Feature Request - Customize addon naming scheme #699

Open
DartRuffian opened this issue Jun 1, 2024 · 7 comments
Open

Feature Request - Customize addon naming scheme #699

DartRuffian opened this issue Jun 1, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@DartRuffian
Copy link
Contributor

DartRuffian commented Jun 1, 2024

Currently, HEMTT will always use a project's prefix for pbo names, and will result in prefix_addon.pbo. I have a different usecase where we want our main prefix to be used for pbo names instead, or to just add a new property for the pbo prefix specifically.

Our main prefix is an acronym for the group, and then each mod's prefix is the name of the mod. I.e. \ls\core\... is the file path for the core mod, \ls\battlefields\ for another mod, etc.

However, this would result in our pbo names being core_addon.pbo or battlefields_addon.pbo, which isn't ideal. Having someway to control the naming schemes for pbos would be great, that way we could format them to be ls_core_addon.pbo/ls_battlefields_addon.pbo or just ls_addon.pbo.

Some ideas:

  • usemainprefix = true: would use mainprefix instead of prefix
  • pboprefix = "prefix": would be used for pbo names, or prefix if not defined
@jonpas
Copy link
Collaborator

jonpas commented Jun 1, 2024

You can rename addons in a post-build hook. I can paste an example used in CUP later today.

@DartRuffian
Copy link
Contributor Author

You can rename addons in a post-build hook. I can paste an example used in CUP later today.

Could do that yeah, just thought a built in solution would be nice as well.

@BrettMayson BrettMayson added the enhancement New feature or request label Jun 1, 2024
@jonpas
Copy link
Collaborator

jonpas commented Jun 1, 2024

let addons = HEMTT_OUT.join("addons");
let prefix_len = HEMTT.project().prefix().len();

for pbo_path in addons.list() {
    let rpbo = pbo_path.file_name();

    // Weapons_CUP_Weapons_ACR.pbo => cup_weapons_acr.pbo
    if rpbo.starts_with("Weapons_CUP_") {
        rpbo.crop(prefix_len + 1);
        rpbo.make_lower();
        let rpbo_path = addons.join(rpbo);
        if !pbo_path.move(rpbo_path) {
            fatal("Failed to rename " + pbo_path + " to " + rpbo_path);
        }
    }
}

@DartRuffian
Copy link
Contributor Author

let addons = HEMTT_OUT.join("addons");
let prefix_len = HEMTT.project().prefix().len();

for pbo_path in addons.list() {
    let rpbo = pbo_path.file_name();

    // Weapons_CUP_Weapons_ACR.pbo => cup_weapons_acr.pbo
    if rpbo.starts_with("Weapons_CUP_") {
        rpbo.crop(prefix_len + 1);
        rpbo.make_lower();
        let rpbo_path = addons.join(rpbo);
        if !pbo_path.move(rpbo_path) {
            fatal("Failed to rename " + pbo_path + " to " + rpbo_path);
        }
    }
}

Looks simple enough, thanks!

@DartRuffian
Copy link
Contributor Author

I tried it out on my project but it seems running the hook in post_build causes release to fail to find a file:

 INFO Binarized 29 files
 INFO Built 39 PBOs
 INFO Running hook: post_build/01_rename_pbos.rhai
 INFO Copied 5 files
ERROR IO Error: The system cannot find the file specified. (os error 2)

hemtt build works as expected. Running the script in post_release lets hemtt release work, but then pbos aren't renamed in build versions.

@BrettMayson
Copy link
Owner

Can you include the project and the branch you are trying this on with the failing script? I can take a look sometime

Repository owner deleted a comment Jun 7, 2024
@DartRuffian
Copy link
Contributor Author

DartRuffian commented Jun 8, 2024

Our project's repo is private because a lot of our models are community donated. You should have gotten an invitation to the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants