Refactor k_stdlib to separate hooks from 'sdk' headers #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been working on a project based on the headers from NSMBW's decomp. One of the most annoying issues I've run into is Kamek's own SDK headers conflicting with the ones from the decomp. I've had to modify the NSMBW headers to be compatible with Kamek. That's really annoying, especially when it comes to keeping them up to date etc.
It would be better if those Kamek SDK headers were optional, rather than forced. It's nice to have them for smaller self-contained projects, but when you're reusing headers from other projects (which is becoming more and more standard as the decomp scene progresses),
k_stdlibturns into an obstacle. After speaking with others, I've discovered they had their own workaround, which is arguably worse: they're modifyingk_stdlibitself to disable these headers. No matter how you deal with this issue, you're currently stuck having to pick your poison.This PR refactors k_stdlib to solve this problem like so:
kamek.honly includes the hooks, none of the extra SDK headers. The hooks now live directly withinkamek.h, as opposed to being brought in from a separate header, seeing as they're the only thing there. This also makes it match withkamek_asm.S.basedirectory has been renamed tok_sdkto avoid conflicts with other libraries. The name "base" is too generic, and it's also not very fitting anymore since the main Kamek header no longer includes anything from there. The namek_sdkspecifically was chosen to mirrork_stdlib.nw4r.handegg.hhave been moved intok_sdk.typedefs that were originally inkamek.hhave been moved to a newtypes.hinsidek_sdk. This lets them be included individually as desired.kamek_sdk.h, was added to automatically include the headers no longer included bykamek.h. This is mainly for backwards compatibility; it's easier to add a single#includedirective to old source files as opposed to trying to figure out which specific headers are needed where. This can also benefit tiny projects that rely onk_stdlibfor the SDK and don't want to add a bunch of#includes.Example patches, as well as the loader, now include
kamek_sdk.has needed.