Skip to content

Commit 1fd1edb

Browse files
committed
Mac Package
1 parent 5fd13f3 commit 1fd1edb

30 files changed

Lines changed: 868 additions & 2 deletions

.github/workflows/build-linux.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build BrickController Linux
2+
3+
on:
4+
push:
5+
branches:
6+
- default
7+
- 'releases/**'
8+
paths:
9+
- '.github/**/*linux.yml'
10+
- 'build/installers/build-linux-deb.sh'
11+
- 'Directory.*.props'
12+
- 'NuGet.config'
13+
- 'BrickController2.slnx'
14+
- 'BrickController2/BrickController2/**'
15+
- 'BrickController2/BrickController2.Linux/**'
16+
pull_request:
17+
branches:
18+
- default
19+
- 'releases/**'
20+
paths:
21+
- '.github/**/*linux.yml'
22+
- 'build/installers/build-linux-deb.sh'
23+
- 'Directory.*.props'
24+
- 'NuGet.config'
25+
- 'BrickController2.slnx'
26+
- 'BrickController2/BrickController2/**'
27+
- 'BrickController2/BrickController2.Linux/**'
28+
release:
29+
types:
30+
- published
31+
workflow_dispatch:
32+
33+
permissions:
34+
contents: write
35+
36+
jobs:
37+
build-linux:
38+
runs-on: ubuntu-24.04
39+
name: BrickController Linux Build
40+
strategy:
41+
matrix:
42+
runtime: [linux-x64]
43+
env:
44+
APP_DISPLAY_VERSION: "0.0.0"
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Setup .NET
50+
uses: actions/setup-dotnet@v4
51+
with:
52+
dotnet-version: 10.0.x
53+
54+
- name: Install .NET MAUI Workload
55+
run: dotnet workload install maui-android
56+
57+
- name: Install GTK build dependencies
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y \
61+
libgtk-4-dev libwebkitgtk-6.0-dev \
62+
gobject-introspection libgirepository1.0-dev \
63+
gir1.2-gtk-4.0 gir1.2-webkit-6.0 \
64+
pkg-config dpkg-dev
65+
66+
- name: Set app version for release
67+
if: github.event_name == 'release' && github.event.action == 'published'
68+
run: echo "APP_DISPLAY_VERSION=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV"
69+
70+
- name: Build Linux installer
71+
run: bash build/installers/build-linux-deb.sh ${{ matrix.runtime }}
72+
73+
- name: Upload Linux artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: brickcontroller-linux-${{ matrix.runtime }}
77+
path: artifacts/installers/*.deb
78+
79+
- name: Upload Linux installer to release
80+
if: github.event_name == 'release' && github.event.action == 'published'
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
files: artifacts/installers/*.deb

.github/workflows/build-macos.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Build BrickController macOS
2+
3+
on:
4+
push:
5+
branches:
6+
- default
7+
- 'releases/**'
8+
paths:
9+
- '.github/**/*macos.yml'
10+
- 'build/installers/build-macos-pkg.sh'
11+
- 'Directory.*.props'
12+
- 'NuGet.config'
13+
- 'BrickController2.slnx'
14+
- 'BrickController2/BrickController2/**'
15+
- 'BrickController2/BrickController2.iOS/**'
16+
- 'BrickController2/BrickController2.MacCatalyst/**'
17+
pull_request:
18+
branches:
19+
- default
20+
- 'releases/**'
21+
paths:
22+
- '.github/**/*macos.yml'
23+
- 'build/installers/build-macos-pkg.sh'
24+
- 'Directory.*.props'
25+
- 'NuGet.config'
26+
- 'BrickController2.slnx'
27+
- 'BrickController2/BrickController2/**'
28+
- 'BrickController2/BrickController2.iOS/**'
29+
- 'BrickController2/BrickController2.MacCatalyst/**'
30+
release:
31+
types:
32+
- published
33+
workflow_dispatch:
34+
35+
permissions:
36+
contents: write
37+
38+
jobs:
39+
build-macos:
40+
runs-on: macos-latest
41+
name: BrickController macOS Build
42+
strategy:
43+
matrix:
44+
runtime: [maccatalyst-arm64, maccatalyst-x64]
45+
env:
46+
APP_DISPLAY_VERSION: "0.0.0"
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Setup .NET
52+
uses: actions/setup-dotnet@v4
53+
with:
54+
dotnet-version: 10.0.x
55+
56+
- name: Install .NET MAUI Workload
57+
run: dotnet workload install maui-maccatalyst
58+
59+
- name: Select compatible Xcode if available
60+
run: |
61+
if [ -d /Applications/Xcode_26.5.app/Contents/Developer ]; then
62+
echo "DEVELOPER_DIR=/Applications/Xcode_26.5.app/Contents/Developer" >> "$GITHUB_ENV"
63+
else
64+
xcodebuild -version
65+
fi
66+
67+
- name: Set app version for release
68+
if: github.event_name == 'release' && github.event.action == 'published'
69+
run: echo "APP_DISPLAY_VERSION=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV"
70+
71+
- name: Build macOS installer
72+
run: bash build/installers/build-macos-pkg.sh ${{ matrix.runtime }}
73+
74+
- name: Upload macOS artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: brickcontroller-macos-${{ matrix.runtime }}
78+
path: artifacts/installers/*.pkg
79+
80+
- name: Upload macOS installer to release
81+
if: github.event_name == 'release' && github.event.action == 'published'
82+
uses: softprops/action-gh-release@v2
83+
with:
84+
files: artifacts/installers/*.pkg

BrickController2.slnx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
<Platform Solution="*|ARM64" Project="ARM64" />
1717
<Deploy />
1818
</Project>
19+
<Project Path="BrickController2/BrickController2.MacCatalyst/BrickController2.MacCatalyst.csproj">
20+
<Platform Solution="*|ARM64" Project="ARM64" />
21+
<Platform Solution="*|x64" Project="x64" />
22+
<Deploy />
23+
</Project>
24+
<Project Path="BrickController2/BrickController2.Linux/BrickController2.Linux.csproj" />
1925
<Project Path="BrickController2/BrickController2.WinUI/BrickController2.WinUI.csproj">
2026
<Platform Solution="*|ARM64" Project="ARM64" />
2127
<Platform Solution="*|x64" Project="x64" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<OutputType>Exe</OutputType>
6+
<RootNamespace>BrickController2.Linux</RootNamespace>
7+
<AssemblyName>BrickController2.Linux</AssemblyName>
8+
<ApplicationId>com.scn.brickcontroller2</ApplicationId>
9+
<ApplicationTitle>BrickController 2</ApplicationTitle>
10+
<RuntimeIdentifiers>linux-x64;linux-arm64</RuntimeIdentifiers>
11+
<Description>Experimental Ubuntu/Linux desktop build of BrickController 2.</Description>
12+
<Authors>Istvan Murvai</Authors>
13+
<PackageProjectUrl>https://github.com/vicocz/brickcontroller2</PackageProjectUrl>
14+
<DebSection>utils</DebSection>
15+
<DebCategories>Utility;Game;</DebCategories>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Autofac" />
20+
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
21+
<PackageReference Include="Microsoft.Maui.Controls" />
22+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
23+
<PackageReference Include="Microsoft.Maui.Essentials" />
24+
<PackageReference Include="Microsoft.Maui.Platforms.Linux.Gtk4" />
25+
<PackageReference Include="Microsoft.Maui.Platforms.Linux.Gtk4.Essentials" />
26+
<ProjectReference Include="..\BrickController2\BrickController2.csproj" />
27+
</ItemGroup>
28+
29+
</Project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Autofac;
2+
using Autofac.Extensions.DependencyInjection;
3+
using BrickController2.BusinessLogic.DI;
4+
using BrickController2.CreationManagement.DI;
5+
using BrickController2.Database.DI;
6+
using BrickController2.DeviceManagement.DI;
7+
using BrickController2.Extensions;
8+
using BrickController2.InputDeviceManagement.DI;
9+
using BrickController2.Linux.PlatformServices.DI;
10+
using BrickController2.UI.DI;
11+
using Microsoft.Maui.Hosting;
12+
using Microsoft.Maui.Platforms.Linux.Gtk4.Essentials.Hosting;
13+
using Microsoft.Maui.Platforms.Linux.Gtk4.Hosting;
14+
using ZXing.Net.Maui.Controls;
15+
16+
namespace BrickController2.Linux;
17+
18+
public static class MauiProgram
19+
{
20+
public static MauiApp CreateMauiApp()
21+
{
22+
var builder = MauiApp
23+
.CreateBuilder()
24+
.UseMauiAppLinuxGtk4<BrickController2.App>()
25+
.AddLinuxGtk4Essentials()
26+
.ConfigureSymbolFonts()
27+
.UseBarcodeReader()
28+
.ConfigureContainer(new AutofacServiceProviderFactory(), autofacBuilder =>
29+
{
30+
autofacBuilder.RegisterModule(new PlatformServicesModule());
31+
32+
autofacBuilder.RegisterModule(new BusinessLogicModule());
33+
autofacBuilder.RegisterModule(new DatabaseModule());
34+
autofacBuilder.RegisterModule(new CreationManagementModule());
35+
autofacBuilder.RegisterModule(new DeviceManagementModule());
36+
autofacBuilder.RegisterModule(new InputDeviceManagementModule());
37+
autofacBuilder.RegisterModule(new UiModule());
38+
});
39+
40+
return builder.Build();
41+
}
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using BrickController2.PlatformServices.BluetoothLE;
2+
using Microsoft.Extensions.Logging;
3+
using System;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
7+
namespace BrickController2.Linux.PlatformServices.BluetoothLE;
8+
9+
public class BluetoothLEService : IBluetoothLEService
10+
{
11+
private readonly ILogger<BluetoothLEService> _logger;
12+
13+
public BluetoothLEService(ILogger<BluetoothLEService> logger)
14+
{
15+
_logger = logger;
16+
}
17+
18+
public Task<bool> IsBluetoothLESupportedAsync() => Task.FromResult(false);
19+
20+
public Task<bool> IsBluetoothLEAdvertisingSupportedAsync() => Task.FromResult(false);
21+
22+
public Task<bool> IsBluetoothOnAsync() => Task.FromResult(false);
23+
24+
public Task<bool> ScanDevicesAsync(Action<ScanResult> scanCallback, CancellationToken token)
25+
{
26+
_logger.LogWarning("Bluetooth LE is not implemented for the Linux GTK4 desktop head.");
27+
return Task.FromResult(false);
28+
}
29+
30+
public Task<IBluetoothLEDevice?> GetKnownDeviceAsync(string address)
31+
{
32+
_logger.LogWarning("Bluetooth LE device lookup is not implemented for the Linux GTK4 desktop head.");
33+
return Task.FromResult<IBluetoothLEDevice?>(null);
34+
}
35+
36+
public IBluetoothLEAdvertiserDevice? CreateBluetoothLEAdvertiserDevice() => null;
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Autofac;
2+
using BrickController2.DeviceManagement.CaDA;
3+
using BrickController2.DeviceManagement.JieStar;
4+
using BrickController2.DeviceManagement.MouldKing;
5+
using BrickController2.Linux.PlatformServices.BluetoothLE;
6+
using BrickController2.Linux.PlatformServices.DeviceManagement.CaDA;
7+
using BrickController2.Linux.PlatformServices.DeviceManagement.JieStar;
8+
using BrickController2.Linux.PlatformServices.DeviceManagement.MouldKing;
9+
using BrickController2.Linux.PlatformServices.GameController;
10+
using BrickController2.Linux.PlatformServices.Infrared;
11+
using BrickController2.Linux.PlatformServices.Localization;
12+
using BrickController2.Linux.PlatformServices.Permission;
13+
using BrickController2.Linux.PlatformServices.SharedFileStorage;
14+
using BrickController2.PlatformServices.BluetoothLE;
15+
using BrickController2.PlatformServices.InputDeviceService;
16+
using BrickController2.PlatformServices.Infrared;
17+
using BrickController2.PlatformServices.Localization;
18+
using BrickController2.PlatformServices.Permission;
19+
using BrickController2.PlatformServices.SharedFileStorage;
20+
21+
namespace BrickController2.Linux.PlatformServices.DI;
22+
23+
public class PlatformServicesModule : Module
24+
{
25+
protected override void Load(ContainerBuilder builder)
26+
{
27+
builder.RegisterType<InfraredService>().As<IInfraredService>().SingleInstance();
28+
builder.RegisterType<GameControllerService>().As<IInputDeviceService>().As<IStartable>().SingleInstance();
29+
builder.RegisterType<BluetoothLEService>().As<IBluetoothLEService>().SingleInstance();
30+
builder.RegisterType<LocalizationService>().As<ILocalizationService>().SingleInstance();
31+
builder.RegisterType<SharedFileStorageService>().As<ISharedFileStorageService>().SingleInstance();
32+
builder.RegisterType<BluetoothPermission>().As<IBluetoothPermission>().InstancePerDependency();
33+
builder.RegisterType<CameraPermission>().As<ICameraPermission>().InstancePerDependency();
34+
builder.RegisterType<ReadWriteExternalStoragePermission>().As<IReadWriteExternalStoragePermission>().InstancePerDependency();
35+
builder.RegisterType<MKPlatformService>().As<IMKPlatformService>().SingleInstance();
36+
builder.RegisterType<CaDAPlatformService>().As<ICaDAPlatformService>().SingleInstance();
37+
builder.RegisterType<JieStarPlatformService>().As<IJieStarPlatformService>().SingleInstance();
38+
}
39+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using BrickController2.DeviceManagement.CaDA;
2+
using BrickController2.Protocols;
3+
4+
namespace BrickController2.Linux.PlatformServices.DeviceManagement.CaDA;
5+
6+
public class CaDAPlatformService : ICaDAPlatformService
7+
{
8+
private const int HeaderOffset = 15;
9+
private const int PayloadOffset = 3;
10+
private const int PayloadLength = 24 + PayloadOffset;
11+
12+
public bool TryGetRfPayload(byte[] rawData, out byte[] rfPayload)
13+
{
14+
rfPayload = new byte[PayloadLength];
15+
CryptTools.GetRfPayload(CaDAProtocol.SeedArray, CaDAProtocol.HeaderArray, rawData, HeaderOffset, CaDAProtocol.CTXValue1, CaDAProtocol.CTXValue2, rfPayload, PayloadOffset);
16+
17+
return true;
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using BrickController2.DeviceManagement.JieStar;
2+
using BrickController2.Protocols;
3+
4+
namespace BrickController2.Linux.PlatformServices.DeviceManagement.JieStar;
5+
6+
public class JieStarPlatformService : IJieStarPlatformService
7+
{
8+
private const int HeaderOffset = 15;
9+
private const int PayloadOffset = 3;
10+
private const int PayloadLength = 24 + PayloadOffset;
11+
12+
public bool TryGetRfPayload(byte ctxValue2, byte[] rawData, out byte[] rfPayload)
13+
{
14+
rfPayload = new byte[PayloadLength];
15+
int payloadLength = CryptTools.GetRfPayload(JieStarProtocol.SeedArray, JieStarProtocol.HeaderArray, rawData, HeaderOffset, JieStarProtocol.CTXValue1, ctxValue2, rfPayload, PayloadOffset);
16+
17+
for (int index = payloadLength + PayloadOffset; index < PayloadLength; index++)
18+
{
19+
rfPayload[index] = (byte)(index + 1);
20+
}
21+
22+
return true;
23+
}
24+
}

0 commit comments

Comments
 (0)