Skip to content

Commit

Permalink
WIP: build Maui using make command
Browse files Browse the repository at this point in the history
  • Loading branch information
webwarrior-ws committed May 27, 2024
1 parent c646442 commit 640922e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: Build Maui Android frontend
run: dotnet build src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework=net8.0-android
- name: Build Android APK
run: dotnet publish src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework net8.0-android --configuration Release
# Upload artifact fails with "permission denied" error without this
Expand Down
21 changes: 13 additions & 8 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ type FrontendProject =
type FrontendApp =
| Console
| Gtk
| Maui
member self.GetProjectName() =
match self with
| Console -> CONSOLE_FRONTEND_APP
| Gtk -> GTK_FRONTEND_APP
| Maui -> MAUI_FRONTEND_APP
member self.GetExecutableName() =
match self with
| Console -> CONSOLE_FRONTEND_APP
| Gtk -> UNIX_NAME
| Maui -> MAUI_FRONTEND_APP
override self.ToString() =
sprintf "%A" self

Expand Down Expand Up @@ -310,13 +313,9 @@ let DotNetBuild
()
| _ -> ()

// We have to build Maui project for android twice because the first time we get
// an error about Resource file not found. The second time it works.
// https://github.com/fabulous-dev/FSharp.Mobile.Templates/tree/55a1f3a0fd5cc397e48677ef4ff9241b360b0e84
let BuildMauiProject binaryConfig =
let BuildMauiProject (binaryConfig: BinaryConfig) (frameworkIdentifier: string) =
let mauiProjectFilePath = FrontendProject.Maui.GetProjectFile().FullName
DotNetBuild mauiProjectFilePath binaryConfig "--framework net8.0-android" true
DotNetBuild mauiProjectFilePath binaryConfig "--framework net8.0-android" false
DotNetBuild mauiProjectFilePath binaryConfig (sprintf "--framework %s" frameworkIdentifier) true

let JustBuild binaryConfig maybeConstant: FrontendApp*FileInfo =
let maybeBuildTool = Map.tryFind "BuildTool" buildConfigContents
Expand Down Expand Up @@ -381,7 +380,6 @@ let JustBuild binaryConfig maybeConstant: FrontendApp*FileInfo =
// somehow, msbuild doesn't restore the frontend dependencies (e.g. Xamarin.Forms) when targetting
// the {LINUX|MAC}_SOLUTION_FILE below, so we need this workaround. TODO: just finish migrating to MAUI(dotnet restore)
NugetRestore solution
CopyXamlFiles()
MSBuildRestoreAndBuild solution

FrontendApp.Console
Expand Down Expand Up @@ -421,6 +419,13 @@ let JustBuild binaryConfig maybeConstant: FrontendApp*FileInfo =
FrontendApp.Gtk
else
FrontendApp.Console
| Some buildTool, None when buildTool = "dotnet" ->
if Misc.GuessPlatform() = Misc.Platform.Linux && FsxHelper.AreGtkLibsPresent Echo.All then
BuildMauiProject binaryConfig "net6.0-gtk"
else
BuildMauiProject binaryConfig "net8.0-android"

FrontendApp.Maui
| _ -> FrontendApp.Console

let scriptName = sprintf "%s-%s" UNIX_NAME (frontend.ToString().ToLower())
Expand Down Expand Up @@ -480,8 +485,8 @@ let MakeAll (maybeConstant: Option<string>) =
Network.DownloadNugetExe FsxHelper.NugetExe
#endif
let buildConfig = BinaryConfig.Debug
let frontend,_ = JustBuild buildConfig maybeConstant
CopyXamlFiles()
let frontend,_ = JustBuild buildConfig maybeConstant
frontend,buildConfig

let RunFrontend (frontend: FrontendApp) (buildConfig: BinaryConfig) (maybeArgs: Option<string>) =
Expand Down

0 comments on commit 640922e

Please sign in to comment.