Skip to content

Commit 50bf7e9

Browse files
authored
Add Github Action CI + Windows compile fix (#534)
* Just add CI * Try and fix Win64 build * Try to fix mac build * Try to fix windows, second try * Mac fix, second try * Try fix Win32 second try * Update deps, fix windows num 2 * Use GCC9 on Mac * Cleanup
1 parent d51f593 commit 50bf7e9

File tree

2 files changed

+228
-0
lines changed

2 files changed

+228
-0
lines changed

.github/workflows/build.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: Build Binaries
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build-win64:
6+
runs-on: windows-latest
7+
defaults:
8+
run:
9+
shell: msys2 {0}
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: msys2/setup-msys2@v2
13+
with:
14+
msystem: MINGW64
15+
update: true
16+
install: git make mingw-w64-x86_64-toolchain mingw-w64-x86_64-libelf mingw-w64-x86_64-avr-toolchain mingw-w64-x86_64-freeglut
17+
- name: CI-Build
18+
run: |
19+
echo 'Running in MSYS2!'
20+
make build-simavr V=1
21+
mkdir simavr_installed
22+
make -k install DESTDIR=$(pwd)/simavr_installed/ || true
23+
mv simavr_installed/bin/simavr simavr_installed/bin/simavr.exe
24+
file simavr_installed/bin/*
25+
- uses: actions/upload-artifact@v4
26+
with:
27+
name: Windows 64-bit
28+
path: simavr_installed
29+
build-win32:
30+
runs-on: windows-latest
31+
defaults:
32+
run:
33+
shell: msys2 {0}
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: msys2/setup-msys2@v2
37+
with:
38+
msystem: MINGW32
39+
update: true
40+
install: git make mingw-w64-i686-toolchain mingw-w64-i686-libelf mingw-w64-i686-freeglut unzip
41+
- name: Install AVR toolchain
42+
run: |
43+
wget "https://github.com/ZakKemble/avr-gcc-build/releases/download/v14.1.0-1/avr-gcc-14.1.0-x86-windows.zip"
44+
unzip avr-gcc-14.1.0-x86-windows.zip
45+
ls -l
46+
rm avr-gcc-14.1.0-x86-windows.zip
47+
echo "$(pwd)/avr-gcc-14.1.0-x86-windows/avr-gcc-14.1.0-x86-windows/bin" >> $GITHUB_PATH
48+
- name: CI-Build
49+
run: |
50+
make build-simavr V=1
51+
mkdir simavr_installed
52+
make -k install DESTDIR=$(pwd)/simavr_installed/ || true
53+
mv simavr_installed/bin/simavr simavr_installed/bin/simavr.exe
54+
file simavr_installed/bin/*
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: Windows 32-bit
58+
path: simavr_installed
59+
build-lin64:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Install Dependenncies
64+
run: sudo apt-get install -y build-essential git make gcc-avr avr-libc libelf-dev freeglut3-dev patchelf
65+
- name: CI-Build
66+
run: |
67+
make build-simavr V=1 RELEASE=1
68+
mkdir simavr_installed
69+
make install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/
70+
file simavr_installed/bin/*
71+
patchelf --remove-needed ./libsimavr.so.1 simavr_installed/bin/simavr || true
72+
patchelf --add-needed libsimavr.so.1 simavr_installed/bin/simavr
73+
patchelf --set-rpath '$ORIGIN/../lib/' simavr_installed/bin/simavr
74+
ldd simavr_installed/bin/*
75+
simavr_installed/bin/simavr --list-cores || true
76+
- name: Tar files
77+
run: tar -cvf simavr.tar.gz -C simavr_installed .
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: Linux 64-bit
81+
path: simavr.tar.gz
82+
build-lin32:
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- name: Install Dependenncies
87+
run: |
88+
sudo dpkg --add-architecture i386
89+
sudo apt-get update
90+
sudo apt-get install -y libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386 gcc-9:i386 binutils:i386 cpp-9:i386 libelf-dev:i386 freeglut3-dev:i386 gcc-avr avr-libc patchelf
91+
ls -l /usr/bin/*gcc*
92+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10
93+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 20
94+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
95+
sudo update-alternatives --set cc /usr/bin/gcc
96+
- name: CI-Build
97+
run: |
98+
make build-simavr V=1 RELEASE=1
99+
mkdir simavr_installed
100+
make install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/
101+
file simavr_installed/bin
102+
patchelf --remove-needed ./libsimavr.so.1 simavr_installed/bin/simavr || true
103+
patchelf --add-needed libsimavr.so.1 simavr_installed/bin/simavr
104+
patchelf --set-rpath '$ORIGIN/../lib/' simavr_installed/bin/simavr
105+
ldd simavr_installed/bin/*
106+
simavr_installed/bin/simavr --list-cores || true
107+
- name: Tar files
108+
run: tar -cvf simavr.tar.gz -C simavr_installed .
109+
- uses: actions/upload-artifact@v4
110+
with:
111+
name: Linux 32-bit
112+
path: simavr.tar.gz
113+
build-armv7l:
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v4
117+
- uses: pguyot/arm-runner-action@v2
118+
id: build_image
119+
with:
120+
cpu: cortex-a7
121+
base_image: raspios_lite:latest
122+
copy_artifact_path: simavr.tar.gz
123+
image_additional_mb: 1024
124+
commands: |
125+
df -h /
126+
sudo apt-get install -y build-essential git make gcc-avr avr-libc libelf-dev freeglut3-dev patchelf file
127+
make -j4 build-simavr V=1 RELEASE=1
128+
mkdir simavr_installed
129+
make -j4 install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/
130+
file simavr_installed/bin/*
131+
patchelf --remove-needed ./libsimavr.so.1 simavr_installed/bin/simavr || true
132+
patchelf --add-needed libsimavr.so.1 simavr_installed/bin/simavr
133+
patchelf --set-rpath '$ORIGIN/../lib/' simavr_installed/bin/simavr
134+
ldd simavr_installed/bin/*
135+
simavr_installed/bin/simavr --list-cores || true
136+
tar -cvf simavr.tar.gz -C simavr_installed .
137+
- uses: actions/upload-artifact@v4
138+
with:
139+
name: Linux ARMv7l
140+
path: simavr.tar.gz
141+
build-armv6l:
142+
runs-on: ubuntu-latest
143+
steps:
144+
- uses: actions/checkout@v4
145+
- uses: pguyot/arm-runner-action@v2
146+
id: build_image
147+
with:
148+
cpu: arm1176
149+
base_image: raspios_lite:latest
150+
copy_artifact_path: simavr.tar.gz
151+
image_additional_mb: 1024
152+
commands: |
153+
df -h /
154+
sudo apt-get install -y build-essential git make gcc-avr avr-libc libelf-dev freeglut3-dev patchelf file
155+
make build-simavr V=1 RELEASE=1
156+
mkdir simavr_installed
157+
make install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/
158+
file simavr_installed/bin/*
159+
patchelf --remove-needed ./libsimavr.so.1 simavr_installed/bin/simavr || true
160+
patchelf --add-needed libsimavr.so.1 simavr_installed/bin/simavr
161+
patchelf --set-rpath '$ORIGIN/../lib/' simavr_installed/bin/simavr
162+
ldd simavr_installed/bin/*
163+
simavr_installed/bin/simavr --list-cores || true
164+
tar -cvf simavr.tar.gz -C simavr_installed .
165+
- uses: actions/upload-artifact@v4
166+
with:
167+
name: Linux ARMv6l
168+
path: simavr.tar.gz
169+
build-aarch64:
170+
runs-on: ubuntu-latest
171+
steps:
172+
- uses: actions/checkout@v4
173+
- uses: pguyot/arm-runner-action@v2
174+
id: build_image
175+
with:
176+
cpu: cortex-a53
177+
base_image: raspios_lite_arm64:latest
178+
copy_artifact_path: simavr.tar.gz
179+
image_additional_mb: 1024
180+
commands: |
181+
df -h /
182+
sudo apt-get install -y build-essential git make gcc-avr avr-libc libelf-dev freeglut3-dev patchelf file
183+
make -j4 build-simavr V=1 RELEASE=1
184+
mkdir simavr_installed
185+
make -j4 install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/
186+
file simavr_installed/bin/*
187+
patchelf --remove-needed ./libsimavr.so.1 simavr_installed/bin/simavr || true
188+
patchelf --add-needed libsimavr.so.1 simavr_installed/bin/simavr
189+
patchelf --set-rpath '$ORIGIN/../lib/' simavr_installed/bin/simavr
190+
ldd simavr_installed/bin/*
191+
simavr_installed/bin/simavr --list-cores || true
192+
tar -cvf simavr.tar.gz -C simavr_installed .
193+
- uses: actions/upload-artifact@v4
194+
with:
195+
name: Linux AArch64
196+
path: simavr.tar.gz
197+
build-darwin-x64:
198+
# this is currently macos-11, Big Sur
199+
runs-on: macos-latest
200+
steps:
201+
- uses: actions/checkout@v4
202+
- name: Install Dependenncies
203+
run: |
204+
HOMEBREW_NO_INSTALL_FROM_API=1 brew install make libelf freeglut patchelf
205+
HOMEBREW_NO_INSTALL_FROM_API=1 brew tap osx-cross/avr
206+
HOMEBREW_NO_INSTALL_FROM_API=1 brew install avr-gcc@9 avr-binutils
207+
export PATH="/usr/local/opt/avr-gcc@9/bin:$PATH"
208+
- name: CI-Build
209+
run: |
210+
avr-gcc --version || true
211+
clang --version
212+
export CFLAGS="-DGL_SILENCE_DEPRECATION"
213+
make -j4 build-simavr V=1 RELEASE=1
214+
mkdir simavr_installed
215+
make -k -j4 install RELEASE=1 DESTDIR=$(pwd)/simavr_installed/ || true
216+
file simavr_installed/bin/*
217+
otool -L simavr_installed/bin/*
218+
simavr_installed/bin/simavr --list-cores || true
219+
- name: Tar files
220+
run: tar -cvf simavr.tar.gz -C simavr_installed .
221+
- uses: actions/upload-artifact@v4
222+
with:
223+
name: Mac OS Intel 64-bit
224+
path: simavr.tar.gz

simavr/sim/sim_avr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ avr_init(
109109
#endif
110110
avr->data_names = calloc(avr->ioend + 1, sizeof (char *));
111111
/* put "something" in the serial number */
112+
#ifdef _WIN32
113+
uint32_t r = getpid() + (uint32_t) rand();
114+
#else
112115
uint32_t r = getpid() + random();
116+
#endif
113117
for (int i = 0; i < ARRAY_SIZE(avr->serial); i++)
114118
avr->serial[i] = r >> (i * 3);
115119
AVR_LOG(avr, LOG_TRACE, "%s init\n", avr->mmcu);

0 commit comments

Comments
 (0)