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

[SM64] Smarter and standardized includes #449

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

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
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
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