File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,7 @@ default_envs = mega2560
1010platform = atmelavr
1111board = megaatmega2560
1212framework = arduino
13+
14+ build_flags =
15+ -I src
16+
Original file line number Diff line number Diff line change @@ -204,6 +204,35 @@ jobs:
204204 pip install platformio
205205 cp ./.action/.github/config/platformio.ini .
206206
207+ # 检查 library.properties 是否存在
208+ if [ -f library.properties ]; then
209+ # 提取 depends 字段
210+ DEPENDS=$(awk -F= '/^[[:space:]]*depends[[:space:]]*=/ {print $2; exit}' library.properties | tr -d '\r')
211+
212+ # 如果 DEPENDS 非空才继续处理
213+ if [ -n "$DEPENDS" ]; then
214+ echo "Library dependencies found: $DEPENDS"
215+
216+ # 如果 platformio.ini 中没有 lib_deps 段,新增
217+ if ! grep -q 'lib_deps' platformio.ini; then
218+ echo "Adding lib_deps to platformio.ini"
219+ echo "lib_deps =" >> ./platformio.ini
220+ fi
221+
222+ # 将每个依赖(逗号分隔)添加到 lib_deps,每行一个
223+ echo "$DEPENDS" | tr ',' '\n' | while read dep; do
224+ dep=$(echo $dep | xargs) # 去掉首尾空格
225+ if [ -n "$dep" ]; then
226+ echo " $dep" >> platformio.ini
227+ fi
228+ done
229+ else
230+ echo "No depends field found in library.properties, skipping lib_deps update."
231+ fi
232+ else
233+ echo "library.properties not found, skipping lib_deps update."
234+ fi
235+
207236 - name : Generate compile_commands.json
208237 run : |
209238 pio run -t compiledb
You can’t perform that action at this time.
0 commit comments