Skip to content

Commit ac7188d

Browse files
add workflow and project
1 parent 41fa1f3 commit ac7188d

File tree

8 files changed

+224
-0
lines changed

8 files changed

+224
-0
lines changed

.github/workflows/build.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Build Native mGBA Libraries
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
10+
android:
11+
name: 🟢 Android
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
abi: [armeabi-v7a, arm64-v8a, x86, x86_64]
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt update
22+
sudo apt install -y cmake ninja-build openjdk-11-jdk ffmpeg libpng-dev zlib1g-dev libsqlite3-dev libfreetype6-dev libzip-dev libelf-dev
23+
24+
- name: Build mGBA for ${{ matrix.abi }}
25+
run: |
26+
export PATH="$PATH:/usr/bin/ffmpeg"
27+
mkdir -p build/android/${{ matrix.abi }}
28+
cd build/android/${{ matrix.abi }}
29+
cmake ../../../libs/mgba \
30+
-DCMAKE_TOOLCHAIN_FILE=../../../libs/mgba/toolchains/android.toolchain.cmake \
31+
-DANDROID_ABI=${{ matrix.abi }} \
32+
-DANDROID_PLATFORM=android-21 \
33+
-DCMAKE_BUILD_TYPE=Release \
34+
-DENABLE_CORE=ON \
35+
-DENABLE_LIBMGBA=ON \
36+
-DENABLE_GIF=ON \
37+
-DENABLE_FFMPEG=ON \
38+
-DENABLE_STATIC=OFF \
39+
-DENABLE_SHARED=ON
40+
make -j$(nproc)
41+
42+
- name: Upload artifact
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: mgba-android-${{ matrix.abi }}
46+
path: build/android/${{ matrix.abi }}/libmgba.*
47+
48+
windows:
49+
name: 🪟 Windows
50+
runs-on: windows-latest
51+
strategy:
52+
matrix:
53+
arch: [x64, ARM64]
54+
steps:
55+
- uses: actions/checkout@v3
56+
57+
- name: Setup vcpkg
58+
run: |
59+
git clone https://github.com/microsoft/vcpkg
60+
.\vcpkg\bootstrap-vcpkg.bat
61+
.\vcpkg\vcpkg.exe install ffmpeg libpng zlib sqlite3 freetype libzip libelf --triplet x64-windows
62+
63+
- name: Build mGBA for ${{ matrix.arch }}
64+
run: |
65+
$env:PATH += ";C:\vcpkg\installed\x64-windows\bin"
66+
mkdir build\windows\${{ matrix.arch }}
67+
cd build\windows\${{ matrix.arch }}
68+
cmake ../../../libs/mgba `
69+
-G "Visual Studio 17 2022" `
70+
-A ${{ matrix.arch }} `
71+
-DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake `
72+
-DCMAKE_C_FLAGS="/D _Atomic=" `
73+
-DCMAKE_BUILD_TYPE=Release `
74+
-DENABLE_CORE=ON `
75+
-DENABLE_LIBMGBA=ON `
76+
-DENABLE_GIF=ON `
77+
-DENABLE_FFMPEG=ON `
78+
-DENABLE_STATIC=OFF `
79+
-DENABLE_SHARED=ON
80+
cmake --build . --config Release
81+
82+
- name: Upload artifact
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: mgba-windows-${{ matrix.arch }}
86+
path: build/windows/${{ matrix.arch }}/Release/mgba.*
87+
88+
ios:
89+
name: 🍎 iOS
90+
runs-on: macos-latest
91+
strategy:
92+
matrix:
93+
arch: [arm64, x86_64]
94+
steps:
95+
- uses: actions/checkout@v3
96+
97+
- name: Install dependencies
98+
run: brew install ffmpeg libpng zlib sqlite3 freetype libzip libelf
99+
100+
- name: Build mGBA for iOS ${{ matrix.arch }}
101+
run: |
102+
export PATH="$PATH:/opt/homebrew/bin"
103+
mkdir -p build/ios/${{ matrix.arch }}
104+
cd build/ios/${{ matrix.arch }}
105+
cmake ../../../libs/mgba \
106+
-DCMAKE_SYSTEM_NAME=Darwin \
107+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
108+
-DCMAKE_OSX_SYSROOT=iphoneos \
109+
-DCMAKE_C_FLAGS="-target ${{ matrix.arch }}-apple-ios13.0" \
110+
-DCMAKE_BUILD_TYPE=Release \
111+
-DENABLE_CORE=ON \
112+
-DENABLE_LIBMGBA=ON \
113+
-DENABLE_GIF=ON \
114+
-DENABLE_FFMPEG=ON \
115+
-DENABLE_STATIC=OFF \
116+
-DENABLE_SHARED=ON
117+
make -j$(sysctl -n hw.logicalcpu)
118+
119+
- name: Upload artifact
120+
uses: actions/upload-artifact@v3
121+
with:
122+
name: mgba-ios-${{ matrix.arch }}
123+
path: build/ios/${{ matrix.arch }}/libmgba.*
124+
125+
macos:
126+
name: 🖥️ macOS
127+
runs-on: macos-latest
128+
strategy:
129+
matrix:
130+
arch: [x86_64, arm64]
131+
steps:
132+
- uses: actions/checkout@v3
133+
134+
- name: Install dependencies
135+
run: brew install ffmpeg libpng zlib sqlite3 freetype libzip libelf
136+
137+
- name: Build mGBA for macOS ${{ matrix.arch }}
138+
run: |
139+
export PATH="$PATH:/opt/homebrew/bin"
140+
mkdir -p build/macos/${{ matrix.arch }}
141+
cd build/macos/${{ matrix.arch }}
142+
cmake ../../../libs/mgba \
143+
-DCMAKE_SYSTEM_NAME=Darwin \
144+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
145+
-DCMAKE_OSX_SYSROOT=macosx \
146+
-DCMAKE_C_FLAGS="-target ${{ matrix.arch }}-apple-macos13.0" \
147+
-DCMAKE_BUILD_TYPE=Release \
148+
-DENABLE_CORE=ON \
149+
-DENABLE_LIBMGBA=ON \
150+
-DENABLE_GIF=ON \
151+
-DENABLE_FFMPEG=ON \
152+
-DENABLE_STATIC=OFF \
153+
-DENABLE_SHARED=ON
154+
make -j$(sysctl -n hw.logicalcpu)
155+
156+
- name: Upload artifact
157+
uses: actions/upload-artifact@v3
158+
with:
159+
name: mgba-macos-${{ matrix.arch }}
160+
path: build/macos/${{ matrix.arch }}/libmgba.*

src/MGBA.Native/Class1.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MGBA.Native;
2+
3+
// All the code in this file is included in all platforms.
4+
public class Class1
5+
{
6+
}

src/MGBA.Native/MGBA.Native.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->
8+
<UseMaui>true</UseMaui>
9+
<SingleProject>true</SingleProject>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<Nullable>enable</Nullable>
12+
13+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
14+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
15+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
16+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
17+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
18+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MGBA.Native;
2+
3+
// All the code in this file is only included on Android.
4+
public class PlatformClass1
5+
{
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MGBA.Native;
2+
3+
// All the code in this file is only included on Mac Catalyst.
4+
public class PlatformClass1
5+
{
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace MGBA.Native
4+
{
5+
// All the code in this file is only included on Tizen.
6+
public class PlatformClass1
7+
{
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MGBA.Native;
2+
3+
// All the code in this file is only included on Windows.
4+
public class PlatformClass1
5+
{
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MGBA.Native;
2+
3+
// All the code in this file is only included on iOS.
4+
public class PlatformClass1
5+
{
6+
}

0 commit comments

Comments
 (0)