Author Topic: [Tutorial]Using the VitaSDK/DolceSDK with Visual Studio Code  (Read 9626 times)

Offline CreepNT

  • End User
  • *
  • Posts: 14
  • Code copy-pasting master
    • View Profile
[Tutorial]Using the VitaSDK/DolceSDK with Visual Studio Code
« on: April 18, 2020, 01:19:57 PM »
After teakhanirons told me some guy got VitaSDK to work in WSL (which I already knew since WSL is more or less a Linux VM), I decided to also get Visual Studio Code to work with it. Fortunately, Microsoft released all the tools required to make this a fairly simple process !

Note : I got this configuration working after following dots' tutorial and manually fixing stuff.
This may not be and most likely isn't the best way to configure VSC to do this job, but It Just Works(TM).

FOR NON-WINDOWS USERS, SEE POST 2 !

Requirements :

For this tutorial, I will use the Debian WSL distribution since it's the one I always install.

Installing the WSL and the VitaSDK/DolceSDK :

Just follow the instructions on MS' website. If you're not familiar with Linux, install Debian as the distribution. Else, choice is up to you.
Don't forget to initialize your distro. Choose whatever you want as the UNIX username and a UNIX password you won't forget (Note that the UNIX password isn't shown when typing it, for security reasons).

Once the distro is ready, install the VitaSDK / DolceSDK following the Linux instructions. For the exports, if you don't know how to edit the .bashrc file, type
Code: [Select]
nano ~/.bashrcThis will open a text editor. Paste the export information at the end of this file, then restart the WSL distro.

Setting up Visual Studio Code :

Install VS Code for Windows then open it.
Click on the Extensions button on the left sidebar, search for C/C++ and Remote - WSL, all made by Microsoft (as shown underlined), and install them.


After both extensions are installed, it is time to configure everything.
Press CTRL+SHIFT+P to open the Command Palette and type Settings json, and look for Open Settings (JSON).

Add the following to your settings.json:
Code: [Select]
    "cmake.buildDirectory": "${workspaceRoot}/build/${buildType}",
    "cmake.configureOnOpen": true,
    "cmake.cmakePath": "/usr/bin/cmake",
    "cmake.generator": "Unix Makefiles"

Be sure to have a proper syntax.
Here's what settings.json could look like (I also disabled the telemetry and changed a few other settings, which is optional) :
Spoiler for settings.json:

Now, go into your WSL terminal, and browse to a project's directory, then type
Code: [Select]
code .
This should install the Visual Studio Code server for WSL, and open a new VSC window.
Go back to the Extensions panel. You should now have two panel : Local and WSL - Debian (or whatever distro you chose), with the latter empty.
Click on the Install in WSL: <distro> button of the C/C++ extension. Search for CMake and install the CMake Tools extension (NOT CMake !) by Microsoft.

Open the Command Palette again, and type cmake, and look for Edit User-Local CMake Kits. You might get a message saying you don't have any kits, click on Accept of whatever the button is. This should then open cmake-tools-kits.json.
Add the following at the beggining, just after the opening bracket ( [ ) :
Spoiler for VitaSDK users:
Code: [Select]
  {
    "name": "VitaSDK",
    "toolchainFile": "/usr/local/vitasdk/share/vita.toolchain.cmake",
    "preferredGenerator": {
      "name": "Unix Makefiles"
    },
    "environmentVariables": {
      "VITASDK": "/usr/local/vitasdk",
      "CMT_MINGW_PATH": "/usr/local/vitasdk/bin"
    }
  },
Spoiler for DolceSDK users:
Code: [Select]
  {
    "name": "DolceSDK",
    "toolchainFile": "/home/YOURUSERNAME/.local/dolcesdk/share/dolce.toolchain.cmake",
    "preferredGenerator": {
      "name": "Unix Makefiles"
    },
    "environmentVariables": {
      "DOLCESDK": "/home/YOURUSERNAME/.local/dolcesdk",
      "CMT_MINGW_PATH": "/home/YOURUSERNAME/.local/dolcesdk/bin"
    }
  },

Example cmake-tools-kits.json (not the full file) :
Spoiler for cmake-tools-kits.json:

Make sure you saved all the config files. CMake should now be configured.
Look at the bottom left corner of the Window, you should see "No Kits Selected", click on that and change it to "VitaSDK"/"DolceSDK".


You should be able to build now by clicking the "Build:" button in the same bottom bar area, or pressing F7.

Quote from: dots_tb
If it doesn't work the first time:
  • Navigate to the location of the source folder and look inside it.
  • Make sure there is no build folder.
  • Open the command palette and then type Developer Reload and reload the window
And with luck, it should configure CMake and allow you to build the project.

Setting up Projects :

You will have to do this for every new project !
Reminder : to open a new project, open its folder in the WSL terminal and type code .

Open the Command Palette and type C++, then look for C/C++: Edit Configurations (UI)


Add a new configuration called VitaSDK/DolceSDK and set the compiler path to :
Spoiler for VitaSDK users:
Code: [Select]
/usr/local/vitasdk/bin/arm-vita-eabi-gcc
Spoiler for DolceSDK users:
Code: [Select]
/home/YOURUSERNAME/.local/dolcesdk/bin/arm-dolce-eabi-gcc


Scroll down and un-collapse Advanced Settings then look for and set the Browse Path to the following:
Spoiler for VitaSDK users:
Code: [Select]
/usr/local/vitasdk/arm-vita-eabi/include
Spoiler for DolceSDK users:
Code: [Select]
/home/YOURUSERNAME/.local/dolcesdk/include


This should set up IntelliSense.
Note : You might have to select the VitaSDK/DolceSDK configuration in the bottom right corner of the window.


With that, you should now be able to enjoy VS Code for your PS Vita software development.

Note: In case you want to make a new project and VSC doesn't connect to the WSL automatically, open the Command Palette, type WSL and click
on Remote-WSL : New Window

Optional : Enabling WSL2

WSL2 is the new revision of WSL. While WSL1 is more like a compatibility layer, WSL2 runs a containerized Linux kernel, hence being more of a VM than WSL1 was. To enable WSL2, see here.

« Last Edit: June 04, 2021, 02:45:53 PM by CreepNT »
Code: [Select]
*(int*)🥚 = 0xDEADCAFE;

Offline CreepNT

  • End User
  • *
  • Posts: 14
  • Code copy-pasting master
    • View Profile
Using VitaSDK/DolceSDK with VSC for non-Windows users
« Reply #1 on: April 18, 2020, 01:35:37 PM »
For Linux/Mac users :
Mac tested by @Deppressiety

Requirements :


Installing the VitaSDK/DolceSDK :

Install the VitaSDK/DolceSDK following the Linux instructions. For the exports, if you don't know how to edit the .bashrc file, type
Code: [Select]
nano ~/.bashrcThis will open a text editor. Paste the export information at the end of this file, then restart your terminal.

Setting up Visual Studio Code :

Install VS Code then open it.
Click on the Extensions button on the left sidebar, search for C/C++ and CMake Tools, both made by Microsoft (as shown underlined), and install them.


After both extensions are installed, it is time to configure everything.
Press CTRL+SHIFT+P to open the Command Palette and type Settings json, then look for Open Settings (JSON).

Add the following to your settings.json:
Code: [Select]
    "cmake.buildDirectory": "${workspaceRoot}/build/${buildType}",
    "cmake.configureOnOpen": true,
    "cmake.cmakePath": "/usr/bin/cmake",
    "cmake.generator": "Unix Makefiles"

Be sure to have a proper syntax. Here's what settings.json could look like (I also disabled the telemetry and changed a few other settings, which is optional) :
Spoiler for settings.json:


Open the Command Palette again, and type cmake, and look for Edit User-Local CMake Kits. You might get a message saying you don't have any kits, click on Accept of whatever the button is. This should then open cmake-tools-kits.json.
Add the following at the beggining, just after the opening bracket ( [ ) :
Spoiler for VitaSDK users:
Code: [Select]
  {
    "name": "VitaSDK",
    "toolchainFile": "/usr/local/vitasdk/share/vita.toolchain.cmake",
    "preferredGenerator": {
      "name": "Unix Makefiles"
    },
    "environmentVariables": {
      "VITASDK": "/usr/local/vitasdk",
      "CMT_MINGW_PATH": "/usr/local/vitasdk/bin"
    }
  },
Spoiler for DolceSDK users:
Code: [Select]
  {
    "name": "DolceSDK",
    "toolchainFile": "/usr/local/dolcesdk/share/dolce.toolchain.cmake",
    "preferredGenerator": {
      "name": "Unix Makefiles"
    },
    "environmentVariables": {
      "DOLCESDK": "/usr/local/dolcesdk",
      "CMT_MINGW_PATH": "/usr/local/dolcesdk/bin"
    }
  },

Example cmake-tools-kits.json (not the full file) :
Spoiler for cmake-tools-kits.json:

Make sure you saved all the config files. CMake should now be configured.
Look at the bottom left corner of the Window, you should see "No Kits Selected", click on that and change it to "VitaSDK"/"DolceSDK".


You should be able to build now by clicking the "Build:" button in the same bottom bar area, or pressing F7.

Quote from: dots_tb
If it doesn't work the first time:
  • Navigate to the location of the source folder and look inside it.
  • Make sure there is no build folder.
  • Open the command palette and then type Developer Reload and reload the window
And with luck, it should configure CMake and allow you to build the project.

Setting up Projects :

You will have to do this for every new project !

Open the Command Palette and type C++, then look for C/C++: Edit Configurations (UI)


Add a new configuration called VitaSDK/DolceSDK and set the Compiler Path to :
Spoiler for VitaSDK users:
Code: [Select]
/usr/local/vitasdk/bin/arm-vita-eabi-gcc
Spoiler for DolceSDK users:
Code: [Select]
/usr/local/dolcesdk/bin/arm-dolce-eabi-gcc


Scroll down and un-collapse Advanced Settings then look for and set the Browse Path to the following:
Spoiler for VitaSDK users:
Code: [Select]
/usr/local/vitasdk/bin/arm-vita-eabi/include
Spoiler for DolceSDK users:
Code: [Select]
/usr/local/dolcesdk/include


This should set up IntelliSense.
Note : You might have to select the VitaSDK/DolceSDK configuration in the bottom right corner of the window.



With that, you should now be able to enjoy VS Code for your PS Vita software development.
« Last Edit: April 25, 2020, 06:30:24 PM by CreepNT »
Code: [Select]
*(int*)🥚 = 0xDEADCAFE;

Offline CreepNT

  • End User
  • *
  • Posts: 14
  • Code copy-pasting master
    • View Profile
placeholder title
« Reply #2 on: April 18, 2020, 01:52:44 PM »
Note : instead of re-creating the VitaSDK configuration for each project, you can copy the .vscode folder and its content from one project to another (might break stuff if you add further configuration).
« Last Edit: April 19, 2020, 12:19:37 PM by CreepNT »
Code: [Select]
*(int*)🥚 = 0xDEADCAFE;

Offline Cimmerian_Iter

  • End User
  • *
  • Posts: 11
    • View Profile
Re: [Tutorial]Using the VitaSDK/DolceSDK with Visual Studio Code
« Reply #3 on: April 25, 2020, 03:55:44 PM »
I'll try to do that on mac os