Skip to content

copy gmp to current folder #56

copy gmp to current folder

copy gmp to current folder #56

Workflow file for this run

name: main
on:
push:
branches:
- master
paths:
- .github/workflows/main.yml
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: x64
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
- os: linux
arch: x86
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
- os: linux
arch: arm64
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
- os: linux
arch: arm
gmp_so: libgmp.so.10.5.0
gmp_cpp_so: libgmpxx.so.4.7.0
- os: win
arch: x64
gmp_so: libgmp-10.dll
gmp_cpp_so: libgmpxx-4.dll
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
fi
- 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}
if [ "${{ matrix.arch }}" = "x86" ]; then
./configure \
CC="clang -m32" CXX="clang++ -m32" \
--host=i686-pc-linux-gnu \
--enable-shared --disable-static --enable-fat --enable-cxx
elif [ "${{ matrix.arch }}" = "arm64" ]; then
./configure \
CC="clang --target=aarch64-linux-gnu" CXX="clang++ --target=aarch64-linux-gnu" \
--host=aarch64-linux-gnu \
--enable-shared --disable-static --enable-fat --enable-cxx
elif [ "${{ matrix.arch }}" = "arm" ]; then
./configure \
CC="clang --target=arm-linux-gnueabihf" CXX="clang++ --target=arm-linux-gnueabihf" \
--host=arm-linux-gnueabihf \
--enable-shared --disable-static --enable-fat --enable-cxx
elif [ "${{ matrix.os }}" = "win" ]; then
./configure \
CC="clang --target=x86_64-w64-mingw32" CXX="clang++ --target=x86_64-w64-mingw32" \
--host=x86_64-w64-mingw32 \
--enable-shared --disable-static --enable-fat --enable-cxx
else
./configure \
CC=clang CXX=clang++ \
--enable-shared --disable-static --enable-fat --enable-cxx
fi
- 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
if [ "${{ matrix.arch }}" = "arm64" ]; then
aarch64-linux-gnu-strip --strip-unneeded ${{ matrix.gmp_so }}
aarch64-linux-gnu-strip --strip-unneeded ${{ matrix.gmp_cpp_so }}
elif [ "${{ matrix.arch }}" = "arm" ]; then
arm-linux-gnueabihf-strip --strip-unneeded ${{ matrix.gmp_so }}
arm-linux-gnueabihf-strip --strip-unneeded ${{ matrix.gmp_cpp_so }}
elif [ "${{ matrix.os }}" = "win" ]; then
x86_64-w64-mingw32-strip --strip-unneeded ${{ matrix.gmp_so }}
x86_64-w64-mingw32-strip --strip-unneeded ${{ matrix.gmp_cpp_so }}
else
strip --strip-unneeded ${{ matrix.gmp_so }}
strip --strip-unneeded ${{ matrix.gmp_cpp_so }}
fi
- name: Compile C Program
run: |
if [ "${{ matrix.arch }}" = "x86" ]; then
clang -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
clang --target=aarch64-linux-gnu -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
clang --target=arm-linux-gnueabihf -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
clang --target=x86_64-w64-mingw32 -o factorial_gmp.exe .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
else
clang -o factorial_gmp .github/workflows/factorial_gmp.c \
-I${{ github.workspace }}/gmp-${GMP_VERSION} \
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \
-lgmp
fi
- 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
fi
- 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 }}