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

fix build paths #3835

Merged
merged 1 commit into from
Feb 26, 2024
Merged

fix build paths #3835

merged 1 commit into from
Feb 26, 2024

Conversation

hardliner66
Copy link
Contributor

@hardliner66 hardliner66 commented Feb 26, 2024

I figured out what the problem for #3834 was and found a solution to fix it as well.

The first problem was, that srcdir is an absolut path, but using .{.path = ...} is supposed to be relative only. So I instead changed it to use .cwd_relative which is badly named, but the appropriate field to use for absolute paths.

The next problem was, that the files added via addCSourceFilesVersioned needed to be relativ to the module (raylib itself) so I figured out a way to get the relative path and added that too.

Theres still a minor problem with getting the relative path, but that shouldn't take that long to fix.

@hardliner66
Copy link
Contributor Author

Fixed the final problem as well. Raylib now compiles on it's own and inside my project without problesm.

@hardliner66 hardliner66 marked this pull request as ready for review February 26, 2024 01:30
@raysan5
Copy link
Owner

raysan5 commented Feb 26, 2024

@hardliner66 Some experienced zig developer should review this change. I feel it adds an extra level of complexity, not sure if really required.

@hardliner66
Copy link
Contributor Author

I mean, it really doesn't add that much complexity. Also, the build is broken without it, because Zig sometimes uses the absolute path as relative path and it can't find files anywhere.

The proper solution when 0.12 is stable would be to switch to use a build.zig.zon and make raylib a proper package, but right now I don't think that's a good move yet.

So the only way to do this is to fix the problem at hand. Only thing I might would want to change is to use join everywhere instead of string concatenation, but I wanted to introduce as little change as possible while still fixing the issue.

Alternatively we could require the user to pass the relative location to the addRaylib function, instead of figuring out ourselves, but that would break every user who currently uses this. So I maded it figure out the path properly in a way that wont break user code.

IIRC there are other projects having the same problem as I had when importing raylib and this should fix it for them as well. I will try to find them and paste them here as well.

@raysan5 raysan5 merged commit 1fc4f4a into raysan5:master Feb 26, 2024
@raysan5
Copy link
Owner

raysan5 commented Feb 26, 2024

@hardliner66 Thanks for the detailed explanation. I'm merging it.

@hardliner66
Copy link
Contributor Author

No problem. I analyzed the bug and fixed it, so I should also explain it. But yesterday it was already 2:30am when I created the MR, so my explanation skills weren't the best probably 😅

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.

2 participants