Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
349 changes: 349 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
name: Component Build

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOCKER_IMAGE: imx-forge:ci

jobs:
# 路径检测
detect:
name: Detect Changes
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
uboot: ${{ steps.changes.outputs.uboot }}
linux-imx: ${{ steps.changes.outputs.linux-imx }}
linux-mainline: ${{ steps.changes.outputs.linux-mainline }}
busybox: ${{ steps.changes.outputs.busybox }}
driver: ${{ steps.changes.outputs.driver }}
scripts: ${{ steps.changes.outputs.scripts }}
steps:
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: changes
with:
base: main
filters: |
uboot:
- 'patches/uboot/**'
- 'patches/uboot-imx/**'
- 'scripts/build_helper/build-uboot.sh'
- 'scripts/release_builder/build_release_uboot.sh'
linux-imx:
- 'patches/linux-imx/**'
- 'scripts/build_helper/build-linux.sh'
linux-mainline:
- 'patches/linux_mainline/**'
- 'scripts/build_helper/build-mainline-linux.sh'
busybox:
- 'patches/busybox/**'
- 'scripts/build_helper/build-busybox.sh'
- 'scripts/release_builder/build_release_busybox.sh'
driver:
- 'driver/**'
scripts:
- 'scripts/**'
- '.github/workflows/**'

# U-Boot 构建
uboot:
name: U-Boot
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.uboot == 'true' || needs.detect.outputs.scripts == 'true'
timeout-minutes: 12
steps:
- uses: actions/checkout@v4
with:
submodules: false

- name: 初始化 U-Boot 子模块
run: git submodule update --init --depth=1 third_party/uboot-imx

- name: 构建 Docker 镜像
run: cd docker && docker build -t ${{ env.DOCKER_IMAGE }} .

- name: 应用 U-Boot 补丁
run: |
if [ -f "patches/uboot-imx/charlies_board.patch" ]; then
cd third_party/uboot-imx
git apply --3way ../../patches/uboot-imx/charlies_board.patch || true
cd ../..
fi

- name: Cache ccache for U-Boot
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-ccache-uboot-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-ccache-uboot-

- name: 构建 U-Boot
run: |
docker run --rm \
--user root \
-v $PWD:/workspace \
-w /workspace \
-e CCACHE_DIR=/workspace/.ccache \
-e CCACHE_BASEDIR=/workspace \
-e CCACHE_NOHASHDIR=true \
-e CCACHE_COMPILERCHECK=content \
${{ env.DOCKER_IMAGE }} \
bash -c '
ccache -M 2G && ccache -z
mkdir -p /workspace/ccache-bin
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-gcc
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-g++
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-ar
export PATH="/workspace/ccache-bin:${PATH}"
./scripts/build_helper/build-uboot.sh
ccache -s
'

- name: 上传产物
uses: actions/upload-artifact@v4
with:
name: uboot
path: out/uboot/u-boot-dtb.imx
retention-days: 7

# Linux NXP BSP 构建
linux-imx:
name: Linux (NXP BSP)
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.linux-imx == 'true' || needs.detect.outputs.scripts == 'true'
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
with:
submodules: false

- name: 初始化 linux-imx 子模块
run: git submodule update --init --depth=1 third_party/linux-imx

- name: 构建 Docker 镜像
run: cd docker && docker build -t ${{ env.DOCKER_IMAGE }} .

- name: 应用 Linux NXP BSP 补丁
run: |
if [ -f "patches/linux-imx/linux-imx-latest.patch" ]; then
cd third_party/linux-imx
git apply --3way ../../patches/linux-imx/linux-imx-latest.patch || true
cd ../..
fi

- name: Cache ccache for Linux NXP BSP
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-ccache-linux-imx-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-ccache-linux-imx-

- name: 构建 Linux NXP BSP
run: |
docker run --rm \
--user root \
-v $PWD:/workspace \
-w /workspace \
-e CCACHE_DIR=/workspace/.ccache \
-e CCACHE_BASEDIR=/workspace \
-e CCACHE_NOHASHDIR=true \
-e CCACHE_COMPILERCHECK=content \
${{ env.DOCKER_IMAGE }} \
bash -c '
ccache -M 2G && ccache -z
mkdir -p /workspace/ccache-bin
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-gcc
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-g++
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-ar
export PATH="/workspace/ccache-bin:${PATH}"
./scripts/build_helper/build-linux.sh
ccache -s
'

- name: 验证产物
run: |
[ -f out/linux/arch/arm/boot/zImage ] || exit 1
file out/linux/arch/arm/boot/zImage | grep -q ARM

- name: 上传产物
uses: actions/upload-artifact@v4
with:
name: linux-imx
path: |
out/linux/arch/arm/boot/zImage
out/linux/arch/arm/boot/dts/nxp/imx/imx6ull-aes.dtb
retention-days: 7

# Linux Mainline 构建(与 NXP 并行)
linux-mainline:
name: Linux (Mainline)
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.linux-mainline == 'true' || needs.detect.outputs.scripts == 'true'
timeout-minutes: 22
steps:
- uses: actions/checkout@v4
with:
submodules: false

- name: 初始化 linux-mainline 子模块
run: git submodule update --init --depth=1 third_party/linux_mainline

- name: 构建 Docker 镜像
run: cd docker && docker build -t ${{ env.DOCKER_IMAGE }} .

- name: 应用 Linux Mainline 补丁
run: |
if [ -f "patches/linux_mainline/linux_mainline-feat-imx6ull_patches-20260322.patch" ]; then
cd third_party/linux_mainline
git apply --3way ../../patches/linux_mainline/linux_mainline-feat-imx6ull_patches-20260322.patch || true
cd ../..
fi

- name: Cache ccache for Linux Mainline
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-ccache-linux-mainline-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-ccache-linux-mainline-

- name: 构建 Linux Mainline
run: |
docker run --rm \
--user root \
-v $PWD:/workspace \
-w /workspace \
-e CCACHE_DIR=/workspace/.ccache \
-e CCACHE_BASEDIR=/workspace \
-e CCACHE_NOHASHDIR=true \
-e CCACHE_COMPILERCHECK=content \
${{ env.DOCKER_IMAGE }} \
bash -c '
ccache -M 2G && ccache -z
mkdir -p /workspace/ccache-bin
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-gcc
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-g++
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-ar
export PATH="/workspace/ccache-bin:${PATH}"
./scripts/build_helper/build-mainline-linux.sh
ccache -s
'

- name: 验证产物
run: |
[ -f out/mainline/linux/arch/arm/boot/zImage ] || exit 1
file out/mainline/linux/arch/arm/boot/zImage | grep -q ARM

- name: 上传产物
uses: actions/upload-artifact@v4
with:
name: linux-mainline
path: out/mainline/linux/arch/arm/boot/zImage
retention-days: 7

# BusyBox 构建
busybox:
name: BusyBox
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.busybox == 'true' || needs.detect.outputs.scripts == 'true'
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
submodules: false

- name: 初始化 busybox 子模块
run: git submodule update --init --depth=1 third_party/busybox

- name: 构建 Docker 镜像
run: cd docker && docker build -t ${{ env.DOCKER_IMAGE }} .

- name: Cache ccache for BusyBox
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-ccache-busybox-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-ccache-busybox-

- name: 构建 BusyBox
run: |
docker run --rm \
--user root \
-v $PWD:/workspace \
-w /workspace \
-e CCACHE_DIR=/workspace/.ccache \
-e CCACHE_BASEDIR=/workspace \
-e CCACHE_NOHASHDIR=true \
-e CCACHE_COMPILERCHECK=content \
${{ env.DOCKER_IMAGE }} \
bash -c '
ccache -M 2G && ccache -z
mkdir -p /workspace/ccache-bin
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-gcc
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-g++
ln -sf /usr/bin/ccache /workspace/ccache-bin/arm-none-linux-gnueabihf-ar
export PATH="/workspace/ccache-bin:${PATH}"
./scripts/build_helper/build-busybox.sh
ccache -s
'

- name: 验证产物
run: |
[ -f out/busybox/busybox ] || exit 1
file out/busybox/busybox | grep -q "ARM"

- name: 上传产物
uses: actions/upload-artifact@v4
with:
name: busybox
path: out/busybox/busybox
retention-days: 7

# 驱动构建
drivers:
name: Drivers
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.driver == 'true'
timeout-minutes: 8
steps:
- uses: actions/checkout@v4
with:
submodules: false

- name: 初始化 linux-mainline 子模块
run: git submodule update --init --depth=1 third_party/linux_mainline

- name: 构建 Docker 镜像
run: cd docker && docker build -t ${{ env.DOCKER_IMAGE }} .

- name: 构建所有驱动
run: |
docker run --rm \
--user root \
-v $PWD:/workspace \
-w /workspace \
${{ env.DOCKER_IMAGE }} \
bash -c "./scripts/driver_helper/build_driver.sh --all || true"

- name: 验证驱动产物
run: |
find driver -name "*.ko" -exec file {} \; 2>/dev/null | head -5 || echo "No kernel modules found, continuing..."
Loading
Loading