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

Change updateSnap to look for the file in src/ if it exists #3

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

jullanggit
Copy link

@jullanggit jullanggit commented Jan 5, 2025

Solves #2, by looking for files in src/ if it exists. If there is no src/ directory, it looks in the cwd like before.
I think this is an acceptable solution, as project files are to my knowledge basically always in src/ if it exists.
If this isn't the case or this solution is too hacky, I would be happy to improve it, although I would need a bit of guidance as I have no idea how to properly get the root module's directory

@mnemnion
Copy link
Owner

This is too hacky for me, but, you've given me an idea.

If, instead of just trying for the /src directory, we had a config in build.zig which defaults to the /src directory, but which can be configured for unusual cases by the user, that might be sufficient.

I still think it would be a pity if 0.14 shipped without any way to open a file given the result of calling @src(), but it's time to start planning for that possibility.

The solution might need to be slightly more involved than that, because since it's possible to have, for instance, ./src and ./test directories which both use ohsnap, I'd like the configuration to support that possibility. That's solvable with an a-list-like structure, something like [][2][]const u8, with [0] as the module name and [1] as the directory, defaulting to "root", "./src".

I'll need some time to take a look at the Zig issue board, maybe talk to some people, but this seems like a reasonable Plan B. It would live in the build file and otherwise be set-and-forget, which is acceptable.

@mnemnion mnemnion marked this pull request as draft January 27, 2025 19:41
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