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

vscode: Add hard-coded path to compile_commands.json #20417

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Feb 22, 2024

Contribution description

When run from Windows via WSL, VS Code just won't find the compile_commands.json otherwise.

Testing procedure

  1. Install VS Code in Windows (not in WSL)
  2. Install WSL + Ubuntu
  3. Install clang, clang, gcc-multilib, python3-serial, etc. in Ubuntin in WSL on Windows
  4. Clone RIOT in Ubuntu in WSL on Windows, run make compile-commands in examples/hello-world
  5. Install the WSL extension in VS Code in Windows (not in WSL)
  6. Reboot WSL so that the WSL extensions gets automagically installed on the next run
  7. Within Ubuntu/WSL inside the RIOT Repo run code . to launch VS Code in Windows, connected to WSL
  8. Open examples/hello-world/main.c
  9. Check if the RIOT_BOARD and the RIOT_CPU macros are defined an the value is presented as "native" when hovering with the mouse

In master, this doesn't work. With this PR, it should work.

Issues/PRs references

None

When run from Windows via WSL, VS Code just won't find the
`compile_commands.json` otherwise.
Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

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

LGTM.
I have a similar configuration on my side.

@dylad dylad added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 22, 2024
@maribu
Copy link
Member Author

maribu commented Feb 22, 2024

Thx :-)

@mguetschow
Copy link
Contributor

mguetschow commented Feb 22, 2024

Tbh I'm not sure whether it is a good idea to include that file in the git tree. It might be automatically changed by VSCode according to the local setup and it will be necessary to double-check we don't overwrite the file by mistake :/

@maribu
Copy link
Member Author

maribu commented Feb 22, 2024

It is in .gitignore, so unless git add --force is used, changes be users can be freely made and won't be tracked.

There is btw. no GUI or configuration knob in VS Code to manually point it to the file. With this PR, it will just work out of the box.

@dylad
Copy link
Member

dylad commented Feb 22, 2024

Tbh I'm not sure whether it is a good idea to include that file in the git tree. It might be automatically changed by VSCode according to the local setup and it will be necessary to double-check we don't overwrite the file by mistake :/

The same could apply to the settings.json that we provide. Of course users can overwrite this file or use settings from their custom workspace, etc.
Nevertheless, I think it is a good idea to provide a default and working environment for vscode users that they can customize the way they want.

@riot-ci
Copy link

riot-ci commented Feb 22, 2024

Murdock results

✔️ PASSED

fb4c388 vscode: Add hard-coded path to compile_commands.json

Success Failures Total Runtime
9997 0 9997 09m:57s

Artifacts

@maribu maribu added this pull request to the merge queue Feb 22, 2024
Merged via the queue into RIOT-OS:master with commit f9de5fd Feb 23, 2024
27 checks passed
@maribu
Copy link
Member Author

maribu commented Feb 23, 2024

Thx :)

@maribu maribu deleted the vscode/hardcode_compile_commands branch February 23, 2024 06:09
@keestux
Copy link
Contributor

keestux commented Mar 28, 2024

It is in .gitignore, so unless git add --force is used, changes be users can be freely made and won't be tracked.

Sorry. This is not true. Once you add a file to the git tree it will be tracked. It does not matter if it in a gitignore (that also means .git/info/exclude).

@maribu
Copy link
Member Author

maribu commented Mar 29, 2024

I was sure that this did work for me at some point in time 😦

Looks like one has to run git update-index --skip-worktree <file path> these days to ignore changes.

@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants