Skip to content

Commit b6d2ae1

Browse files
committed
vscode documentation inital draft
1 parent 20b8eac commit b6d2ae1

File tree

6 files changed

+110
-0
lines changed

6 files changed

+110
-0
lines changed

howtousevscode.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
2+
# Getting started with VSCode
3+
4+
A convenient way of working with the FreeCAD source code is to use an IDE or Integrated Development Environment. The FreeCAD repository contains a VSCode configuration which makes it particularly easy to get started with.
5+
6+
To get started from VSCode select `File > Open Folder`, then select the folder where you have cloned your fork of the repo.
7+
8+
VSCode will probably ask to install the recommended extensions: say `yes`. If it doesn't you'll need to manually install these extensions
9+
```
10+
ms-vscode.cpptools-extension-pack
11+
ms-python.python
12+
```
13+
14+
## Select build configuration
15+
16+
<video autoplay muted playsinline loop src="images/configure.mp4" type="video/mp4"></video>
17+
18+
First on the bottom left corner, in the status bar, select the build type. Options are:
19+
- debug
20+
- release
21+
- conda debug
22+
- conda release
23+
24+
If you are using conda please select one of the respective ones.
25+
26+
Cmake should automatically configure the project with the selected configuration.
27+
28+
## First build
29+
30+
<video autoplay muted playsinline loop src="images/build.mp4" type="video/mp4"></video>
31+
32+
Press `Ctrl + Shift + B`, or click the build button with the cog icon in the status bar, or run the `CMake: build` task.
33+
34+
**NOTE:** The first build takes a while.
35+
36+
**NOTE:** If you change configuration (see step above) you will have to build again.
37+
38+
## Launching the built executable and debugging
39+
40+
<video autoplay muted playsinline loop src="images/debug.mp4" type="video/mp4"></video>
41+
42+
On the left panel go to the debug section and click the little green play button. Alternatively press `F5`. Every time you launch the debugger a build is triggered, to ensure all the latest changes you made to the code are compiled in.
43+
44+
You should see freecad launching and the debugger attaching to the process. If an error pops up the python debugger failed to attach (there's 30 second timeout).
45+
Close FreeCAD and try launching it again. If it still fails try increasing the timeout located in the file `.vscode/scripts/WaitForDebugpy.py`
46+
47+
To debug please refer to the [documentation](https://code.visualstudio.com/docs/editor/debugging#_debug-actions) or search for a tutorial online.
48+
49+
**NOTE:** VSCode has an option called 'run without debugging'. This doesn't work, don't use it. If you just want to run the application launch with `F5` and ignore the debugger.
50+
51+
**NOTE:** There's actually two debuggers: on the top panel you can see a dropdown to select either the c++ debugger or the python one.
52+
53+
**NOTE:** Don't use the restart button. It only restarts the selected debugger, which definitely is not what you want. Instead press the stop button (which stops both debuggers) and launch again.
54+
55+
## Running tests
56+
57+
<video autoplay muted playsinline loop src="images/testing.mp4" type="video/mp4"></video>
58+
59+
The IDE supports running FreeCAD tests as well. On the left panel go to the testing section and click the play button. A build takes place and then all the tests are run and results reported.
60+
61+
**NOTE:** This is much slower than running the `Tests_run` executable directly. The video above is sped up.
62+
63+
**NOTE:** Only c++ tests are currently integrated. Python tests are run from the `Test workbench` or with the command `FreeCAD -t 0`.
64+
65+
Alternatively, there are two vscode tasks that can be used to run the cpp and python tests directly.
66+
67+
**NOTE:** The debug tests button does not currently work. More configuration is needed to get that to work.
68+
69+
## General features of VSCode
70+
71+
On the left panel you can see the following sections:
72+
73+
- File manager: here you can control fils and search them with `Ctrl+F`. Press `F2` to rename the selected file.
74+
- Source control: here you can control git from the graphical user interface.
75+
- Search: powerful tool that can search all files and replace text.
76+
77+
In the status bar on the bottom:
78+
- You can see which branch you are on and change it from there
79+
- Click the error/warning counter to open the `PROBLEMS` panel. Here you will have a convenient collection of all the compiler warnings, cmake warnings, and problems from the workspace.
80+
81+
General editor useful shortcuts:
82+
- Rename all occurrencies of a symbol (e.g. a function name) with `F2`
83+
- Easily navigate code with the tools in the right click menu. For example `Go to definition` and `Find all references`.
84+
- Press `Ctrl+P` and type a file name to jump to that file.
85+
- Press `Ctrl+F` to search the current file.
86+
- Use `Alt+Up/Down` to move rows of text up and down.
87+
- Use `Ctrl+C/X/V` without selecting any text to copy/cut/paste entire rows.
88+
- Use `Ctrl+Shift+Up/Down` to create more cursors and edit many rows at the same time. Press `Esc` to go back to one cursor.
89+
- Hold `Ctrl` while moving left/right to move the cursor entire words at a time.
90+
- Hold `Shift` while moving left/right/up/down to select text with the cursor.
91+
92+
Read the documentation for more:
93+
94+
- [basic editing](https://code.visualstudio.com/docs/editor/codebasics)
95+
- [code navigaton](https://code.visualstudio.com/docs/editor/editingevolved)
96+
- [refactoring](https://code.visualstudio.com/docs/editor/refactoring)
97+
98+
Other useful extensions, recommended but not necessary are
99+
- ```gruntfuggly.todo-tree```: Scans all the files and reports where particular keywords appear. For example `TODO`, `FIXME`, `BUG`...
100+
101+
- ```mhutchie.git-graph```: Helps visualize git commits and branches.
102+
103+
- ```donjayamanne.githistory```: Adds two buttons to the right-click menu: `git: view file history` and `git: view line history`
104+
105+
106+
![](images/extensions.png)
107+
108+
- On the very left you can see the `Todo-Tree` extension reporting `TODO`s and `FIXME`
109+
- On the left half you can see the `git graph` extension showing all the commits on different branches. You can click a commit to see exactly what was modified by it.
110+
- On the right half you can see the `git history` of the DocumentObject.cpp file.

images/build.mp4

2.56 MB
Binary file not shown.

images/configure.mp4

1.54 MB
Binary file not shown.

images/debug.mp4

4.24 MB
Binary file not shown.

images/extensions.png

3.42 MB
Loading

images/testing.mp4

1.06 MB
Binary file not shown.

0 commit comments

Comments
 (0)