Last active
May 14, 2024 18:14
-
-
Save bd2357/b2d69ab18849c1e2f70959eef426ff09 to your computer and use it in GitHub Desktop.
Ceedling on Windows notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using Ceedling on Windows is a bit more involved than using it in a Linux | |
environment. It requires Ruby which is not often installed on windows machines, | |
and while Ceedling can be configures to run with most C compilers, out of the | |
box it tries to use GCC which is also not generally available on windows. | |
Now if you are running Windows 10 professional, you can install the bash shell | |
and things get easier but lets say you are stuck with Windows Home or Windows 7 | |
and you want to do some quick and dirty test driven C coding with simple Mocks, | |
what is the best way to proceed? | |
Well it turns out that installing Ruby via the RubyInstaller for Windows | |
(https://rubyinstaller.org/) solves most of the problems. | |
You want to install the recommended version with the DevKit which gives you | |
MSYS2 tool chain including a GCC compiler and the bash shell. The MSYS2 | |
(MSYS64 Mingw64) includes the pacman program which allows you to add other | |
packages to your MSYS64 environment and we will use it to install the GDB | |
debugger. | |
The Ruby installer will want to install itself on the root of your C: drive. | |
This a good thing and is highly recommended. All subsequent instructions | |
assume this. | |
After installing Ruby, use Windows Explorer to go to C:\Ruby25-x64\msys64 and | |
click on the mingw64.exe file to run your shell. | |
I usually pin this to my Task Bar so I can always get back to it. | |
Install the debugger | |
> pacman -S mingw64/mingw-w64-x86_64-gdb | |
You may need to add /c/Ruby25-x64/bin to your path | |
(probable add the line in your .bashrc file) | |
> PATH=${PATH}:/c/Ruby25-x64/bin | |
Get the Ceedling Gem | |
> gem install ceedling | |
You also need to add the GCC compiler and the Ruby/bin folder to your windows | |
enviornement paths if you want to use ceedling and gdb from cmd or powershell. | |
Paths to add: | |
C:\Ruby25-x64\bin | |
C:\Ruby25-x64\msys64\mingw64\bin | |
____________________________________ | |
So for VS code I stopped trying to get the extension (below) to work. It is just as easy to open a terminal inside vscode cd to the ceedling folder and type ceedling. All just works. | |
VS Code Setup | |
See. Ceedling TestExplorer Extension for vscode (Visual Studio Code) (numaru.vscode-ceedling-test-adapter) | |
The instruction seem simple but you need to understand VSCode and its JSON files so assuming you have your | |
gcc and gdb setup as described above and ceedling configured to run in the cmd window. | |
You need a launch.json file in the .vscode folder that includes this information: | |
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "ceedling_gdb", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}/build/test/out/${command:ceedlingExplorer.debugTestExecutable}", | |
"args": [], | |
"stopAtEntry": false, | |
"cwd": "${workspaceFolder}", | |
"environment": [], | |
"externalConsole": false, | |
"MIMode": "gdb", | |
"miDebuggerPath": "C:/Ruby25-x64/msys64/mingw64/bin/gdb.exe", | |
"setupCommands": [ | |
{ | |
"description": "Enable pretty-printing for gdb", | |
"text": "-enable-pretty-printing", | |
"ignoreFailures": true | |
} | |
] | |
} | |
] | |
} | |
And the extension settings (By clicking the manage gear on the extension in EXTENSIONS view) | |
Ceedling Explorer: Debug Configuration | |
ceedling_gdb | |
Ceedling Explorer: Project Path | |
null | |
Ceedling Explorer: Shell Path | |
null | |
____________________________________ | |
I would also like to describe a workflow using the Notepad++ editor. | |
____________________________________ | |
Might also consider installing GNU Global for Tags | |
> pacman -S mingw64/mingw-w64-x86_64-global | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment