Skip to content

Codecleanup type to kind #51

Codecleanup type to kind

Codecleanup type to kind #51

name: CMake Mingw Cross-Compile
on:
push:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**CMakeLists.txt'
- .github/workflows/cmake-mingw-posix.yml
pull_request:
branches:
- '**'
paths:
- '**.cpp'
- '**.h'
- '**CMakeLists.txt'
- .github/workflows/cmake-mingw-posix.yml
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
WINEPATH: "/usr/lib/gcc/x86_64-w64-mingw32/10-posix;/usr/x86_64-w64-mingw32/lib"
jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: install cross-build dependencies
run: |
sudo apt install cmake mingw-w64 \
ninja-build wine
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
run: |
cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build \
-GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBuildTest=TRUE \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc-posix \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix \
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CROSS_COMPILING=TRUE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
#- name: add i386 for Wine
# shell: bash
# run: |
# sudo dpkg --add-architecture i386
#
#- name: Setup wine
# shell: bash
# run: |
# sudo apt-get update \
# && sudo apt install wine32
- name: Set variables
run: |
APP=$(cat $GITHUB_WORKSPACE/src/lib/Version/appName.txt)
VER=$(cat $GITHUB_WORKSPACE/src/lib/Version/version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
echo "APPNAME=$APP" >> $GITHUB_ENV
- name: Test mingw binary via wine
working-directory: ${{github.workspace}}
run: wine cmd /C build/test/WarfLang_TEST.exe
- name: Prepare Binaries for upload
shell: bash
run: |
mkdir ${{github.workspace}}/artifacts
cp build/src/lib/lib${{ env.APPNAME }}Core.a ${{github.workspace}}/artifacts
cp build/src/cli/${{ env.APPNAME }}.exe ${{github.workspace}}/artifacts
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ${{github.workspace}}/artifacts
cp /usr/lib/gcc/x86_64-w64-mingw32/10-posix/libgcc_s_seh-1.dll ${{github.workspace}}/artifacts
cp /usr/lib/gcc/x86_64-w64-mingw32/10-posix/libstdc++-6.dll ${{github.workspace}}/artifacts
pushd ${{github.workspace}}
zip -r ${{ env.APPNAME }}-Windows-mingw64.zip artifacts
popd
- name: 'Upload Pull Request Artifact'
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/pull/')
with:
name: ${{ env.APPNAME }} Pull Request Artifacts
path: ${{ env.APPNAME }}-*.zip
retention-days: 5
- name: Upload binaries to Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/heads/master')
with:
tag_name: ${{ env.APPNAME }}-${{ env.VERSION }}
files: |
${{ env.APPNAME }}-*.zip