Skip to content

[SM64] Smarter and standardized includes#449

Merged
jesusyoshi54 merged 19 commits intoFast-64:mainfrom
Lilaa3:smart-include-function
Aug 15, 2025
Merged

[SM64] Smarter and standardized includes#449
jesusyoshi54 merged 19 commits intoFast-64:mainfrom
Lilaa3:smart-include-function

Conversation

@Lilaa3
Copy link
Collaborator

@Lilaa3 Lilaa3 commented Sep 8, 2024

I'd really like some opinions on write_or_delete_if_found's complexity.

Added new functions, write_or_delete_if_found, write_includes and update_actor_includes. Remove writeIfNotFound and deleteIfFound

write_or_delete_if_found is a smarter version of writeIfNotFound and deleteIfFound, it optionally removes comments prior to searching (but doesn't remove comments from the actual file of course) and lets you pass in regex patterns (without worrying about comments!) which allows much smarter searchs that can tolerate whitespace, it adds a trailing newline to the file instead of each include having to include a newline (broke stuff before), the footer can now be optional (allows no endif which is great for files that use the GCC #pragma once macro)

update_actor_includes standardizes group and level includes into one place for ease of editing, one of the major differences is that level exports no longer use the full path (levels/actor/my_file.c would instead be /actor/my_file.c) this should allow level header type actors to actually update headers on custom non decomp levels but that is not done in this PR (existing includes are unaffected!).

Benifts from this pr:

  1. New line issues are fixed
  2. Code quality (hopefully, maybe it could be better still?)
  3. Smarter searchs
  4. Less file writes (probably not significant to anyone's ssd lifespan but who knows!)
  5. More verbose
  6. Cleaner level actor includes

Added new functions, write_includes and update_actor_includes.

write_includes is a smarter version of writeIfNotFound specifically for includes and externs, it removes comments prior to searching (but doesn't remove comments from the actual file of course) and allows whitespace (where possible, a path including whitespace won´t be found when searching for a file with no whitespace), futhermore it adds a trailing newline to the file instead of adding a leading newline for each include, the logic that finds the `#endif` of .h files is also improved like the logic to find includes and externs (whitespace is tolerated, comments are ignored) but it also allows no endif for files that use the GCC `#pragma once` macro

update_actor_includes standardizes group and level includes into one place for ease of editing, one of the major differences is that level exports no longer use the full path (levels/actor/my_file.c would instead be /actor/my_file.c) this should allow level header type actors to actually update headers on custom non decomp levels but that is not done here
@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Sep 25, 2024

While I like my current idea, I think I can iron out some stuff and actually update writeIfNotFound, looking into that right now

@Lilaa3 Lilaa3 changed the title [SM64] Smarter includes [SM64] Smarter and standardized includes Sep 27, 2024
@Lilaa3 Lilaa3 force-pushed the smart-include-function branch 2 times, most recently from bb78cad to 82f7e22 Compare September 27, 2024 19:05
@Lilaa3 Lilaa3 force-pushed the smart-include-function branch from df8b312 to 2d76dce Compare September 27, 2024 20:03
@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Sep 27, 2024

I'm actually done this time, just needed to change stuff for animations rework

@Lilaa3 Lilaa3 mentioned this pull request Sep 30, 2024
1 task
@jesusyoshi54
Copy link
Collaborator

can you add function descriptions to the more complex funcs, it is something we should probably do more often

@Lilaa3 Lilaa3 requested a review from jesusyoshi54 April 13, 2025 13:45
@Lilaa3 Lilaa3 added review code please Ask that some other Fast64 dev reviews the code sm64 Has to do with the Super Mario 64 side enhancement New feature or request labels Apr 17, 2025
Copy link
Collaborator

@jesusyoshi54 jesusyoshi54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a light code review of sm64_utility.py and the other files and some testing. I think overall it is good and it seems to work though I didn't test everything as this seems to sort of touch everything.
I think it would be good if this could get someone else to do some stress testing with their own levels and then I would be good with this :)

@jesusyoshi54 jesusyoshi54 added the merge soon Will be merged in a few days at most if nothing else comes up label Aug 15, 2025
@Anoliah
Copy link
Contributor

Anoliah commented Aug 15, 2025

Tested on a few levels. Does not seem to cause any issues.

@jesusyoshi54 jesusyoshi54 merged commit a53681e into Fast-64:main Aug 15, 2025
1 check passed
@Lilaa3 Lilaa3 deleted the smart-include-function branch August 22, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request merge soon Will be merged in a few days at most if nothing else comes up review code please Ask that some other Fast64 dev reviews the code sm64 Has to do with the Super Mario 64 side

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants