CLion IDE - how to configure?

How do you configure CLion IDE so that “Go to Definition” and similar actions work?

It can’t detect the location of included header symbols (which I can’t figure out myself either).

For example applications/subghz/subghz_setting.c contains:

#include "furi_hal_subghz_configs.h"

But that file lives in firmware/targets/f7/furi_hal/furi_hal_subghz_configs.h. How come these header files are found by the Scons build tool? IDE & I myself can’t make the connection.

It seemed a lot easier to manage in CLion with the Makefile. I’ve been trying to implement some suggestions I read in CPP-1102, the CLion ticket about scons support. Namely, adding scons-compiledb support… and the steps needed to get there were a bit funky:

  1. First, run ./fbt once to download/unpack the tool chain
  2. Run . ./scripts/toolchain/fbtenv.sh to set all env vars needed to address the toolchain’s python binary
  3. Install scons-compiledb with python3 -m pip install scons-compiledb (I had trouble using the pip binary, but better luck invoking it by module. NOTE: if you get a warning about it installing to user directory, something’s gone wrong — it should install to the toolchain’s site-packages)
  4. Modify the root SConstruct, adding an import scons_compiledb to the top, and altering the DefaultEnvironment(tools=[]) call to:
    env = DefaultEnvironment(tools=[])
    scons_compiledb.enable(env)
    
  5. Now, when you run ./fbt, it should generate a build/latest/compile_commands.json file
  6. Copy or symlink this file to the root flipperzero-firmware directory, or CLion may have some issues with the paths.
  7. Finally, hit File > Open, navigate to the compile_commands.json file, hit Open, and when the dialog appears, click “Open as Project”

Buuuuut even with all that, I still found it unable to resolve furi.h =/
image

3 Likes

That’s very intresting because I made configuration in CLion 2022.2 on Win10.
I Made it!!!

  1. Install Chocolatey. It’s like brew on Windows
  2. Install python, mingw, make, pandoc, gcc-arm-embedded, cmake, cmake.install
  3. Clone M*LIB
  4. On step make doc I got no markdown error. So I change markdown to pandoc in Makefile
  5. make install PREFIX=<mingw location>
  6. In firmware source dir run: python pip install -r scripts/requirements.txt
  7. Run: ./fbt.cmd
  8. Open CLion and setup “File | Settings | Build, Execution, Deployment | Toolchains” to MinGW directory
  9. Open directory of project
  10. Setup Run/Debug config to fbt.cmd like custom build configuration

Sorry if I made something wrong. I didn’t open C/C++ for about 20 years and never worked with embedded devices.