-
Notifications
You must be signed in to change notification settings - Fork 314
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(clion): Add Xcode information to Cpp compiler wrapper #4651
Conversation
ECD 27 April 2023 to be merged as per @tpasternak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, good job!
The only major issue I see here is that we ignore stderr output in both query calls, which can lead to some hard-to-spot silent crashes, so personally I'd prefer to pipe stderr to the Bazel
tool window
cpp/src/com/google/idea/blaze/cpp/XcodeCompilerSettingsProviderImpl.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
ByteArrayOutputStream errStream = new ByteArrayOutputStream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We lose error stream here if the query result is 0. I think this is the reason for which it was possible to skip != None
check in QUERY_XCODE_VERSION_STARLARK_EXPR - the error message was silenced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! Piped it through the context.
ff24a60
to
e0a0807
Compare
@tpasternak If CI passes, I think this is ready for another review. |
TargetMapBuilder.builder() | ||
.addTarget(createCcToolchain()) | ||
.build(); | ||
XcodeCompilerSettings expected = new XcodeCompilerSettings(Path.of("/tmp/dev_dir"), Path.of("/tmp/dev_dir/sdk")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XcodeCompilerSettings expected = new XcodeCompilerSettings(Path.of("/tmp/dev_dir"), Path.of("/tmp/dev_dir/sdk")); | |
XcodeCompilerSettings expected = XcodeCompilerSettings.create(Path.of("/tmp/dev_dir"), Path.of("/tmp/dev_dir/sdk")); |
Otherwise, it won't compile as XcodeCompilerSettings is now abstract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! After a small fire at work I finally got time to make the tests pass.
There was this thing and another small thing related to turning it into a project service, then it's all done :D
Checklist
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: N/A (sorry, I didn't open one).
Description of this change
In CLion, the Bazel plugin has to pass a C compiler to the rest of the CLion machinery.
Currently, on macOS, if using the standard
cc
toolchains, it does so by wrapping theclang_wrapper.sh
we get from each toolchain implementation. On macOS, that wrapper expects the environment variablesDEVELOPER_DIR
andSDKROOT
to be set. In Bazel, they are set on every action. Currently, in CLion, they are not, which makes a lot of the smarts of CLion inaccessible to macOS users.This PR sets those variables by mirroring Bazel's logic:
cquery
for the xcode version in@bazel_tools//tools/osx:current_xcode_config
.DEVELOPER_DIR
that corresponds with that version. (This is where Bazel does it).Note that we could have gotten the xcode version from the aspect, and saved ourselves a potentially expensive cquery. But, due to this issue, we cannot forward those values to the rest of the build.