diff --git a/scripts/configure.fsx b/scripts/configure.fsx index 7a3bb2585..e8fc3cbae 100755 --- a/scripts/configure.fsx +++ b/scripts/configure.fsx @@ -15,10 +15,12 @@ open System.Configuration open Fsdk open Fsdk.Process +#load "fsxHelper.fs" +open GWallet.Scripting let rootDir = DirectoryInfo(Path.Combine(__SOURCE_DIRECTORY__, "..")) -let initialConfigFile, buildTool = +let initialConfigFile, buildTool, isGtkPresent = match Misc.GuessPlatform() with | Misc.Platform.Windows -> let buildTool= @@ -27,13 +29,13 @@ let initialConfigFile, buildTool = | None -> Process.VsWhere "MSBuild\\**\\Bin\\MSBuild.exe" - Map.empty, buildTool + Map.empty, buildTool, false | platform (* Unix *) -> Process.ConfigCommandCheck ["make"] true true |> ignore match Process.ConfigCommandCheck ["dotnet"] false true with - | Some _ -> Map.empty, "dotnet" + | Some _ -> Map.empty, "dotnet", false | None -> Process.ConfigCommandCheck ["mono"] true true |> ignore @@ -45,7 +47,7 @@ let initialConfigFile, buildTool = if platform = Misc.Platform.Mac then match Process.ConfigCommandCheck [ "msbuild"; "xbuild" ] true true with - | Some theBuildTool -> Map.empty, theBuildTool + | Some theBuildTool -> Map.empty, theBuildTool, false | _ -> failwith "unreachable" else let buildTool = @@ -90,7 +92,15 @@ let initialConfigFile, buildTool = (stableVersionOfMono.ToString())) Environment.Exit 1 Console.WriteLine "found" - Map.empty.Add("MonoPkgConfigVersion", monoVersion), buildTool + + Console.Write "checking for GTK (libs)... " + let isGtkPresent = FsxHelper.IsGtkPresent() + if isGtkPresent then + Console.WriteLine "found" + else + Console.WriteLine "not found" + + Map.empty.Add("MonoPkgConfigVersion", monoVersion), buildTool, isGtkPresent #if LEGACY_FRAMEWORK let targetsFileToExecuteNugetBeforeBuild = """ @@ -148,6 +158,26 @@ let version = Misc.GetCurrentVersion(rootDir) let repoInfo = Git.GetRepoInfo() +let frontend = + match buildTool, Misc.GuessPlatform() with + + // NOTE: 'dotnet build' cannot build Xamarin.Forms, and make.fsx doesn't support yet building + // with both dotnet & msbuild yet + | "dotnet", _ -> "Console" + + | _, Misc.Platform.Linux -> + if isGtkPresent then + "Xamarin.Forms" + else + "Console" + + // NOTE: even though Windows has msbuild too, its buildTool value contains full path so it won't + // match with the case below (and this is on purpose, since we don't build WinUI/UWP frontend yet) + | "msbuild", _ -> + "Xamarin.Forms" + + | _ -> "Console" + Console.WriteLine() Console.WriteLine(sprintf "\tConfiguration summary for geewallet %s %s" @@ -162,6 +192,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`" diff --git a/scripts/fsxHelper.fs b/scripts/fsxHelper.fs index 9c4f0cff5..e8ba69607 100644 --- a/scripts/fsxHelper.fs +++ b/scripts/fsxHelper.fs @@ -4,6 +4,7 @@ open System open System.IO open Fsdk +open Fsdk.Process module FsxHelper = @@ -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 @@ -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 diff --git a/scripts/make.fsx b/scripts/make.fsx index 034dd4e1f..d94528dc6 100644 --- a/scripts/make.fsx +++ b/scripts/make.fsx @@ -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 @@ -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 diff --git a/scripts/sanitycheck.fsx b/scripts/sanitycheck.fsx index 5e4723e3f..13fc30bfc 100755 --- a/scripts/sanitycheck.fsx +++ b/scripts/sanitycheck.fsx @@ -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"