In his streams Per updates the ion compiler while writing ion. To have a similar workflow in Clion:
Open the ion
directory as a project - this will create CMakeLists.txt.
Change CMakeLists.txt with the following content
cmake_minimum_required(VERSION 3.13)
project(ion C)
set(CMAKE_C_STANDARD 11)
include_directories(.)
add_executable(ion main.c)
This allows to build and run the ion compiler.
To enable breakpoints in the ion files, add the *.ion
pattern to C/C++ file types (Settings > Editor > File Types).
Let's say we want to debug the test1 package. Add the executable to CMakeLists.txt:
add_executable(test1 test1/out.c)
Create a new run configuration called 'test1' (Run > Edit configurations...> + > Application)
and select test1
in its Target and Executable fields.
Create a run configuration 'compile test1' with Target and Executable ion
, program arguments -o <path/to/test1/out.c> test1
and environment variables:
IONPATH=path/to/bitwise/ion
IONHOME=path/to/bitwise/ion
Add the 'compile test1' configuration to the 'Before launch' list of 'test1' after the 'Build'.
Now you can debug 'test1' configuration and it stops in ion breakpoints.
For some reason sometimes debugger doesn't show all local variables. You can evaluate them by name and add to watches.
Probably a better way without messing with run configuration dependencies is to write in CMakeLists.txt:
and create a single run configuration with Target and Executable 'test1'.