Skip to content

Commit

Permalink
cmake/ci: add custom built clangd
Browse files Browse the repository at this point in the history
This change will add clangd to our packages.

If you want to build clangd manually, you'll have to add
`clang-tools-extra` to `LLVM_ENABLE_PROJECTS`. Also if you want it to
get installed with the `install-distribution` rule, you'll have to
specify `LLVM_ENABLE_PROJECTS` before specifying the initial cache with
`-C` (see `debian/build.sh` for an example).

This closes: leaningtech/cheerp-meta#144
  • Loading branch information
Hyxogen authored and yuri91 committed Feb 7, 2024
1 parent 97ae7db commit e8f410b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 13 additions & 3 deletions debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ if [ -n "$CIRCLECI" ]; then
USE_CCACHE=On
if [ "$CIRCLE_BRANCH" != "master" ]; then
ENABLE_LLVM_ASSERTIONS=On
else
BUILD_CLANGD=1
fi
FLAGS_RELEASE="-O2"
fi
Expand Down Expand Up @@ -65,12 +67,17 @@ llvm_ninja_command() {
}

build_compiler() {
if [ -n "$BUILD_CLANGD" ]; then
LLVM_PROJECTS="clang;clang-tools-extra"
else
LLVM_PROJECTS="clang"
fi

cmake \
-C llvm/CheerpCmakeConf.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="$FLAGS_RELEASE" \
-DCLANG_VENDOR="Cheerp $deb_version" \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_ENABLE_PROJECTS="$LLVM_PROJECTS" \
llvm/ \
-GNinja \
-DLLVM_ENABLE_ASSERTIONS="$ENABLE_LLVM_ASSERTIONS" \
Expand All @@ -80,10 +87,13 @@ build_compiler() {
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=ld \
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=ld \
-DLLVM_CCACHE_BUILD="$USE_CCACHE" \
-C llvm/CheerpCmakeConf.cmake \
-B build_llvm

export DESTDIR="$BUILD_DIR"
llvm_ninja_command install-distribution

unset LLVM_PROJECTS
unset DESTDIR
}

Expand Down Expand Up @@ -227,7 +237,7 @@ case "$1" in
install_all
;;
tar-compiler)
tar -cvjf "$2" build_llvm debian/build.sh cmake third-party llvm clang .git/logs/HEAD
tar -cvjf "$2" build_llvm debian/build.sh cmake third-party llvm clang clang-tools-extra .git/logs/HEAD
;;
tar-install)
tar -cvjf "$2" "$BUILD_DIR/."
Expand Down
6 changes: 5 additions & 1 deletion llvm/CheerpCmakeConf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ set(LLVM_TOOLCHAIN_TOOLS
llc
CACHE STRING "")

if("${LLVM_ENABLE_PROJECTS}" MATCHES ".*clang-tools-extra.*")
set(CHEERP_CLANGD clangd)
endif()

set(LLVM_DISTRIBUTION_COMPONENTS
clang
clang-resource-headers
${CHEERP_CLANGD}
${LLVM_TOOLCHAIN_TOOLS}
CACHE STRING "")

0 comments on commit e8f410b

Please sign in to comment.