Using VSCode and FemtoIDE together

Femto and VSCode work beautifully together.

Follow these steps to create a new project in FemtoIDE and then switch to VSCode.


Step 1: Install VSCode following these instructions for your platform:


Step 2: Create a new project in Femto by clicking


Step 3: Create a new project in Femto (note the location as you will need this later)


Step 4: Click the Femto icon in the top- left corner and select ‘Init VSCode Project’

The existing program will compile and the VSCode tasks and other configuration options will be added to the project.


Step 5: Close Femto and open VSCode and select Open Folder from the File menu. Find the folder created by Femto.


Complete

You are ready to program!



Compiling

On Windows, the program can be compiled using Control-Shift-B.

On a Mac, the program can be compiled using Command-Shift-B.

It will compile and automatically launch the Femto emulator. If you attempt to compile again with the emulator window open, it will complain that the task is already active. Either click ‘Terminate Task’ or close the emulator screen before compiling again.



Clean Compile

If you change any of the project.json file properties, you will probably need to do a clean compile.

Step 1: Select Terminal and Run Task... from the main menu.


Step 2: Select Femto clean compile from the menu.



Other Addins

As you use VSCode, it will detect that you are using C++ and will prompt you to install some additional packages, such as C++ IntelliSense and the like. Its up to you if you want to install these - they are all free and you can always uninstall them if you do not like them.

I have installed the following and they work for me:

There are also many more plugins available - have a look at them via the extensions view.

If you like useless extensions, then consider this one:

8 Likes

The setup looks very easy (I already have VSCode). I need to test this soon!

I use VSCode for Python, C++ and Ansible automation. Its a great all-round product.

I still use the full Visual Studio for C# though.

I bit more instructions. Especially for debugging in the simulator.

  • To swich between the Pokitto HW platform and the simulator platform, you need to change project.json by editing it like this (you can also use FemtoIDE UI for switching the platform):
    "target": "Pokitto",
    Or
    "target": "linux",
    FemtoIDE will automatically generate “compile_commands.json” and “.vscode/c_cpp_properties.json” for that platform for VSCode.
  • To be able to create the debug builds for the simultaor, you need to add new commands to the tasks.json, like this:
    {
        "label": "Femto debug compile",
        "type": "shell",
        "command": "/home/hannu/bin/FemtoIDE/IDE \"MyProject\" compileDebug onEmulatorStopped",
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    },
    {
        "label": "Femto clean",
        "type": "shell",
        "command": "/home/hannu/bin/FemtoIDE/IDE \"MyProject\" clean",
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build"
        }
    }

So I was testing VSCode with FemtoIDE for some time, but finally ended up using the FemtoIDE only. There are some rough edges in FemtoIDE (like compiler error handling) but overall it is simpler to use and better optimized for Pokitto dev. There is also a good support for the debug probe HW. In VSCode there are benefits also, like global search.
However, it is now very easy to switch the dev tool so lets see if I will go back to VSCode time to time :wink:

Actually there some kind of global search also in FemtoIDE, you can hit F3 and a search window will appear on the right side of the window:

There you can search for something trough all the files in project.

1 Like

That is true. It searches from the project files, but not e.g. from PokittoLib. In vscode you can enter any path in the input field where to search from.

In VSCode, you can also click on a variable and see where its declared and used.

2 Likes

That is handy

2 Likes

Sure is …

Anyhow, I am not trying to convert anyone here. I happen to like VSCode and use it a lot so I was sooooo happy when @FManga added the VSCode support.

2 Likes