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

Followup for Pass path associations as special compiler flags #6007

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

LeFrosch
Copy link
Collaborator

@LeFrosch LeFrosch commented Feb 1, 2024

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: #5300

Description of this change

Followup for #5301. Pass all headers in targets with include_prefix with special "-ibazel" flag like that they can be handled by CLion. Also I tried to address all open comments in the pull request.

@github-actions github-actions bot added product: CLion CLion plugin awaiting-review Awaiting review from Bazel team on PRs labels Feb 1, 2024
@ujohnny
Copy link
Collaborator

ujohnny commented Feb 12, 2024

I remember when I intentionally added a check in VirtualIncludesHandler.java to handle this. Something should be definitely done to it, either removed or message there should be updated.

}
}

private List<String> collectIncludes(Path root, TargetKey targetKey, BlazeProjectData blazeProjectData) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd pass indicator to this routine as well and performed a check indicator.checkCanceled() in both for loops.

try {
return Path.of(value);
} catch (InvalidPathException e) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be logged, but please warn.

Copy link
Collaborator

Choose a reason for hiding this comment

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

some indentations are wrong in this file in if blocks, please make sure you have style guide applied

@@ -257,6 +355,9 @@ private OCWorkspaceImpl.ModifiableModel calculateConfigurations(
.map(file -> "-I" + file.getAbsolutePath())
.collect(toImmutableList());

Path rootPath = workspaceRoot.directory().toPath();
List<String> includes = collectIncludesWithProgress(rootPath, targetKey, blazeProjectData, indicator);
Copy link
Collaborator

Choose a reason for hiding this comment

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

these includes are quite specific ones. should we say something like collectBazelStripIncludeHints?

continue;
}

// if absolut strip prefix is a repository-relative path
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo


CIdeInfo cIdeInfo = targetIdeInfo.getcIdeInfo();
Path includePrefix = pathOf(cIdeInfo.getIncludePrefix());
Path stripPrefix = pathOf(cIdeInfo.getStripIncludePrefix());
Copy link
Collaborator

Choose a reason for hiding this comment

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

related to #5969, strip prefix might be //foo/bar and this code will break on Windows (yes we do not support it, though it works and maybe we should not introduce new issues).

LeFrosch added a commit to LeFrosch/intellij-bazel that referenced this pull request Feb 15, 2024
Changes:
- formatting and names
- only collects hints for include_prefix, strip_include_prefix is handled by VirtualIncludesHandler
- no longer recursive and handles duplicated dependencies
yvvan and others added 5 commits February 15, 2024 16:29
 - take library path into account for path transformation
 - don't use imports with `*`
 - revert small refactoring
- added registry key
- added progress indicator
- using path instead of string transformations
This should be redundant because includes are mapped with the -ibazel flag
@@ -107,7 +107,7 @@ public String externalWorkspaceName() {
}
int slashesIndex = label.indexOf("//");
logger.assertTrue(slashesIndex >= 0);
return label.substring(1, slashesIndex);
return label.substring(0, slashesIndex).replaceFirst("^@+", "");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe there's something wrong here, this line probably should not be changed since in bazel external workspace name should has only one @ symbol

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that it's the way bazel 7 started to report external workspace targets. Investigating.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So my conclusion here is the following:

  1. Please drop this change from this patchset.
  2. Create new issue describing issue about bazel 7 -- this code works fine with bazel 6.
  3. Please check any other occurrences of @ strip and adjust them.
  4. Should we introduce some special function that expects exactly 1 or exactly 2 @ signs?

Copy link
Collaborator

@ujohnny ujohnny left a comment

Choose a reason for hiding this comment

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

Copy link
Collaborator

@ujohnny ujohnny left a comment

Choose a reason for hiding this comment

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

lgtm

@ujohnny ujohnny merged commit b59c61f into bazelbuild:master Mar 7, 2024
6 checks passed
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Mar 7, 2024
@LeFrosch LeFrosch deleted the Daniel.Brauner/5301 branch August 18, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: CLion CLion plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants