Initial commit #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test C++ on RISC-V | |
on: | |
push: | |
branches: | |
- "*" | |
pull_request: | |
branches: | |
- "*" | |
workflow_dispatch: # 手动触发 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# 安装依赖 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake g++ wget | |
# 安装 RISC-V 工具链 | |
- name: Install RISC-V toolchain | |
run: | | |
sudo apt-get install -y gcc-riscv64-linux-gnu qemu-user g++-riscv64-linux-gnu libc6-dev-riscv64-cross | |
# 创建构建目录 | |
- name: Create build directory | |
run: | | |
mkdir build | |
cd build | |
cmake -DTOOLCHAIN_PREFIX=riscv64-linux-gnu- -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ -DARCH=riscv64 .. | |
working-directory: ${{ github.workspace }} | |
# 构建 C++ 项目 | |
- name: Build project | |
run: | | |
cd build | |
make | |
working-directory: ${{ github.workspace }} | |
# 运行程序(假设已经有模拟器或者环境来执行 RISC-V 程序) | |
- name: Test RISC-V program | |
run: | | |
# 使用 QEMU 模拟器来运行 RISC-V 程序 | |
qemu-riscv64 -L /usr/riscv64-linux-gnu ./build/riscv_test | |
working-directory: ${{ github.workspace }} |