-
Notifications
You must be signed in to change notification settings - Fork 19
152 lines (139 loc) · 5.49 KB
/
main.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
```yaml
name: main
on:
push:
branches:
- master
paths:
- .github/workflows/main.yml
workflow_dispatch:
env:
GMP_CONFIGURE_OPTIONS: --enable-shared --disable-static --enable-fat --enable-cxx
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: x64
host: x86_64-pc-linux-gnu
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
strip: strip
- os: linux
arch: x86
host: i686-pc-linux-gnu
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
strip: strip
- os: linux
arch: arm64
host: aarch64-linux-gnu
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
strip: aarch64-linux-gnu-strip
- os: linux
arch: arm
host: arm-linux-gnueabihf
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
strip: arm-linux-gnueabihf-strip
- os: win
arch: x64
host: x86_64-w64-mingw32
gmp_so: libgmp-10.dll
gmp_cpp_so: libgmpxx-4.dll
strip: x86_64-w64-mingw32-strip
env:
GMP_VERSION: 6.3
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install Toolchain (arch-specific)
run: |
sudo apt-get update
if [ "${{ matrix.arch }}" = "x86" ]; then
sudo apt-get install -y gcc-multilib g++-multilib
elif [ "${{ matrix.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
sudo apt-get install -y qemu-user
elif [ "${{ matrix.arch }}" = "arm" ]; then
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
sudo apt-get install -y qemu-user
elif [ "${{ matrix.os }}" = "win" ]; then
sudo apt-get install -y mingw-w64
sudo apt-get install -y wine
- name: Download GMP Source
run: |
git clone --depth 1 https://github.com/gmp-mirror/gmp-${GMP_VERSION}.git
- name: Autoreconf
run: |
cd gmp-${GMP_VERSION}
autoreconf -ivf
- name: Configure GMP
run: |
cd gmp-${GMP_VERSION}
./configure --host=${{ matrix.host }} ${{ env.GMP_CONFIGURE_OPTIONS }}
- name: Build GMP
run: |
cd gmp-${GMP_VERSION}
make MAKEINFO=true
- name: Check .libs
run: |
cd gmp-${GMP_VERSION}/.libs
ls -l
file ${{ matrix.gmp_so }}
- name: Strip GMP Library
run: |
cd gmp-${GMP_VERSION}/.libs
${{ matrix.strip }} --strip-unneeded ${{ matrix.gmp_so }}
${{ matrix.strip }} --strip-unneeded ${{ matrix.gmp_cpp_so }}
- name: Compile C Program
run: |
if [ "${{ matrix.arch }}" = "x86" ]; then
gcc -m32 -o factorial_gmp .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
elif [ "${{ matrix.arch }}" = "arm64" ]; then
aarch64-linux-gnu-gcc -o factorial_gmp .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
elif [ "${{ matrix.arch }}" = "arm" ]; then
arm-linux-gnueabihf-gcc -o factorial_gmp .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
elif [ "${{ matrix.os }}" = "win" ]; then
x86_64-w64-mingw32-gcc -o factorial_gmp.exe .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
else
gcc -o factorial_gmp .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
- name: Run C Program
run: |
if [ "${{ matrix.arch }}" = "arm64" ]; then
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs qemu-aarch64 -L /usr/aarch64-linux-gnu/ ${GITHUB_WORKSPACE}/factorial_gmp
elif [ "${{ matrix.arch }}" = "arm" ]; then
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs qemu-arm -L /usr/arm-linux-gnueabihf/ ${GITHUB_WORKSPACE}/factorial_gmp
elif [ "${{ matrix.os }}" = "win" ]; then
cp ${{ github.workspace }}/gmp-${GMP_VERSION}/.libs/${{ matrix.gmp_so }} .
wine ${GITHUB_WORKSPACE}/factorial_gmp.exe
else
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs ./factorial_gmp
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}
path: |
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/gmp.h
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/gmpxx.h
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/.libs/${{ matrix.gmp_so }}
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/.libs/${{ matrix.gmp_cpp_so }}
```