Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions .script/build-rmcs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,10 +7,47 @@ cd "${RMCS_PATH}"/rmcs_ws || exit
[[ -x /opt/cmake/bin/cmake ]] &&
export PATH="/opt/cmake/bin:$PATH"

command -v clang &>/dev/null &&
export CC=clang
cmake_toolchain_args=()
event_handlers_args=()

if [[ "${RMCS_USE_LLVM}" == "ON" ]]; then
missing_tools=()
for tool in clang clang++ llvm-ar llvm-ranlib ld.lld ninja; do
if ! command -v "${tool}" &>/dev/null; then
missing_tools+=("${tool}")
fi
done

if ((${#missing_tools[@]} > 0)); then
echo "> ERROR: LLVM toolchain is required when RMCS_USE_GCC is not ON."
echo "> Missing tools: ${missing_tools[*]}"
echo "> Install the missing tools, or set RMCS_USE_GCC=ON to build with GCC."
exit 1
fi

command -v clang++ &>/dev/null &&
echo "> Compiling With LLVM ToolChain"
export CC=clang
export CXX=clang++
cmake_toolchain_args=(
"-G Ninja"
"-D CMAKE_MESSAGE_LOG_LEVEL=ERROR"
"-D CMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld"
"-D CMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld"
"-D CMAKE_AR=$(command -v llvm-ar)"
"-D CMAKE_RANLIB=$(command -v llvm-ranlib)"
)
event_handlers_args=(
--event-handlers console_cohesion+
)
fi

colcon_args=(
--symlink-install --merge-install
"${event_handlers_args[@]}"
)
cmake_args=(
"${cmake_toolchain_args[@]}"
)

colcon build --symlink-install --merge-install "$@" --cmake-args -G Ninja
CLICOLOR_FORCE=1 NINJA_STATUS="" \
colcon build "${colcon_args[@]}" "$@" --cmake-args "${cmake_args[@]}"
51 changes: 51 additions & 0 deletions .script/complete/_build-rmcs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
#compdef build-rmcs

local _comp_func="${_comps[colcon]}"

if [[ -z "${_comp_func}" ]]; then
if (( $+functions[_python_argcomplete] )); then
_comp_func="_python_argcomplete"
elif (( $+functions[_colcon] )); then
_comp_func="_colcon"
else
_message "colcon completion not found. Please source colcon completion setup."
return 1
fi
fi

if [[ "${_comp_func}" == "_python_argcomplete" ]]; then
local IFS=$'\013'
local -a completions
local _comp_line _comp_point

_comp_line="colcon build${BUFFER#build-rmcs}"
_comp_point=$((CURSOR + 2))

completions=($(IFS="$IFS" \
COMP_LINE="${_comp_line}" \
COMP_POINT="${_comp_point}" \
_ARGCOMPLETE=1 \
_ARGCOMPLETE_SHELL="zsh" \
_ARGCOMPLETE_SUPPRESS_SPACE=1 \
__python_argcomplete_run colcon))

_describe colcon completions -o nosort
return 0
fi

local -a _orig_words
local _orig_current

_orig_words=("${words[@]}")
_orig_current=${CURRENT}

words=(colcon build "${_orig_words[@]:1}")
CURRENT=$((_orig_current + 1))

"${_comp_func}" "$@"
local status=$?

words=("${_orig_words[@]}")
CURRENT=${_orig_current}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

return $status
21 changes: 14 additions & 7 deletions Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,17 +88,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
rm -rf /var/lib/apt/lists/* /tmp/*

# Install latest stable llvm-toolchain
ARG LLVM_VERSION=22
RUN mkdir -p /etc/apt/keyrings && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg -o /etc/apt/keyrings/llvm-snapshot.gpg --dearmor && \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://mirrors.tuna.tsinghua.edu.cn/llvm-apt/noble/ llvm-toolchain-noble-22 main" \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://mirrors.tuna.tsinghua.edu.cn/llvm-apt/noble/ llvm-toolchain-noble-${LLVM_VERSION} main" \
| tee /etc/apt/sources.list.d/llvm.list && \
apt-get update && \
apt-get install -y --no-install-recommends clang-22 clangd-22 clang-format-22 lldb-22 && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 100 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 100 && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-22 100 && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-22 100 && \
update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-22 100 && \
apt-get install -y --no-install-recommends \
clang-${LLVM_VERSION} clangd-${LLVM_VERSION} clang-format-${LLVM_VERSION} clang-tidy-${LLVM_VERSION} \
lldb-${LLVM_VERSION} lld-${LLVM_VERSION} llvm-${LLVM_VERSION} && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${LLVM_VERSION} 100 && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

漏了 clang-tidy

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下载的包还是显式写出来吧,这样可以看出我们用到了什么

update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-${LLVM_VERSION} 100 && \
update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-${LLVM_VERSION} 100 && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*

# Generate/load ssh key and setup unison
Expand Down