VS Code Local/Native Usage

Last update: 08 Feb 2024 [History] [Edit]

Use Case

If you have a private Almalinux 9 laptop or desktop available for code development, your best approach is to use VS Code “natively” on it.

If you have a different kind of Linux or macOS machine, you may still be able to develop analysis code “natively” on it. See the appropriate pages for details on doing that. (To be written later…)

Requirements

You will need all of the following to use VS Code natively for developing ATLAS offline/trigger code:

  • An up-to-date version of Almalinux 9 as the operating system;
  • CVMFS correctly set up to be able to mount all of the following repositories on the host: -/cvmfs/atlas.cern.ch
    • /cvmfs/atlas-nightlies.cern.ch
    • /cvmfs/atlas-condb.cern.ch
    • /cvmfs/sft.cern.ch
  • HEP_OSlibs installed;
  • An up-to-date version of VS Code, installed using the Microsoft YUM repository for RHEL/Fedora/Centos.
  • From all of the available VS Code extensions you should install at the very least ms-vscode.cpptools, ms-python.python and twxs.cmake to make best use of the editor.

Setup

Set up the partial build of the packages that you want to work on in an appropriate directory, using the WorkDir project. (If you are doing a partial checkout, you need to check out the .vscode directory using git sparse-checkout-atlas add .vscode; git checkout.) Make sure that you set up your build in a directory called build/, just beside the athena/ directory. With something like:

cd <some appropriate place>
git clone ssh://git@gitlab.cern.ch:7999/<username>/athena.git
<set up the appropriate branch>
<create a package_filters.txt file>
mkdir build
cd build/
asetup <the appropriate release>
cmake -DATLAS_PACKAGE_FILTER_FILE=../package_filters.txt ../athena/Projects/WorkDir/

Once you’ve set up a functional build directory, where you are able to build the packages that you want, just execute code from that terminal to start VS Code. In VS Code then open the athena folder that you checked out in the previous step, to start editing the code in it.

If you’ve done everything correctly, now when you open the source files included in the package(s) whose partial build you have set up, VS Code should be able to correctly parse those source files, and give you help with editing them.