pret / pokeplatinum

Decompilation of Pokémon Platinum
164 stars 56 forks source link

Generated NAIX headers trigger a full source rebuild #200

Open lhearachel opened 2 months ago

lhearachel commented 2 months ago

Introduced by #198

Steps to Reproduce

Assuming a freshly-cloned repository up-to-date with main:

  1. Run ./build.sh.
  2. Open res/battle/scripts/subscripts/subscript_mimic.s
  3. Make the following change:
    -    WaitButtonABTime 30
    +    WaitButtonABTime 15
  4. Run ./build.sh. Observe that the NARC only requests subscript_mimic to be rebuilt, but all source-code files are rebuilt afterwards due to the dependency on the generated NAIX.

Expected Behavior

Only the following source-code files which explicitly include battle/scripts/sub_seq.naix should be rebuilt:

include/data/move_side_effect_subscripts.h
src/battle/battle_controller.c
src/battle/battle_lib.c
src/battle/battle_script.c
mid-kid commented 2 months ago

I assume this happens due to the header being updated whenever a naix file changes? What about the header depends directly on the contents of naix files?

lhearachel commented 2 months ago

For clarity on terminology, a NAIX header is built by knarc during the process of packing a NARC. We use such headers in the source files to refer to files within a particular NARC. For an example, refer to src/battle/battle_controller.c and search for instances of subscript_.

From what I can tell, the core issue is that global.pch is being rebuilt, or detected as dependent on that NAIX header. I'm not sure why that is, but it is the clearest explanation that I can think of for why the full source tree is rebuilt.

mid-kid commented 2 months ago

In that case my question would be: When does the file layout of a NARC change? If it can only be changed by editing the build system, maybe it shouldn't be generated as a by-product of actually packing the files into a NARC. Instead it could be generated while setting up the build system (as a configure_file() with a command), or simply without depending on the files to be packed into the NARC.

I'm not sure how precompiled headers work, but even if it's excluded, I wonder how much of the codebase would be rebuilt after changing the contents of a NARC.

lhearachel commented 2 months ago

Unfortunately, moving the NARC file layout declaration to configuration time doesn't really solve the underlying issue. The full source tree would still be rebuilt if a user added a new file to that NARC.