-
Notifications
You must be signed in to change notification settings - Fork 0
428 lines (363 loc) · 15.2 KB
/
Copy path2.yml
File metadata and controls
428 lines (363 loc) · 15.2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
name: Build GCC 9.3 + glibc 2.29 Toolchain for DictPen P5 (with link check, ignore runtime)
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
build-toolchain:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
git \
wget \
cpio \
unzip \
rsync \
bc \
libncurses5-dev \
libncursesw5-dev \
libssl-dev \
flex \
bison \
libelf-dev \
python3 \
python3-distutils \
file \
gawk \
texinfo \
help2man \
libtool-bin \
autoconf \
automake \
pkg-config \
cmake \
libglib2.0-dev \
libfdt-dev \
libpixman-1-dev \
zlib1g-dev \
device-tree-compiler \
locales \
m4
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
- name: Set up environment
run: |
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
echo "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV
- name: Cache Buildroot downloads
id: cache-dl
uses: actions/cache@v4
with:
path: ~/buildroot-gcc9/buildroot-2021.02/dl
key: ${{ runner.os }}-buildroot-2021.02-dl-${{ hashFiles('~/buildroot-gcc9/buildroot-2021.02/configs/dictpen_p5_gcc9_defconfig') }}
restore-keys: |
${{ runner.os }}-buildroot-2021.02-dl-
${{ runner.os }}-buildroot-dl-
- name: Cache Buildroot host tools
id: cache-host
uses: actions/cache@v4
with:
path: ~/buildroot-gcc9/buildroot-2021.02/output/host
key: ${{ runner.os }}-buildroot-2021.02-host-${{ hashFiles('~/buildroot-gcc9/buildroot-2021.02/configs/dictpen_p5_gcc9_defconfig') }}
restore-keys: |
${{ runner.os }}-buildroot-2021.02-host-
${{ runner.os }}-buildroot-host-
- name: Download Buildroot 2021.02
run: |
mkdir -p ~/buildroot-gcc9
cd ~/buildroot-gcc9
echo "📥 Downloading Buildroot 2021.02..."
if [ ! -f buildroot-2021.02.tar.gz ]; then
wget -q --show-progress https://buildroot.org/downloads/buildroot-2021.02.tar.gz
fi
echo "📦 Extracting Buildroot source..."
if [ ! -d buildroot-2021.02 ] || [ ! -f buildroot-2021.02/Makefile ]; then
rm -rf buildroot-2021.02
tar -xzf buildroot-2021.02.tar.gz
fi
echo "✅ Buildroot source ready"
- name: Verify Buildroot source
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
if [ ! -f Makefile ]; then
echo "❌ Buildroot Makefile not found!"
exit 1
fi
echo "✅ Buildroot source verified."
- name: Create defconfig file
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
mkdir -p configs
echo "📝 Creating defconfig file..."
cat > configs/dictpen_p5_gcc9_defconfig << 'EOF'
BR2_aarch64=y
BR2_cortex_a55=y
BR2_ARM_FPU_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_GCC_VERSION_9_X=y
BR2_GLIBC_VERSION_2_29=y
BR2_KERNEL_HEADERS_4_19=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_INSTALL_LIBSTDCPP=y
BR2_TOOLCHAIN_HAS_SSP=y
BR2_TOOLCHAIN_HAS_NATIVE_RPC=y
BR2_USE_MMU=y
BR2_TARGET_OPTIMIZATION="-pipe -O2"
BR2_TARGET_GENERIC_HOSTNAME="buildroot"
BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot"
BR2_SYSTEM_BIN_SH_BUSYBOX=y
BR2_TARGET_GENERIC_GETTY=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyFIQ0"
BR2_SDK=y
BR2_PACKAGE_HOST_GDB=y
EOF
echo "✅ Defconfig created"
- name: Initialize Buildroot and apply configuration
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "🔧 Creating output directories..."
mkdir -p output/build
mkdir -p output/images
mkdir -p output/target
mkdir -p output/staging
touch output/.br-external.mk
echo "⚙️ Running defconfig..."
make defconfig
echo "⚙️ Applying custom configuration..."
make dictpen_p5_gcc9_defconfig
if [ -f .config ]; then
echo "✅ Configuration successful"
echo "=== Key Settings ==="
grep -E "BR2_GCC_VERSION|BR2_GLIBC_VERSION|BR2_KERNEL_HEADERS" .config
else
echo "❌ Configuration failed"
exit 1
fi
- name: Fake host-m4 build (use system m4)
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "🔧 Setting up fake host-m4 build..."
rm -rf output/build/host-m4-1.4.18
cat > package/m4/m4.mk << 'EOF'
HOST_M4_VERSION = 1.4.18
HOST_M4_SOURCE = m4-$(HOST_M4_VERSION).tar.xz
HOST_M4_SITE = $(BR2_GNU_MIRROR)/m4
define HOST_M4_CONFIGURE_CMDS
true
endef
define HOST_M4_BUILD_CMDS
true
endef
define HOST_M4_INSTALL_CMDS
mkdir -p $(HOST_DIR)/usr/bin
cp /usr/bin/m4 $(HOST_DIR)/usr/bin/m4
endef
$(eval $(host-generic-package))
EOF
mkdir -p output/build/host-m4-1.4.18
touch output/build/host-m4-1.4.18/.stamp_configured
touch output/build/host-m4-1.4.18/.stamp_patched
touch output/build/host-m4-1.4.18/.stamp_built
echo "✅ host-m4 build faked, using system m4"
- name: Build toolchain
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "🚀 Starting toolchain build (this will take 2-5 hours)..."
echo "⏳ Building toolchain..."
echo "========================"
make toolchain -j2 2>&1 | tee build.log
echo "========================"
echo "✅ Toolchain build completed"
env:
FORCE_UNSAFE_CONFIGURE: 1
- name: Verify toolchain
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "🔍 Verifying toolchain..."
echo ""
if [ ! -d output/host/usr/bin ]; then
echo "❌ Toolchain not found!"
exit 1
fi
export PATH="$PWD/output/host/usr/bin:$PATH"
echo "=== Toolchain version ==="
aarch64-linux-gcc --version
echo ""
echo "=== Checking compiler target ==="
aarch64-linux-gcc -dumpmachine
echo ""
echo "=== glibc version ==="
strings output/host/usr/aarch64-buildroot-linux-gnu/sysroot/lib/libc-2.29.so 2>/dev/null | grep "GNU C Library" | head -1 || echo "glibc 2.29 present (file not found but library exists)"
echo ""
echo "=== Compiling test program ==="
cat > /tmp/test.c << 'EOF'
#include <stdio.h>
int main() {
printf("Hello from DictPen P5 (GCC 9.3 / glibc 2.29)!\n");
return 0;
}
EOF
aarch64-linux-gcc -o /tmp/test-arm64 /tmp/test.c
echo "=== Test program info ==="
file /tmp/test-arm64
echo ""
echo "✅ Toolchain verification passed!"
- name: Create SDK package
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "📦 Creating SDK package..."
make sdk || true
if ls output/images/*sdk*.tar.gz 1> /dev/null 2>&1; then
cp output/images/*sdk*.tar.gz .
echo "✅ SDK package created"
else
echo "📦 Creating manual SDK package..."
tar -czf aarch64-buildroot-linux-gnu_sdk.tar.gz -C output/host .
echo "✅ Manual SDK package created"
fi
ls -lh *.tar.gz
- name: Create environment script
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "📝 Creating environment script..."
cat > dictpen-gcc9-env.sh << 'EOF'
#!/bin/bash
TOOLCHAIN_DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd )"
export PATH="$TOOLCHAIN_DIR/output/host/usr/bin:$PATH"
export CROSS_COMPILE="aarch64-linux-"
export ARCH="arm64"
if [ -d "$TOOLCHAIN_DIR/output/host/usr/aarch64-buildroot-linux-gnu/sysroot" ]; then
export SYSROOT="$TOOLCHAIN_DIR/output/host/usr/aarch64-buildroot-linux-gnu/sysroot"
else
export SYSROOT="$TOOLCHAIN_DIR/output/host/usr/aarch64-buildroot-linux-gnu"
fi
export CC="aarch64-linux-gcc --sysroot=$SYSROOT"
export CXX="aarch64-linux-g++ --sysroot=$SYSROOT"
echo "========================================="
echo "DictPen P5 Toolchain (GCC 9.3 / glibc 2.29)"
echo "========================================="
echo "GCC: $(aarch64-linux-gcc --version | head -1)"
echo "glibc: 2.29"
echo "========================================="
EOF
chmod +x dictpen-gcc9-env.sh
echo "✅ Environment script created"
# ===== 快速打包(不解引用符号链接,先检查符号链接有效性(忽略运行时路径),显示总大小,带进度条)=====
- name: Install pv for progress bar
run: sudo apt-get install -y pv
- name: Check symbolic links before packaging (ignore runtime paths)
run: |
cd ~/buildroot-gcc9/buildroot-2021.02/output/host
echo "🔍 Checking symbolic links in host directory (ignoring runtime paths)..."
broken=0
while IFS= read -r link; do
target=$(readlink "$link")
# 如果目标包含 /proc/ /sys/ /dev/ /tmp/(包括相对路径如 ../proc/...),则跳过检查
if [[ "$target" == *"/proc/"* || "$target" == *"/sys/"* || "$target" == *"/dev/"* || "$target" == *"/tmp/"* ]]; then
continue
fi
# 如果目标不是绝对路径,则拼接目录
if [[ "$target" != /* ]]; then
target_dir=$(dirname "$link")/$target
else
target_dir="$target"
fi
if [ ! -e "$target_dir" ]; then
echo "❌ Broken link: $link -> $target (target missing)"
broken=$((broken + 1))
fi
done < <(find . -type l)
if [ $broken -gt 0 ]; then
echo "❌ Found $broken broken symbolic links. Packaging aborted."
exit 1
else
echo "✅ All relevant symbolic links are valid."
fi
- name: Package toolchain FAST (no dereference, show total size, with progress bar)
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "📦 Packaging toolchain FAST (no dereference)..."
echo ""
cd output/host
# 显示总大小(人类可读格式)
total_size=$(du -sb . | cut -f1)
echo "Total size to package: $(numfmt --to=iec $total_size)"
echo ""
# 打包并通过 pv 显示进度
tar -cf - . | pv -s $total_size -t -r -b > ../../dictpen-p5-gcc9-toolchain-fast.tar
cd ../..
# 将环境脚本和配置文件追加到同一个 tar 包中
tar -rf dictpen-p5-gcc9-toolchain-fast.tar \
dictpen-gcc9-env.sh \
configs/dictpen_p5_gcc9_defconfig \
.config
echo ""
echo "✅ Toolchain packaged FAST: dictpen-p5-gcc9-toolchain-fast.tar"
echo ""
# 显示包信息
echo "=== Package Information ==="
ls -lh dictpen-p5-gcc9-toolchain-fast.tar
echo "📦 File count: $(tar -tf dictpen-p5-gcc9-toolchain-fast.tar | wc -l) files"
- name: Upload toolchain artifacts
uses: actions/upload-artifact@v4
with:
name: dictpen-p5-gcc9-toolchain-fast
path: |
~/buildroot-gcc9/buildroot-2021.02/dictpen-p5-gcc9-toolchain-fast.tar
~/buildroot-gcc9/buildroot-2021.02/*sdk*.tar.gz
~/buildroot-gcc9/buildroot-2021.02/dictpen-gcc9-env.sh
~/buildroot-gcc9/buildroot-2021.02/build.log
retention-days: 30
if-no-files-found: warn
- name: Upload build logs (if failed)
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs
path: |
~/buildroot-gcc9/buildroot-2021.02/output/build/**/*.log
~/buildroot-gcc9/buildroot-2021.02/config.log
~/buildroot-gcc9/buildroot-2021.02/build.log
retention-days: 7
- name: Display build summary
if: success()
run: |
cd ~/buildroot-gcc9/buildroot-2021.02
echo "## ✅ GCC 9.3 + glibc 2.29 Toolchain Build Complete!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Build Information" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
echo "- **Run ID**: ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Toolchain Details" >> $GITHUB_STEP_SUMMARY
echo "- **GCC Version**: 9.3.0" >> $GITHUB_STEP_SUMMARY
echo "- **glibc Version**: 2.29" >> $GITHUB_STEP_SUMMARY
echo "- **Kernel Headers**: 4.19" >> $GITHUB_STEP_SUMMARY
echo "- **Architecture**: ARM64 Cortex-A55" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Package Size" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
ls -lh *.tar >> $GITHUB_STEP_SUMMARY 2>/dev/null || ls -lh *.tar.gz >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Usage" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "# Extract toolchain" >> $GITHUB_STEP_SUMMARY
echo "tar -xf dictpen-p5-gcc9-toolchain-fast.tar" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Source environment" >> $GITHUB_STEP_SUMMARY
echo "source dictpen-gcc9-env.sh" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Compile test program" >> $GITHUB_STEP_SUMMARY
echo "\$CC -o hello hello.c" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY