How do you set up your IDE to work well with the Xmos ecosystem?

Technical questions regarding the XTC tools and programming with XMOS.
michaelf
Member++
Posts: 19
Joined: Thu Mar 14, 2024 7:44 pm

How do you set up your IDE to work well with the Xmos ecosystem?

Post by michaelf »

I use VSCode and I'm using only very minimal additional tools/extensions because I find they clash or don't quite integrate well with the Xmos ecosystem. I'm thinking about things like syntax highlighting, code completion, code formatting and so on, rather than managing the build system. The latter has good docs for getting started in the XTC tools guide.

For syntax highlighting, I have found a very niche (~300 total downloads) extension, which is pretty good - certainly better than nothing.

For code formatting, I use clang-format, but end up having to exclude large sections of XC code because it can't handle the syntax. In some cases it fails completely, for example, it formats "=>" operators in case guards to "= >" which causes a syntax error.

I briefly tried configuring the C/C++ extension for intellisense, code navigation, and so on, but by the time I'd configured it to not think everything is an error and put squiggles over half the code base, it no longer really served any useful functionality. I expect this is a lot to do with user error on my part.

So, how are people setting up their code environment nicely?
User avatar
xhuw
Verified
Member++
Posts: 24
Joined: Wed May 22, 2024 2:36 pm

Post by xhuw »

For XC, I haven't come across anything that helps. Its a custom language with a custom syntax that standard tools don't support. For C, I use neovim with the clangd language server with the following in the $HOME/.config/clangd/config.yaml

(of course fix the hardcoded paths to your XTC install)

Code: Select all


CompileFlags:
  Add:
    - -I/home/huw/XMOS/XTC/15.1.4/target/include
    - -I/home/huw/XMOS/XTC/15.1.4/target/include/clang
    - -D__XS3A__
  Remove: 
    - -march=xs3a
    - -report
    - -fxscope
    - -mno-dual-issue

If you also generate a compile_commands.json and copy it to the root directory of your project then clangd will give you pretty much normal autocomplete etc. for your C code.

I expect some googling about setting up clangd in vscode will get you to a similar experience as I have

https://cmake.org/cmake/help/latest/var ... MANDS.html
XMOS Software Engineer

Image
RitchRock
XCore Addict
Posts: 202
Joined: Tue Jan 17, 2017 9:25 pm

Post by RitchRock »

Thanks for asking this question. Development on XMOS with the xC language in VS Code is slow without xTimeComposer. I also have the extension you mention, which is better than nothing and I've added some keywords for xC files, but nothing like we had in xTimeComposer. What I do like about the extension is the ability to right click, make an .xe file active and then have a button in VSCode to run firmware. I don't setup my project like they want so I can't burn, but at least I have quick flash functionality.

Now that I'm on v15 tools, I wish/hope that XMOS would create a VS Code extension that would help here to get us back to how "plug and play" xTimeComposer was. How does XMOS internally develop with xC code now? TBH I don't understand how the last post by @xhuw will help us.