Skip to content

Commit

Permalink
WIP: call nuget restore
Browse files Browse the repository at this point in the history
On legacy non-Windows platforms use make.fsx for build,
that will download nuget and call nuget restore.
  • Loading branch information
webwarrior-ws committed Jan 12, 2023
1 parent ddae982 commit 29272e0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
73 changes: 70 additions & 3 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 29272e0

Please sign in to comment.