Toolchain+Docs: Improve the way to enable clangd

Allowing an environment variable to enable/disable the build for clangd
and other toolchains will improve the developer-experience than
reconfiguring and building the toolchain manually.

Now you will have to call the command as following
	$ CLANG_ENABLE_CLANGD=ON Toolchain/BuildClang.sh
This commit is contained in:
Gurkirat Singh 2024-04-10 02:29:25 +05:30 committed by Andrew Kaster
parent 2d5cb1e02d
commit e444b0aace
Notes: sideshowbarker 2024-07-18 04:46:35 +09:00
2 changed files with 8 additions and 5 deletions

View file

@ -224,10 +224,7 @@ clangd that are aware of SerenityOS as a valid target. These tools will be insta
the script. Pointing your editor's plugins to the custom-built clang tools and a ``compile_commands.json`` from a clang build the script. Pointing your editor's plugins to the custom-built clang tools and a ``compile_commands.json`` from a clang build
of Serenity can enable richer error reporting than the tools that are installed for the build host. of Serenity can enable richer error reporting than the tools that are installed for the build host.
To enable building clangd as part of the clang toolchain, set ``CLANG_ENABLE_CLANGD`` to ON in To enable building clangd as part of the clang toolchain, set ``CLANG_ENABLE_CLANGD`` environment variable to ``ON``, then run ``Toolchain/BuildClang.sh``.
``Toolchain/CMake/LLVMConfig.cmake`` before running BuildClang.sh. If you already built the clang toolchain and would like to
enable the custom clangd build, change the CMake cache variable ``CLANG_ENABLE_CLANGD`` to ON in ``Toolchain/Build/clang/llvm``
and re-install with ``cd Toolchain/Build/clang/llvm && cmake ../../../Tarballs/llvm-project-$LLVM_VERSION.src/llvm -DCLANG_ENABLE_CLANGD=ON && ninja install/strip``, where $LLVM_VERSION should be tab-completable in your shell.
## Clang-format updates ## Clang-format updates

View file

@ -27,7 +27,13 @@ set(LLVM_INSTALL_UTILS ON CACHE BOOL "")
set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "Don't install headers, utils, and tools") set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "Don't install headers, utils, and tools")
set(LLVM_INSTALL_BINUTILS_SYMLINKS OFF CACHE BOOL "") set(LLVM_INSTALL_BINUTILS_SYMLINKS OFF CACHE BOOL "")
set(CLANG_ENABLE_CLANGD OFF CACHE BOOL "") if(DEFINED ENV{CLANG_ENABLE_CLANGD} AND "$ENV{CLANG_ENABLE_CLANGD}" STREQUAL "ON")
message(STATUS "Enabling clangd as a part of toolchain build")
set(CLANG_ENABLE_CLANGD ON CACHE BOOL "" FORCE)
else()
message(STATUS "Disabling clangd as a part of toolchain build")
set(CLANG_ENABLE_CLANGD OFF CACHE BOOL "" FORCE)
endif()
foreach(target x86_64-pc-serenity;aarch64-pc-serenity;riscv64-pc-serenity) foreach(target x86_64-pc-serenity;aarch64-pc-serenity;riscv64-pc-serenity)
list(APPEND targets "${target}") list(APPEND targets "${target}")