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

Add trdata.naix as a dependency of compiler for scr_seq binaries #332

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

lhearachel
Copy link
Collaborator

This hardens the dependency between the compiling generator for binaries packed into scr_seq.narc and trdata.naix (which is generated during packing for trdata.narc).

The bug is apparent in the following snippet of build.ninja from a failure archive:

build res/field/scripts/scr_seq.narc.p/scripts_route_230: CUSTOM_COMMAND ../../../home/runner/work/pokeplatinum/pokeplatinum/res/field/scripts/scripts_route_230.s | /home/runner/work/pokeplatinum/pokeplatinum/tools/scripts/make_script_bin.sh consts/abilities.h consts/abilities.inc consts/badges.h consts/badges.inc consts/battle.h consts/battle.inc consts/battle_subscripts.h consts/battle_subscripts.inc consts/btlcmd.h consts/btlcmd.inc consts/catching_show.h consts/catching_show.inc consts/game_records.h consts/game_records.inc consts/gender.h consts/gender.inc consts/items.h consts/items.inc consts/journal.h consts/journal.inc consts/map.h consts/map.inc consts/movement.h consts/movement.inc consts/moves.h consts/moves.inc consts/pokemon.h consts/pokemon.inc consts/poketch.h consts/poketch.inc consts/scrcmd.h consts/scrcmd.inc consts/sdat.h consts/sdat.inc consts/shadows.h consts/shadows.inc consts/species.h consts/species.inc consts/tm_learnset.h consts/tm_learnset.inc consts/trainer.h consts/trainer.inc consts/trainer_ai.h consts/trainer_ai.inc res/text/pl_msg.narc

This can be read in human terms as scripts_route_230 being built by a custom command applied to scripts_route_230.s with header dependencies against the files thereafter (which means that any change to those files will flag scripts_route_230 as dirty and in-need of rebuild. Notably missing is trdata.naix, which is used by some script files, such as scripts_pastoria_gym.s.

Because ninja builds files as immediately as it deems that it is able to, this sometimes resulted in the compilation generator for these binaries being kickstarted before trdata.narc could be packed, which naturally results in a compilation error. The root of the bug is here:

scr_seq_narc = custom_target('scr_seq.narc',
    output: [
        'scr_seq.narc',
        'scr_seq.naix',
    ],
    input: field_script_gen.process(
        scr_seq_files,
        extra_args: ['--out-dir', scr_seq_private_dir]
    ),
    command: [
        narc_exe, 'create',
        '--naix',
        '--order', scr_seq_narc_order,
        '--output', '@OUTPUT0@',
        '@PRIVATE_DIR@',
    ],
    depends: [
        trdata_narc,
    ],
)

This declares a dependency against trdata.narc on the packing procedure for scr_seq.narc. Notably, this does not propagate the dependency into the generators, which are independent. Instead, that dependency must be declared on the generator itself.

@lhearachel lhearachel merged commit 7fc646f into pret:main Jan 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant