Skip to content

Commit

Permalink
scripts/configure.fsx: put Frontend in cfg summary
Browse files Browse the repository at this point in the history
To be able to reuse the way of checking for GTK via pkg-config in
both configure and Makefile we had to put it in fsxHelper.fs, which
in turn required me to convert a tuple into a function (and add one
more case to its potential error msg).
  • Loading branch information
knocte committed Aug 11, 2023
1 parent 93e2c74 commit 2d5fe98
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
17 changes: 17 additions & 0 deletions scripts/configure.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ open System.Configuration
open Fsdk
open Fsdk.Process

#load "fsxHelper.fs"
open GWallet.Scripting

let rootDir = DirectoryInfo(Path.Combine(__SOURCE_DIRECTORY__, ".."))

Expand Down Expand Up @@ -148,6 +150,18 @@ let version = Misc.GetCurrentVersion(rootDir)

let repoInfo = Git.GetRepoInfo()

let frontend =
match buildTool, Misc.GuessPlatform() with
| "dotnet", _ -> "Console"
| _, Misc.Platform.Linux ->
if FsxHelper.IsGtkPresent() then
"Xamarin.Forms"
else
"Console"
| "msbuild", _ ->
"Xamarin.Forms"
| _ -> "Console"

Console.WriteLine()
Console.WriteLine(sprintf
"\tConfiguration summary for geewallet %s %s"
Expand All @@ -162,6 +176,9 @@ Console.WriteLine(sprintf
Console.WriteLine(sprintf
"\t* .NET build tool: %s"
(if buildTool = "dotnet" then "dotnet build" else buildTool))
Console.WriteLine(sprintf
"\t* Frontend: %s"
frontend)
Console.WriteLine()

Console.WriteLine "Configuration succeeded, you can now run `make`"
18 changes: 16 additions & 2 deletions scripts/fsxHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open System
open System.IO

open Fsdk
open Fsdk.Process

module FsxHelper =

Expand All @@ -19,7 +20,16 @@ module FsxHelper =
|> ignore
dir

let FsxRunnerBin,FsxRunnerArg =
let IsGtkPresent() =
if Misc.GuessPlatform() <> Misc.Platform.Linux then
failwith "Gtk is only supported in Linux"

let pkgConfigForGtkProc = Process.Execute({ Command = "pkg-config"; Arguments = "gtk-sharp-2.0" }, Echo.All)
match pkgConfigForGtkProc.Result with
| Error _ -> false
| _ -> true

let FsxRunnerInfo() =
match Misc.GuessPlatform() with
| Misc.Platform.Windows ->
#if !LEGACY_FRAMEWORK
Expand All @@ -34,6 +44,10 @@ module FsxHelper =
let msg = "FsxRunnerBin env var not found, it should have been sourced from build.config file"
let msgFull =
msg + Environment.NewLine +
"(maybe you meant to run a Makefile target rather than this script directly; or there is a .sh wrapper script for your .fsx script)"
(sprintf "(maybe you 1. %s, or 2. %s, or 3. %s)"
"called this from configure.fsx (which is not supported, just use this func from make.fsx or sanitycheck.fsx)"
"you meant to run a Makefile target rather than this script directly?"
"there is a .sh wrapper script for your .fsx script"
)
failwith msgFull
fsxRunnerBinEnvVar, fsxRunnerArgEnvVar
13 changes: 4 additions & 9 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,7 @@ let JustBuild binaryConfig maybeConstant: Frontend*FileInfo =

Frontend.Console
| Misc.Platform.Linux ->
let pkgConfigForGtkProc = Process.Execute({ Command = "pkg-config"; Arguments = "gtk-sharp-2.0" }, Echo.All)
let isGtkPresent =
match pkgConfigForGtkProc.Result with
| Error _ -> false
| _ -> true

if isGtkPresent then
if FsxHelper.IsGtkPresent() then
let solution = LINUX_SOLUTION_FILE
#if LEGACY_FRAMEWORK
ExplicitRestore solution
Expand Down Expand Up @@ -615,10 +609,11 @@ match maybeTarget with
#endif

let sanityCheckScript = Path.Combine(FsxHelper.ScriptsDir.FullName, "sanitycheck.fsx")
let fsxRunnerBin,fsxRunnerArg = FsxHelper.FsxRunnerInfo()
Process.Execute(
{
Command = FsxHelper.FsxRunnerBin
Arguments = sprintf "%s %s" FsxHelper.FsxRunnerArg sanityCheckScript
Command = fsxRunnerBin
Arguments = sprintf "%s %s" fsxRunnerArg sanityCheckScript
},
Echo.All
).UnwrapDefault() |> ignore<string>
Expand Down
5 changes: 3 additions & 2 deletions scripts/sanitycheck.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ let FindOffendingPrintfUsage () =
Path.DirectorySeparatorChar
)

let fsxRunnerBin, fsxRunnerArg = FsxHelper.FsxRunnerInfo()
let proc =
{
Command = FsxHelper.FsxRunnerBin
Command = fsxRunnerBin
Arguments = sprintf "%s %s --exclude=%s %s"
FsxHelper.FsxRunnerArg
fsxRunnerArg
findScript
excludeFolders
"printf failwithf"
Expand Down

0 comments on commit 2d5fe98

Please sign in to comment.