From 29272e080f0afe92625c98954c63ce34147d2c3b Mon Sep 17 00:00:00 2001 From: webwarrior Date: Thu, 12 Jan 2023 14:24:22 +0100 Subject: [PATCH] WIP: call nuget restore On legacy non-Windows platforms use make.fsx for build, that will download nuget and call nuget restore. --- .github/workflows/CI.yml | 8 ++--- scripts/make.fsx | 73 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f1dabbb7..a9ea4bca 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -213,7 +213,7 @@ jobs: - name: configure run: ./configure.sh - name: build in DEBUG mode - run: make + run: fsharpi --define:LEGACY_FRAMEWORK scripts/make.fsx - name: run unit tests run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx @@ -255,7 +255,7 @@ jobs: - name: configure run: ./configure.sh - name: build in DEBUG mode - run: make + run: fsharpi --define:LEGACY_FRAMEWORK scripts/make.fsx - name: run unit tests run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx @@ -353,7 +353,7 @@ jobs: - name: configure run: ./configure.sh - name: build in DEBUG mode - run: make + run: fsharpi --define:LEGACY_FRAMEWORK scripts/make.fsx - name: run unit tests run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx @@ -395,7 +395,7 @@ jobs: - name: configure run: ./configure.sh - name: build in DEBUG mode - run: make + run: fsharpi --define:LEGACY_FRAMEWORK scripts/make.fsx - name: run unit tests run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx diff --git a/scripts/make.fsx b/scripts/make.fsx index c1bd286b..71d38c97 100644 --- a/scripts/make.fsx +++ b/scripts/make.fsx @@ -85,8 +85,67 @@ let FindBuildTool() : string * string = match Misc.GuessPlatform() with | Misc.Platform.Linux | Misc.Platform.Mac -> - failwith - "cannot find buildTool because this script is not ready for Unix yet" + let buildConfigFileName = "build.config" + + let buildConfigContents = + let buildConfig = + Path.Combine(RootDir.FullName, buildConfigFileName) + |> FileInfo + + if not(buildConfig.Exists) then + let configureLaunch = + match Misc.GuessPlatform() with + | Misc.Platform.Windows -> ".\\configure.bat" + | _ -> "./configure.sh" + + Console.Error.WriteLine( + sprintf + "ERROR: configure hasn't been run yet, run %s first" + configureLaunch + ) + + Environment.Exit 1 + + let configFileLines = File.ReadAllLines buildConfig.FullName + + let skipBlankLines line = + not <| String.IsNullOrWhiteSpace line + + let splitLineIntoKeyValueTuple(line: string) = + let pair = + line.Split([| '=' |], StringSplitOptions.RemoveEmptyEntries) + + if pair.Length <> 2 then + failwithf + "All lines in '%s' must conform to key=value format, but got: '%s'. All lines: \n%s" + buildConfigFileName + line + (File.ReadAllText buildConfig.FullName) + + pair.[0], pair.[1] + + let buildConfigContents = + configFileLines + |> Array.filter skipBlankLines + |> Array.map splitLineIntoKeyValueTuple + |> Map.ofArray + + buildConfigContents + + let maybeBuildTool = Map.tryFind "BuildTool" buildConfigContents + + match maybeBuildTool with + | None -> + failwith + "A BuildTool should have been chosen by the configure script, please report this bug" + | Some "dotnet" -> +#if LEGACY_FRAMEWORK + failwith + "'dotnet' shouldn't be the build tool when using legacy framework, please report this bug" +#endif + "dotnet", "build" + | Some otherBuildTool -> + otherBuildTool, String.Empty | Misc.Platform.Windows -> #if !LEGACY_FRAMEWORK "dotnet", "build" @@ -156,6 +215,9 @@ let JustBuild binaryConfig = #else let solFile = "fsx-legacy.sln" + if not NugetExe.Exists then + Network.DownloadNugetExe NugetExe + Network.RunNugetCommand NugetExe (sprintf "restore %s" solFile) @@ -179,7 +241,12 @@ let MakeAll() = buildConfig let programFiles = - Environment.GetEnvironmentVariable "ProgramW6432" |> DirectoryInfo + let programFilesPath = Environment.GetEnvironmentVariable "ProgramW6432" + + if isNull programFilesPath then // hack for unix platforms so that script doesn't crash + DirectoryInfo "/" + else + DirectoryInfo programFilesPath let fsxInstallationDir = Path.Combine(programFiles.FullName, "fsx") |> DirectoryInfo