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

find associated build file in case of missing build config data #1738

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

Techatrix
Copy link
Member

@Techatrix Techatrix commented Jan 30, 2024

The associated build file resolution mechanism may fail to find the build file because the necessary build config from running the build.zig may not have finished yet.

These changes should ensure that the associated build file is kept unresolved until all necessary information is available.

fixes #1629

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 61 lines in your changes are missing coverage. Please review.

Comparison is base (47d0e7d) 75.87% compared to head (7376916) 75.70%.

Files Patch % Lines
src/DocumentStore.zig 50.92% 53 Missing ⚠️
src/analysis.zig 0.00% 3 Missing ⚠️
src/features/completions.zig 33.33% 2 Missing ⚠️
src/features/goto.zig 0.00% 2 Missing ⚠️
src/ComptimeInterpreter.zig 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1738      +/-   ##
==========================================
- Coverage   75.87%   75.70%   -0.17%     
==========================================
  Files          35       35              
  Lines       10141    10203      +62     
==========================================
+ Hits         7694     7724      +30     
- Misses       2447     2479      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@llogick llogick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason it doesn't resolve 1629 is because it stops iterating at the first is_associated.

@Techatrix Techatrix force-pushed the techatrix/build-file-resolution branch from 397a6e3 to 66d2fec Compare February 4, 2024 21:29
@Techatrix
Copy link
Member Author

The only reason it doesn't resolve 1629 is because it stops iterating at the first is_associated.

Resolving the build configs in reverse order appears to resolve it.

diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig
index 765c2de0..fbff1a33 100644
--- a/src/DocumentStore.zig
+++ b/src/DocumentStore.zig
@@ -304,7 +304,10 @@ pub const Handle = struct {
 
         var has_missing_build_config = false;
 
-        var it = unresolved.has_been_checked.iterator(.{ .kind = .unset });
+        var it = unresolved.has_been_checked.iterator(.{
+            .kind = .unset,
+            .direction = .reverse,
+        });
         while (it.next()) |i| {
             const build_file_uri = unresolved.potential_build_files[i];
             const build_file = document_store.getOrLoadBuildFile(build_file_uri) orelse continue;

The associated build file resolution mechanism may fail to find the
build file because the necessary build config from running
the build.zig may not have finished yet.

These changes should ensure that the associated build file is kept
unresolved until all necessary information is available.
@Techatrix Techatrix force-pushed the techatrix/build-file-resolution branch from 66d2fec to 7376916 Compare February 4, 2024 21:44
@llogick
Copy link
Contributor

llogick commented Feb 4, 2024

Resolving the build configs in reverse order appears to resolve it.

Naturally, but how would that affect the original use-case #688?

In testing this I simply iterated over all of the potential build files, storing the index of the last is_associated and assigning it afterwards.

@llogick llogick merged commit d04c1a1 into master Feb 4, 2024
10 checks passed
@llogick llogick deleted the techatrix/build-file-resolution branch February 4, 2024 22:45
Techatrix added a commit that referenced this pull request Feb 4, 2024
This also reverts the change to the iteration order of #1738
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.

module in build.zig is not considered as a BuildConfig packages
2 participants