-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcclangd
executable file
·25 lines (22 loc) · 993 Bytes
/
cclangd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
if [[ "$#" -eq 1 && "$1" = "--version" ]]; then
echo "1.0.0"
exit 0
fi
CONTAINER_NAME="psxmc"
PROJECT_ROOT_PATH="$(pwd)"
# Verify that a contianer by this name actually exists, and is running
if [ -z "$(docker ps -q -f name="$CONTAINER_NAME" -f status=running)" ]; then
echo "[cclangd] No container running, determining existance of 'start_clangd.sh' script in project root"
if [ -e "$PROJECT_ROOT_PATH/start_clangd.sh" ]; then
echo "[cclangd] Start script exists in project root, invoking it to start container"
exec "$PROJECT_ROOT_PATH/start_clangd.sh" "$CONTAINER_NAME" "$PROJECT_ROOT_PATH"
else
echo "[cclangd] No start script exists in project root, starting on host"
clangd --background-index
fi
else
echo "[cclangd] Container running, executing inside it"
# Important part here is both the '-i' and the redirection of STDERR
docker exec -i "$1" /usr/bin/clangd --background-index 2>/dev/null
fi