Skip to content

Commit fd2c5f9

Browse files
committed
解决第三方库文件报错问题
1 parent 11f6f20 commit fd2c5f9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.github/config/platformio.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ default_envs = mega2560
1010
platform = atmelavr
1111
board = megaatmega2560
1212
framework = arduino
13+
14+
build_flags =
15+
-I src
16+

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)