1+ #
2+ # Copyright (c) 2025, RT-Thread Development Team
3+ #
4+ # SPDX-License-Identifier: Apache-2.0
5+ #
6+ # Change Logs:
7+ # Date Author Notes
8+ # 2025-03-22 Supperthomas 添加upload 上传编译固件
9+ # 2025-04-03 Hydevcode 自动生成attach的产物
10+ #
11+ # 1.读取重点看护表
12+ # 2.生成矩阵
13+ # 3.编译对应bsp
14+ # 4.调用对应的attach的python编译
15+ # 5.生成产物
16+ name : Auto Version Attach Generate
17+
18+ on :
19+ workflow_dispatch :
20+
21+ jobs :
22+ generate-matrix :
23+ runs-on : ubuntu-22.04
24+ outputs :
25+ matrix : ${{ steps.read-config.outputs.matrix }}
26+ steps :
27+ - name : Checkout repo
28+ uses : actions/checkout@v4
29+ with :
30+ ref : master
31+ sparse-checkout : .github/PART_BSP_COMPILE.json
32+ persist-credentials : false
33+ - name : Read matrix config
34+ id : read-config
35+ run : |
36+ raw_matrix=$(cat .github/PART_BSP_COMPILE.json |egrep -v '^//')
37+ FILTER_CONDITION='.legs[]'
38+ matrix=$(jq -c "{legs: [$FILTER_CONDITION]}" <<< "$raw_matrix")
39+ echo "matrix=$matrix" >> $GITHUB_OUTPUT
40+ build :
41+ runs-on : ubuntu-22.04
42+ needs : generate-matrix
43+ name : ${{ matrix.legs.RTT_BSP }}
44+ strategy :
45+ fail-fast : false
46+ matrix : ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
47+ steps :
48+ - uses : actions/checkout@v4
49+ - name : Set up Python
50+ uses : actions/setup-python@main
51+ with :
52+ python-version : 3.8
53+
54+ - name : Install Tools
55+ shell : bash
56+ run : |
57+ wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh
58+ chmod 777 install_ubuntu.sh
59+ ./install_ubuntu.sh
60+ pip install -r tools/requirements.txt
61+ git config --global http.postBuffer 524288000
62+ echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV
63+ echo "RTT_CC=gcc" >> $GITHUB_ENV
64+ echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh
65+
66+ - name : Cache GCC Arm Toolchain
67+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
68+ id : cache-gcc-arm
69+ uses : actions/cache@main
70+ with :
71+ path : /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
72+ key : ${{ runner.os }}-arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
73+
74+ - name : Download Arm ToolChains
75+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && (steps.cache-gcc-arm.outputs.cache-hit != 'true') }}
76+ shell : bash
77+ run : |
78+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.8/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz
79+ sudo tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt
80+
81+ - name : Install Arm ToolChains2
82+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
83+ shell : bash
84+ run : |
85+ /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc --version
86+ echo "RTT_EXEC_PATH=/opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin" >> $GITHUB_ENV
87+
88+ - name : Install LLVM-Arm ToolChains
89+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'llvm-arm' && success() }}
90+ shell : bash
91+ run : |
92+ wget -q https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-16.0.0/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz
93+ sudo tar zxf LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz -C /opt
94+ sudo apt-get -qq install libncurses5 libncurses5-dev libncursesw5-dev
95+ /opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin/clang --version
96+ echo "RTT_CC=llvm-arm" >> $GITHUB_ENV
97+ echo "RTT_EXEC_PATH=/opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin" >> $GITHUB_ENV
98+
99+ - name : Install AArch64 ToolChains
100+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-aarch64' && success() }}
101+ shell : bash
102+ run : |
103+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
104+ sudo tar -xf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
105+ /opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
106+ echo "RTT_EXEC_PATH=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin" >> $GITHUB_ENV
107+
108+ - name : Install Mips ToolChains
109+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-mips' && success() }}
110+ shell : bash
111+ run : |
112+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.1/mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2
113+ sudo tar xjf mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2 -C /opt
114+ /opt/mips-2016.05/bin/mips-sde-elf-gcc --version
115+ echo "RTT_EXEC_PATH=/opt/mips-2016.05/bin" >> $GITHUB_ENV
116+
117+ - name : Install Riscv64-unknown-elf ToolChains
118+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv64-unknown-elf' && success() }}
119+ run : |
120+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
121+ sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
122+ /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
123+ echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
124+
125+ - name : Install riscv32-unknown-elf Toolchains
126+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'RISC-V-GCC-RV32' && success() }}
127+ run : |
128+ wget -q https://github.com/hpmicro/riscv-gnu-toolchain/releases/download/2022.05.15/riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz
129+ sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
130+ /opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
131+ echo "RTT_EXEC_PATH=/opt/riscv32-unknown-elf-newlib-multilib/bin/" >> $GITHUB_ENV
132+
133+ - name : Install Riscv-none-embed ToolChains
134+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv-none-embed' && success() }}
135+ run : |
136+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.5/xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz
137+ sudo tar zxf xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz -C /opt
138+ /opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin/riscv-none-embed-gcc --version
139+ echo "RTT_EXEC_PATH=/opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin" >> $GITHUB_ENV
140+
141+ - name : Install riscv32-esp-elf ToolChains
142+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv32-esp32' && success() }}
143+ run : |
144+ wget -q https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
145+ sudo tar xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz -C /opt
146+ /opt/riscv32-esp-elf/bin/riscv32-esp-elf-gcc --version
147+ pip3 install esptool
148+ echo "RTT_EXEC_PATH=/opt/riscv32-esp-elf/bin" >> $GITHUB_ENV
149+
150+ - name : Install Simulator Tools
151+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'gcc' && success() }}
152+ run : |
153+ sudo apt-get -qq install libsdl2-dev
154+
155+ - name : Install i386-unknown-elf Tools
156+ if : ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-i386-unknown-elf' && success() }}
157+ run : |
158+ wget -q https://github.com/zhkag/toolchains/releases/download/i386-unknown/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2
159+ sudo tar -jxvf i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
160+ /opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin/i386-unknown-elf-gcc --version
161+ echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
162+ - name : Bsp Scons Compile
163+ if : ${{ success() }}
164+ shell : bash
165+ env :
166+ RTT_BSP : ${{ matrix.legs.RTT_BSP }}
167+ RTT_TOOL_CHAIN : ${{ matrix.legs.RTT_TOOL_CHAIN }}
168+ SRTT_BSP : ${{ join(matrix.legs.SUB_RTT_BSP, ',') }}
169+ run : |
170+ source ~/.env/env.sh
171+ python tools/ci/bsp_buildings.py
172+ - name : Upload output as artifact
173+ if : ${{ success() }}
174+ uses : actions/upload-artifact@main
175+ with :
176+ name : ${{ matrix.legs.RTT_BSP }}
177+ if-no-files-found : ignore
178+ path : version_output/
179+ # 整合所有的output为一个文件夹
180+ collect-artifacts :
181+ needs : build
182+ runs-on : ubuntu-latest
183+ steps :
184+ # 这里会下载所有产物
185+ - name : Download all artifacts
186+ uses : actions/download-artifact@main
187+ with :
188+ path : version_output/
189+ merge-multiple : true
190+ - run : ls -R version_output/
191+
192+ - name : Upload combined output as artifact
193+ uses : actions/upload-artifact@main
194+ with :
195+ name : 00_all_bsp_output_${{ github.sha }}
196+ path : version_output/
0 commit comments