-
Notifications
You must be signed in to change notification settings - Fork 107
153 lines (149 loc) · 5.71 KB
/
build-artifact.yml
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
name: Build artifact
on:
push:
branches:
- master
workflow_dispatch:
jobs:
detect-file-change:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Test file change
id: test-file-change
uses: tj-actions/changed-files@v45
with:
fetch_additional_submodule_history: 'true'
files: |
mk/artifact.mk
tests/ansibench/**
tests/rv8-bench/**
tests/doom/**
tests/quake/**
tests/scimark2/**
tests/*.c
- name: Test file change of Linux image
id: test-linux-image-version-change
uses: tj-actions/changed-files@v45
with:
files: |
mk/external.mk
- name: Set alias
id: has_changed_files
run: |
if [[ ${{ steps.test-file-change.outputs.any_modified }} == true ]]; then
echo "has_changed_files=true" >> $GITHUB_OUTPUT
else
echo "has_changed_files=false" >> $GITHUB_OUTPUT
fi
if [[ ${{ steps.test-linux-image-version-change.outputs.any_modified }} == true ]]; then
# Determine if the changes are from Buildroot or the Linux version (The Linux might have several patches, so also need to check the SHA value)
echo -n $(git --no-pager diff HEAD^ HEAD | grep -e "+BUILDROOT_VERSION" -e "+LINUX_VERSION" -e "+LINUX_DATA_SHA1") >> linux-image-version-change
if [[ -s linux-image-version-change ]]; then
echo "has_changed_linux_image_version=true" >> $GITHUB_OUTPUT
else
echo "has_changed_linux_image_version=false" >> $GITHUB_OUTPUT
fi
else
echo "has_changed_linux_image_version=false" >> $GITHUB_OUTPUT
fi
outputs:
has_changed_files: ${{ steps.has_changed_files.outputs.has_changed_files }}
has_changed_linux_image_version: ${{ steps.has_changed_files.outputs.has_changed_linux_image_version }}
build-linux-image-artifact:
needs: [detect-file-change]
if: ${{ needs.detect-file-change.outputs.has_changed_linux_image_version == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install dependencies
run: |
sudo apt-get update -q -y
sudo apt-get upgrade -q -y
sudo apt-get install -q -y build-essential git
- name: Build Linux image
run: |
make build-linux-image
make artifact ENABLE_PREBUILT=0 ENABLE_SYSTEM=1
mkdir -p /tmp/rv32emu-linux-image-prebuilt/linux-image
mv build/linux-image/Image /tmp/rv32emu-linux-image-prebuilt/linux-image
mv build/linux-image/rootfs.cpio /tmp/rv32emu-linux-image-prebuilt/linux-image
mv build/sha1sum-linux-image /tmp
- name: Create tarball
run: |
cd /tmp
tar -zcvf rv32emu-linux-image-prebuilt.tar.gz rv32emu-linux-image-prebuilt
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
run: |
RELEASE_TAG=$(date +'%Y.%m.%d'-Linux-Image)
cd /tmp
gh release create $RELEASE_TAG \
--repo sysprog21/rv32emu-prebuilt \
--title "$RELEASE_TAG""-nightly"
gh release upload $RELEASE_TAG \
rv32emu-linux-image-prebuilt.tar.gz \
sha1sum-linux-image \
--repo sysprog21/rv32emu-prebuilt
build-artifact:
needs: [detect-file-change]
if: ${{ needs.detect-file-change.outputs.has_changed_files == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install dependencies
run: |
sudo apt-get update -q -y
sudo apt-get upgrade -q -y
sudo apt-get install -q -y gcc-multilib g++-multilib
sudo apt-get install -q -y opam build-essential libgmp-dev z3 pkg-config zlib1g-dev
.ci/riscv-toolchain-install.sh
echo "$PWD/toolchain/bin" >> $GITHUB_PATH
- name: Build binaries
run: |
make artifact ENABLE_PREBUILT=0
mkdir -p /tmp/rv32emu-prebuilt
mv build/sha1sum-linux-x86-softfp /tmp
mv build/sha1sum-riscv32 /tmp
mv build/linux-x86-softfp build/riscv32 /tmp/rv32emu-prebuilt
- name: Build Sail model
run: |
cd /tmp
opam init -y --disable-sandboxing
opam switch create ocaml-base-compiler.4.06.1
opam install sail -y
eval $(opam config env)
git clone https://github.com/riscv/sail-riscv.git
cd sail-riscv
git checkout 9547a30bf84572c458476591b569a95f5232c1c7
ARCH=RV32 make -j
mkdir -p /tmp/rv32emu-prebuilt/sail_cSim
mv c_emulator/riscv_sim_RV32 /tmp/rv32emu-prebuilt/sail_cSim
- name: Create tarball
run: |
cd /tmp
tar -zcvf rv32emu-prebuilt.tar.gz rv32emu-prebuilt
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
run: |
RELEASE_TAG=$(date +'%Y.%m.%d'-ELF)
cd /tmp
gh release create $RELEASE_TAG \
--repo sysprog21/rv32emu-prebuilt \
--title "$RELEASE_TAG""-nightly"
gh release upload $RELEASE_TAG \
rv32emu-prebuilt.tar.gz \
sha1sum-linux-x86-softfp \
sha1sum-riscv32 \
--repo sysprog21/rv32emu-prebuilt