Skip to content

Resolve build file and main module based on uri - #3252

Open
sukus21 wants to merge 1 commit into
zigtools:0.16.xfrom
sukus21:resolve-module-from-path
Open

Resolve build file and main module based on uri#3252
sukus21 wants to merge 1 commit into
zigtools:0.16.xfrom
sukus21:resolve-module-from-path

Conversation

@sukus21

@sukus21 sukus21 commented Aug 25, 2026

Copy link
Copy Markdown

Attmepts to resolve #3194

If associated build file for a file cannot be calculated, loop over known build files, and pick the one with the URI that matches the best. This is intended as a fallback, if the regular reference-based method fails. I am not sure how well this actually works or performs, as it does multiple string compares. There might be a more elegant way of this this, but I haven't found it yet.

This covers the common project setup, where you have a build.zig file at the root of the project, and ensures that sub-directories with valid build files still refer to their own build.zig, which is "closer" in the source tree.

I'm unsure if the project at large wants this code. It's something I hacked together after poking around the ZLS code for a couple hours. If this is a solution the ZLS team wants to move on with, I'd be happy to make any adjustments or relocate this code somewhere else.

This is a fallback, if the regular method fails. I am not sure how well this method actually works, as it does multiple string compares. There should be a more elegant way of doing this.
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