-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-ide.sh
More file actions
executable file
·50 lines (43 loc) · 1.66 KB
/
Copy pathsetup-ide.sh
File metadata and controls
executable file
·50 lines (43 loc) · 1.66 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Generates compile_commands.json and .clangd for clangd IDE support.
# Run once after cloning, or after changing platformio.ini dependencies.
#
# Usage: ./setup-ide.sh
set -e
PLATFORMIO_CORE_DIR="${PLATFORMIO_CORE_DIR:-$HOME/.platformio}"
TOOLCHAIN_DIR="$PLATFORMIO_CORE_DIR/packages/toolchain-xtensa"
if [ ! -d "$TOOLCHAIN_DIR" ]; then
echo "Error: Toolchain not found at $TOOLCHAIN_DIR"
echo "Run 'pio run' first to install dependencies."
exit 1
fi
# Detect GCC version inside the toolchain
GCC_VERSION=$(ls "$TOOLCHAIN_DIR/lib/gcc/xtensa-lx106-elf/" | head -1)
echo "Generating compile_commands.json..."
pio run -e nodemcu -t compiledb
echo "Generating .clangd with toolchain paths (GCC $GCC_VERSION)..."
cat > .clangd <<EOF
# Firmware sources: xtensa cross-compiler flags from compile_commands.json
If:
PathExclude: test/.*
CompileFlags:
CompilationDatabase: .
Add:
- -Wno-unused-command-line-argument
- -Wno-attributes
- -isystem${TOOLCHAIN_DIR}/xtensa-lx106-elf/include/c++/${GCC_VERSION}
- -isystem${TOOLCHAIN_DIR}/xtensa-lx106-elf/include/c++/${GCC_VERSION}/xtensa-lx106-elf
- -isystem${TOOLCHAIN_DIR}/xtensa-lx106-elf/include/c++/${GCC_VERSION}/backward
- -isystem${TOOLCHAIN_DIR}/lib/gcc/xtensa-lx106-elf/${GCC_VERSION}/include
- -isystem${TOOLCHAIN_DIR}/lib/gcc/xtensa-lx106-elf/${GCC_VERSION}/include-fixed
- -isystem${TOOLCHAIN_DIR}/xtensa-lx106-elf/include
- --target=xtensa
Remove:
- -mlongcalls
- -mtext-section-literals
- -free
- -fipa-pta
- -falign-functions=4
EOF
# Note: native tests use test/compile_flags.txt instead of this file.
echo "Done. Restart clangd in your IDE to apply."