Skip to content

Commit 6cf0253

Browse files
Add support for VSCode (UBC-Thunderbots#1824)
* wip debugging not working * remove debugging support * remove running stuff through vscode * Update getting-started.md
1 parent b332988 commit 6cf0253

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ Makefile
3434
.setting/
3535

3636
# VSCode
37-
.vscode/
37+
.vscode/.*
38+
!.vscode/extensions.json
3839

3940
# Vim
4041
*.swo
4142
*.swp
43+
src/compile_commands.json
4244

4345
# Stuff generated by vimdiff
4446
*_BACKUP_*.txt

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"ms-vscode.cpptools",
4+
"bazelbuild.vscode-bazel",
5+
"ms-python.python"
6+
]
7+
}
8+

docs/getting-started.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Installing CLion](#installing-clion)
1919
* [Getting your Student License](#getting-your-student-license)
2020
* [Installing CLion](#installing-clion-1)
21+
* [Installing VSCode](#installing-vscode)
2122
* [Building and Running the Code](#building-and-running-the-code)
2223
* [Debugging](#debugging)
2324
* [Profiling](#profiling)
@@ -89,7 +90,7 @@ We have several setup scripts to help you easily install the necessary dependenc
8990

9091
### Installing CLion
9192

92-
CLion is our main IDE for editing our C/C++ code. It is designed to work with our build system, `bazel`, and has all the great features of an IDE such as code completion, syntax highlighting etc. We **strongly** recommend installing CLion and using it for development.
93+
CLion is our main IDE for editing our C/C++ code. It is designed to work with our build system, `bazel`, and has all the great features of an IDE such as code completion, syntax highlighting etc. If you are running Software on an ultrabook or a virtual machine, see [Installing VSCode](#installing-vscode) for a less resource intensive option.
9394

9495
#### Getting your Student License
9596

@@ -105,6 +106,15 @@ CLion is free for students, and you can use your UBC alumni email address to cre
105106
* Run `./install_clion.sh` (* **DO NOT** download CLion yourself unless you know what you're doing. The `install_clion.sh` script will grab the correct version of CLion and the Bazel plugin to ensure everything is compatible *).
106107
* When you run CLion for the first time you will be prompted to enter your JetBrains account or License credentials. Use your student account.
107108

109+
### Installing VSCode
110+
111+
1. Inside a terminal, navigate to the environment_setup folder. Eg. `cd path/to/the/repository/Software/environment_setup`
112+
2. Run `./install_vscode.sh` (* **DO NOT** download VSCode yourself unless you know what you're doing. The `install_vscode.sh` script will grab the most stable version of VSCode)
113+
3. Open `vscode`. You can type `vscode` in the terminal, or click the icon on your Desktop.
114+
&. Click `Open Folder` and navigate to where you cloned software. So if I cloned the repo to `/home/my_username/Downloads/Software`, I would select `/home/my_username/Downloads/Software`.
115+
4. VSCode will prompt you to install recommended extensions, click `Install`, this installs necessary plugins to work on the codebase. (Bazel, C++, Python, etc..)
116+
5. Navigate to File -> Preferences -> Settings -> Workspace -> Extensions -> Bazel and select the `Bazel: Enable Code Lens` option.
117+
108118
## Building and Running the Code
109119

110120
### From the command-line
@@ -129,7 +139,6 @@ First we need to setup CLion
129139
6. Change the Project Name to whatever you want. Leave everything else as it is ("Use shared project view file" should be selected).
130140
7. Click `Finish` and you're good to go! Give CLion some time to find everything in your repo.
131141

132-
133142
Now that you're setup, if you can run it on the command line, you can run it in clion. There are two main ways of doing so.
134143
1. Open any `BUILD` file and right clight in a `cc_library()` call. This will give you the option to `Run` or `Debug` that specific target. Try it by opening `Software/src/software/geom/BUILD` and right-clicking on the `cc_library` for `angle_test`!
135144
2. Add a custom build configuration (more powerful, so make sure you understand this!)
@@ -138,6 +147,12 @@ Now that you're setup, if you can run it on the command line, you can run it in
138147
3. For `Target Expression`, you can put anything that comes after a `build`, `run`, `test`, etc. call on the command line. For example: `//software/geom:angle_test`.
139148
4. For `Bazel Command` you can put any bazel command, like `build`, `run`, `test`, etc.
140149
5. Click `Ok`, then there should be a green arrow in the top right corner by the drop-down menu. Click it and the test will run!
150+
151+
### With VSCode
152+
1. Open VSCode
153+
2. Navigate to `Software/src/software/geom/BUILD`
154+
3. On top of every `cc_test`, `cc_library` and `cc_binary` there should be a `Test ...`, `Build ...` or `Run ...` for the respective target.
155+
4. Click `Test //software/geom:angle_test` to run the `angle_test`
141156

142157
### Running our AI, Simulator or Robot Diagnostics
143158

environment_setup/install_vscode.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
echo "================================================================"
4+
echo "Installing VSCode"
5+
echo "================================================================"
6+
7+
if [ "$EUID" -ne 0 ]
8+
then echo "Please run as root"
9+
exit
10+
fi
11+
12+
if [ -d "/opt/VSCode-linux-x64" ]
13+
then
14+
echo "Old VSCode installation detected, please delete /opt/VSCode-linux-x64 and re-run"
15+
exit 1
16+
fi
17+
18+
# permalink obtained from here: https://github.com/microsoft/vscode/issues/1084
19+
download_permalink_linux64=http://go.microsoft.com/fwlink/?LinkID=620884
20+
vscode_executable_path="/usr/local/bin/vscode"
21+
22+
echo "Downloading Stable VSCode"
23+
wget -O /tmp/vscode-stable.tar.gz $download_permalink_linux64
24+
25+
echo "Unzipping to /opt folder"
26+
tar -xvf /tmp/vscode-stable.tar.gz -C /opt
27+
28+
echo "Creating Desktop Entry"
29+
30+
VSCODE_DESKTOP_ENTRY='''
31+
[Desktop Entry]
32+
Name=Visual Studio Code
33+
Comment=Programming Text Editor
34+
Exec=/opt/VSCode-linux-x64/code
35+
Icon=/opt/VSCode-linux-x64/resources/app/resources/linux/code.png
36+
Terminal=false
37+
Type=Application
38+
Categories=Programming;
39+
'''
40+
echo "$VSCODE_DESKTOP_ENTRY" > ~/.local/share/applications/vscode.desktop
41+
42+
echo "Symlink VSCode"
43+
sudo ln -s -f /opt/VSCode-linux-x64/code ${vscode_executable_path}
44+
45+
echo "================================================================"
46+
echo "Done"
47+
echo "================================================================"

0 commit comments

Comments
 (0)