Skip to content

Commit

Permalink
feat: hollow launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraZiling committed Jul 10, 2024
1 parent 59b52e8 commit f8bba45
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 17 deletions.
10 changes: 0 additions & 10 deletions Hollow/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,8 @@ public class App : Application
private static IServiceProvider? _provider;
public override void Initialize()
{
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Version", AppInfo.AppVersion)
.MinimumLevel.Debug()
.WriteTo.Console(outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}")
.WriteTo.File(Path.Combine(AppInfo.LogDir, "log_.txt"), outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: null)
.CreateLogger();

AvaloniaXamlLoader.Load(this);
_provider = ConfigureServices();

//TODO: Platform specific
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", AppInfo.CachesDir);
AvaloniaWebViewBuilder.Initialize(default);
}

Expand Down
22 changes: 19 additions & 3 deletions Hollow/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using Avalonia;
using System;
using System.IO;
using Avalonia.Logging;
using Avalonia.WebView.Desktop;
using Hollow.Models;
using Serilog;

namespace Hollow;

Expand All @@ -10,14 +14,26 @@ sealed class Program
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Version", AppInfo.AppVersion)
.MinimumLevel.Debug()
.WriteTo.Console(outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}")
.WriteTo.File(Path.Combine(AppInfo.LogDir, "log_.txt"), outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: null)
.CreateLogger();

//TODO: Platform specific
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", AppInfo.CachesDir);

BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.WithInterFont()
.UseDesktopWebView();
}
3 changes: 2 additions & 1 deletion Hollow/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
Expand All @@ -18,7 +19,7 @@ private void MinimizeButton_OnClick(object? _1, RoutedEventArgs _2)

private void CloseButton_OnClick(object? _1, RoutedEventArgs _2)
{
Close();
Environment.Exit(0);
}

protected override void OnPointerPressed(PointerPressedEventArgs e)
Expand Down
12 changes: 9 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ param(

$ErrorActionPreference = "Stop";

Write-Output "Start building launcher...";

cargo build --manifest-path .\hollow-launcher\Cargo.toml -r

Write-Output "Start building withRuntime...";

dotnet publish Hollow/Hollow.csproj -o "build/$Version/withRuntime" -p:EnableCompressionInSingleFile=true -p:PublishSingleFile=true -p:Platform=win-x64 -p:SelfContained=true -p:AssemblyVersion=$Version -p:Configuration=Release;
dotnet publish Hollow/Hollow.csproj -o "build/$Version/withRuntime/hollow_app" -r win-x64 -p:SelfContained=true -p:AssemblyVersion=$Version -p:Configuration=Release;

Rename-Item -Path "build/$Version/withRuntime/Hollow.exe" -NewName "Hollow_withRuntime.exe"
Copy-Item -Path ".\hollow-launcher\target\release\Hollow.exe" -Destination ".\build\$Version\withRuntime\Hollow.exe"

Write-Output "Start building withoutRuntime...";

dotnet publish Hollow/Hollow.csproj -o "build/$Version/withoutRuntime" -p:Platform=win-x64 -p:PublishReadyToRun=true -p:SelfContained=false -p:AssemblyVersion=$Version -p:Configuration=Release;
dotnet publish Hollow/Hollow.csproj -o "build/$Version/withoutRuntime/hollow_app" -r win-x64 -p:SelfContained=false -p:AssemblyVersion=$Version -p:Configuration=Release;

Copy-Item -Path ".\hollow-launcher\target\release\Hollow.exe" -Destination ".\build\$Version\withoutRuntime\Hollow.exe"

Write-Output "Build Finished";

Expand Down
276 changes: 276 additions & 0 deletions hollow-launcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions hollow-launcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "hollow-launcher"
version = "0.0.1"
edition = "2021"
build = "build.rs"

[[bin]]
name = "Hollow"
path = "src/main.rs"
windows_subsystem = "windows"

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }

[build-dependencies]
winres = "0.1.12"
Binary file added hollow-launcher/assets/small_icon.ico
Binary file not shown.
Loading

0 comments on commit f8bba45

Please sign in to comment.