Skip to content

Commit d8e78cc

Browse files
author
Farid Zakaria
authored
Add sensible setup for vscode (#2085)
* Add CmakePresets.json file with the default Debug build. This actually works for Cmake itself without vscode. `cmake --preset debug` * add `ide.md` to describe how to setup vscode to get intellisense and to use the CMakePresets.json file End result of this should be that CMake works nicely in vscode **with** clangd intellsense information ![image](https://github.com/openxla/stablehlo/assets/605070/1d0b5123-21f0-4e39-adef-9ae194d4ded2)
1 parent aa69bae commit d8e78cc

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

CMakePresets.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "debug",
6+
"displayName": "Debug w/ ccache",
7+
"generator": "Ninja",
8+
"binaryDir": "build/",
9+
"cacheVariables": {
10+
"CMAKE_BUILD_TYPE": "Debug",
11+
"LLVM_ENABLE_ASSERTIONS": "ON",
12+
"LLVM_ENABLE_LLD": "ON",
13+
"STABLEHLO_ENABLE_BINDINGS_PYTHON" : "OFF",
14+
"STABLEHLO_ENABLE_SPLIT_DWARF": "ON",
15+
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
16+
"CMAKE_CXX_COMPILER": "clang++",
17+
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
18+
"CMAKE_C_COMPILER": "clang",
19+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
20+
"MLIR_DIR": "${sourceDir}/llvm-build/lib/cmake/mlir"
21+
}
22+
}
23+
]
24+
}

build_tools/github_actions/lint_check_license.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ echo
5151
SKIPPED_SUFFIXES=(
5252
.clang-format
5353
.gitignore
54+
.json
5455
.md
5556
.mlir
5657
.mlir.bc

docs/ide.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# IDE setup
2+
3+
You can find on this page some _opinionated_ IDE setup instructions.
4+
Of course the best IDE is the one that _works for you_.
5+
6+
> If you have an improvement or recommendation to any of the setups, we welcome contributions.
7+
8+
## Visual Studio Code (vscode)
9+
10+
### CMake
11+
12+
Visual Studio Code (vscode) can work pretty well with the CMake build system.
13+
14+
The following extensions are recommended:
15+
16+
* [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools)
17+
* [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd)
18+
19+
> Note: Installing the `clangd` extension will inform you that you
20+
will need to disable the default _intellisense_ extension.
21+
This is fine, as `clangd` will provide the same functionality.
22+
23+
We include a [CmakePresets.json](../CMakePresets.json) file in the root of the repository.
24+
This file is used by the `CMake Tools` extensionto provide a list of _presets_ that
25+
can be used to configure the build. The `CMake Tools` extension will automatically
26+
detect this file and provide the presets.
27+
28+
Additionally, all the configured presets generate the `compile_commands.json` file
29+
in the build directory which will then be picked up by `clangd`.
30+
31+
We recommend additionally setting the following in your `.vscode/settings.json` file:
32+
33+
```json
34+
{
35+
"files.exclude": {
36+
"**/bazel-*": true
37+
}
38+
}
39+
```

0 commit comments

Comments
 (0)