-
Notifications
You must be signed in to change notification settings - Fork 36
Setup Visual Studio Code
Visual Studio Code is the editor of choice for many people (and most of our team members also use it), so we decided to make a guide on how to setup your workspace so you can get the most functionality out of VSCode (e.g. code formatting, linting, intellisense, etc) and developing QuISP is smooth as possible.
- You should have a working build of QuISP. If you haven't done so please follow this guide Intro & Install section.
- You should have opp_test and unit test (googletest) working and running.
We recommend using clangd since it has VSCode integration via official extension. This will enable us to format code according to .clang-format
file and lint and give hints according to rules defined in .clang-tidy
file.
In this guide, we use Homebrew as our choice of a package manager. If your preference is to use another package manager (e.g. MacPorts) or install it from source, we won't cover it here.
- installing llvm (clangd is packaged with the llvm)
$ brew install llvm
- verify that your installation is successful
$ clangd --version
It should print out something like this
$ clangd version 12.0.0
- Go to your VSCode and make sure to uninstall or disable official C/C++ extension from Microsoft since this extension can have weird interaction or making some features not working properly with clangd extension.
- Once you confirmed that the C/C++ extension from Microsoft is disabled or not installed. Choose View –> Extensions, then search for “clangd” and install it.
- At this point, clangd still won't work properly because clangd relies on a file called
compiled_command.json
which contains the information of the project should be compiled. If you navigate to the code file in VSCode now (e.g. QuantumChannel.cc), you should see errors that it does not know whereomnetpp.h
is or error indicating wrong class name. - In QuISP we use GNU Make to build our project. So in order to create
compiled_command.json
we recommend using Bear. Bear is a tool for generating compilation database which clang tools uses (including clangd). - Install Bear via Homebrew
$ brew install bear
- Generate the compilation database
compiled_command.json
. We need to make a clean build of QuISP again. At project root.
/quisp-project-root/ $ make distclean; bear -- make run-unit-test
- After successfully rebuild QuISP, confirm that
compiled_command.json
is created successfully. The file should contain something like snippets below. It will create one compile arguments for each file as one json object in the array.
[
{
"arguments": [
"/usr/local/Cellar/llvm/12.0.0/bin/clang-12",
"-c",
"-std=c++14",
"-O3",
"-DNDEBUG=1",
"-isystem",
"/Users/aqua/projects/omnetpp-5.6.2/tools/macosx/include",
"-Wno-deprecated-register",
"-Wno-unused-function",
"-fno-omit-frame-pointer",
"-DWITH_MPI",
"-DXMLPARSER=libxml",
"-DPREFER_QTENV",
"-DWITH_QTENV",
"-DWITH_PARSIM",
"-DWITH_NETBUILDER",
"-DWITH_OSG",
"-DWITH_OSGEARTH",
"-I.",
"-I/usr/local/Cellar/eigen/3.3.9/include/eigen3",
"-I/Users/aqua/projects/omnetpp-5.6.2/include",
"-o",
"out/clang-release//channels/QuantumChannel.o",
"channels/QuantumChannel.cc"
],
"directory": "/Users/aqua/projects/quisp/quisp",
"file": "/Users/aqua/projects/quisp/quisp/channels/QuantumChannel.cc",
"output": "/Users/aqua/projects/quisp/quisp/out/clang-release//channels/QuantumChannel.o"
},
...
]
- Navigate to code file in QuISP (e.g. QuantumChannel.cc), you should see all the errors disappear.
(TBD)