From 8efd365474b6be97c02c9c144fa0437afbd29ec0 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 25 Jul 2024 12:11:59 -0400 Subject: [PATCH] fix compile_flags.txt to include correct paths --- .vscode/extensions.json | 3 ++- compile_flags.txt | 2 -- docs/development.md | 23 +++++++++++++++++++++++ justfile | 8 ++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 docs/development.md create mode 100644 justfile diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 12fb0ee22b3..a7aed6f1a27 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "llvm-vs-code-extensions.vscode-clangd", "ms-vscode.cpptools", "abronan.capnproto-syntax", - "DavidAnson.vscode-markdownlint" + "DavidAnson.vscode-markdownlint", + "skellock.just" ] } diff --git a/compile_flags.txt b/compile_flags.txt index dcafe872a6f..0a3b4855cfe 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -3,8 +3,6 @@ -xc++ -nostdinc -Ibazel-bin/external/dawn/include --Ibazel-bin/external/ada-url/_virtual_includes/ada-url/ --Ibazek-bin/external/simdutf/virtual_includes/simdutf/ -Ibazel-bin/external/com_cloudflare_lol_html/_virtual_includes/lolhtml -Ibazel-bin/external/perfetto/ -Iexternal/perfetto-sdk/sdk/ diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 00000000000..7d010f14a9e --- /dev/null +++ b/docs/development.md @@ -0,0 +1,23 @@ +# Development + +## Clangd + +To get language support in VSCode and other IDEs we recommend using `clangd`-based language server. +The server reads supplied `compile_flags.txt` file for correct options and include paths to resolve symbols +in opened files. + +To support `clangd` project-level operations like `Find References` `compile_commands.json` file needs to +be generated that will list all files in the project. If you do this, then it needs to be re-generated periodically +when new files appear. + +1. Install `gen-compile-commands` + +```sh +just prepare +``` + +2. Generate `compile_commands.json` + +```sh +just compile-commands +``` diff --git a/justfile b/justfile new file mode 100644 index 00000000000..fc2e297069b --- /dev/null +++ b/justfile @@ -0,0 +1,8 @@ +prepare: + cargo install gen-compile-commands + +compile-commands: + rm -f compile_commands.json | gen-compile-commands --root . --compile-flags compile_flags.txt --out compile_commands.json --src-dir ./src + +clean: + rm -f compile_commands.json