Skip to content

Commit 7cb9590

Browse files
committed
Build: more cleanup
1 parent f79742e commit 7cb9590

8 files changed

Lines changed: 38 additions & 69 deletions

File tree

build/Building.fs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,25 @@
33
open FSharp.Core
44
open Fake.Core
55
open Fake.DotNet
6+
open Fake.DotNet.DotNet.Options
67
open Fake.IO.FileSystemOperators
78

89
open Model
910

11+
let inline private minimal p = withVerbosity (Some DotNet.Verbosity.Minimal) p
12+
let inline private buildOptions args (p:DotNet.BuildOptions) = { p with NoRestore = true; MSBuildParams = args }
13+
let inline private packOptions args (p:DotNet.PackOptions) = { p with NoRestore = true; MSBuildParams = args }
1014

11-
let private dotnet command =
12-
DotNet.exec id command "" |> ignore<ProcessResult>
15+
let private normal = { MSBuild.CliArguments.Create() with NodeReuse = false; Properties = [ ("StrongName", "False") ] }
16+
let private strongNamed = { MSBuild.CliArguments.Create() with NodeReuse = false; Properties = [ ("StrongName", "True") ] }
17+
18+
let restore (solution:Solution) = DotNet.restore minimal solution.SolutionFile
1319

14-
let private dotnetWeak command =
15-
let properties = [ ("StrongName", "False") ]
16-
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
17-
DotNet.exec id command suffix |> ignore<ProcessResult>
20+
let build (solution:Solution) = DotNet.build (minimal >> buildOptions normal) solution.SolutionFile
21+
let buildStrongNamed (solution:Solution) = DotNet.build (minimal >> buildOptions strongNamed) solution.SolutionFile
1822

19-
let private dotnetStrong command =
20-
let properties = [ ("StrongName", "True") ]
21-
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
22-
DotNet.exec id command suffix |> ignore<ProcessResult>
23-
24-
25-
let clean (solution:Solution) = dotnet (sprintf "clean %s --configuration Release --verbosity minimal" solution.SolutionFile)
26-
27-
let restoreWeak (solution:Solution) = dotnetWeak (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
28-
let restoreStrong (solution:Solution) = dotnetStrong (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
29-
30-
let buildWeak (solution:Solution) = dotnetWeak (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
31-
let buildStrong (solution:Solution) = dotnetStrong (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
32-
33-
let packWeak (solution:Solution) = dotnetWeak (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
34-
let packStrong (solution:Solution) = dotnetStrong (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
35-
36-
let packProjectWeak = function
37-
| VisualStudio p -> dotnetWeak (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
38-
| _ -> failwith "Project type not supported"
39-
let packProjectStrong = function
40-
| VisualStudio p -> dotnetStrong (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
41-
| _ -> failwith "Project type not supported"
23+
let pack (solution:Solution) = DotNet.pack (minimal >> packOptions normal) solution.SolutionFile
24+
let packStrongNamed (solution:Solution) =DotNet.pack (minimal >> packOptions strongNamed) solution.SolutionFile
4225

4326
let buildVS2019x86 config isIncremental subject =
4427
MSBuild.run

build/Documentation.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open Fake.IO.FileSystemOperators
88
open System
99

1010
open Model
11-
open Dotnet
1211

1312
let provideDocExtraFiles extraDocs (releases:Release list) =
1413
for (fileName, docName) in extraDocs do Shell.copyFile ("docs" </> docName) fileName
@@ -21,5 +20,6 @@ let provideDocExtraFiles extraDocs (releases:Release list) =
2120
File.readAsString release.ReleaseNotesFile ]
2221
|> File.replaceContent ("docs" </> (release.ReleaseNotesFile |> String.replace "RELEASENOTES" "ReleaseNotes"))
2322

23+
let private dotnet command = DotNet.exec id command "" |> ignore<ProcessResult>
2424
let buildDocs outputDir = dotnet (sprintf "fsdocs build --noapidocs --output %s" outputDir)
2525
let watchDocs outputDir = dotnet (sprintf "fsdocs watch --noapidocs --output %s" outputDir)

build/Dotnet.fs

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/Model.fs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ let nativeBashScriptProject binaryName bashScriptFile nuGetPackages =
113113
Release = nuGetPackages |> List.map (fun p -> p.Release) |> List.distinct |> List.exactlyOne }
114114
|> Project.NativeBashScript
115115

116-
117-
let projectOutputDir = function
118-
| VisualStudio p -> p.OutputDir
119-
| NativeVisualStudio p -> p.OutputDir
120-
| NativeBashScript p -> p.OutputDir
121-
122116
let projectRelease = function
123117
| VisualStudio p -> p.Release
124118
| NativeVisualStudio p -> p.Release
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Preparing
1+
module Versioning
22

33
open FSharp.Core
44
open Fake.Core
@@ -11,15 +11,15 @@ let private getRegexSingleLine pattern =
1111
match regexes_sl.TryGetValue pattern with
1212
| true, regex -> regex
1313
| _ -> (System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.Singleline))
14-
let regex_replace_singleline pattern (replacement : string) text = (getRegexSingleLine pattern).Replace(text, replacement)
14+
let private regex_replace_singleline pattern (replacement : string) text = (getRegexSingleLine pattern).Replace(text, replacement)
1515

16-
let patchVersionInResource path (release:Release) =
16+
let updateNativeResource path (release:Release) =
1717
File.applyReplace
1818
(String.regex_replace @"\d+\.\d+\.\d+\.\d+" release.AssemblyVersion
1919
>> String.regex_replace @"\d+,\d+,\d+,\d+" (String.replace "." "," release.AssemblyVersion))
2020
path
2121

22-
let patchVersionInProjectFile (project:Project) =
22+
let updateProject (project:Project) =
2323
match project with
2424
| VisualStudio p ->
2525
let semverSplit = p.Release.PackageVersion.IndexOf('-')

build/build.fs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ let header = """
1515
open FSharp.Core
1616
open Fake.Core
1717
open Fake.Core.TargetOperators
18+
open Fake.DotNet
1819
open Fake.IO
1920
open Fake.IO.FileSystemOperators
2021
open Fake.IO.Globbing.Operators
2122
open System
2223

2324
open Model
24-
open Dotnet
25-
open Preparing
2625
open Building
2726
open Testing
2827
open Packaging
@@ -174,13 +173,13 @@ let ``Clean`` _ =
174173
allSolutions |> List.iter (fun solution -> Shell.cleanDirs [ solution.OutputZipDir; solution.OutputNuGetDir; solution.OutputLibDir; solution.OutputLibStrongNameDir ])
175174

176175
let ``Apply Version`` _ =
177-
allProjects |> List.iter patchVersionInProjectFile
178-
patchVersionInResource "src/NativeProviders/MKL/resource.rc" mklRelease
179-
patchVersionInResource "src/NativeProviders/CUDA/resource.rc" cudaRelease
180-
patchVersionInResource "src/NativeProviders/OpenBLAS/resource.rc" openBlasRelease
176+
allProjects |> List.iter Versioning.updateProject
177+
Versioning.updateNativeResource "src/NativeProviders/MKL/resource.rc" mklRelease
178+
Versioning.updateNativeResource "src/NativeProviders/CUDA/resource.rc" cudaRelease
179+
Versioning.updateNativeResource "src/NativeProviders/OpenBLAS/resource.rc" openBlasRelease
181180

182181
let ``Restore`` _ =
183-
allSolutions |> List.iter restoreWeak
182+
allSolutions |> List.iter restore
184183

185184
let fingerprint = "490408de3618bed0a28e68dc5face46e5a3a97dd"
186185
let timeserver = "http://time.certum.pl/"
@@ -190,22 +189,22 @@ let ``Build`` isStrongname isSign _ =
190189
// Strong Name Build (with strong name, without certificate signature)
191190
if isStrongname then
192191
Shell.cleanDirs (!! "src/**/obj/" ++ "src/**/bin/" )
193-
restoreStrong numericsSolution
194-
buildStrong numericsSolution
192+
restore numericsSolution
193+
buildStrongNamed numericsSolution
195194
if isSign then sign fingerprint timeserver numericsSolution
196195
collectBinariesSN numericsSolution
197196
zip numericsStrongNameZipPackage header numericsSolution.OutputZipDir numericsSolution.OutputLibStrongNameDir (fun f -> f.Contains("MathNet.Numerics.") || f.Contains("System.Threading.") || f.Contains("FSharp.Core."))
198-
packStrong numericsSolution
197+
packStrongNamed numericsSolution
199198
collectNuGetPackages numericsSolution
200199

201200
// Normal Build (without strong name, with certificate signature)
202201
Shell.cleanDirs (!! "src/**/obj/" ++ "src/**/bin/" )
203-
restoreWeak numericsSolution
204-
buildWeak numericsSolution
202+
restore numericsSolution
203+
build numericsSolution
205204
if isSign then sign fingerprint timeserver numericsSolution
206205
collectBinaries numericsSolution
207206
zip numericsZipPackage header numericsSolution.OutputZipDir numericsSolution.OutputLibDir (fun f -> f.Contains("MathNet.Numerics.") || f.Contains("System.Threading.") || f.Contains("FSharp.Core."))
208-
packWeak numericsSolution
207+
pack numericsSolution
209208
collectNuGetPackages numericsSolution
210209

211210
// NuGet Sign (all or nothing)
@@ -220,7 +219,7 @@ let ``Build MKL Windows`` isIncremental isSign _ =
220219
// |> Proc.run
221220
//if result.ExitCode <> 0 then failwith "Error while setting oneAPI environment variables."
222221

223-
restoreWeak mklSolution
222+
restore mklSolution
224223
buildVS2019x86 "Release-MKL" isIncremental !! "MathNet.Numerics.MKL.sln"
225224
buildVS2019x64 "Release-MKL" isIncremental !! "MathNet.Numerics.MKL.sln"
226225
Directory.create mklSolution.OutputZipDir
@@ -233,7 +232,7 @@ let ``Build MKL Windows`` isIncremental isSign _ =
233232

234233
let ``Build CUDA Windows`` isIncremental isSign _ =
235234

236-
restoreWeak cudaSolution
235+
restore cudaSolution
237236
buildVS2019x64 "Release-CUDA" isIncremental !! "MathNet.Numerics.CUDA.sln"
238237
Directory.create cudaSolution.OutputZipDir
239238
zip cudaWinZipPackage header cudaSolution.OutputZipDir "out/CUDA/Windows" (fun f -> f.Contains("MathNet.Numerics.Providers.CUDA.") || f.Contains("MathNet.Numerics.CUDA.") || f.Contains("cublas") || f.Contains("cudart") || f.Contains("cusolver"))
@@ -245,7 +244,7 @@ let ``Build CUDA Windows`` isIncremental isSign _ =
245244

246245
let ``Build OpenBLAS Windows`` isIncremental isSign _ =
247246

248-
restoreWeak openBlasSolution
247+
restore openBlasSolution
249248
buildVS2019x86 "Release-OpenBLAS" isIncremental !! "MathNet.Numerics.OpenBLAS.sln"
250249
buildVS2019x64 "Release-OpenBLAS" isIncremental !! "MathNet.Numerics.OpenBLAS.sln"
251250
Directory.create openBlasSolution.OutputZipDir
@@ -277,7 +276,7 @@ let extraDocs =
277276
"CONTRIBUTORS.md", "Contributors.md" ]
278277

279278
let ``Docs Clean`` _ =
280-
Shell.cleanDirs ["out/docs"]
279+
Shell.cleanDirs ["out/docs"]
281280

282281
let ``Docs Build`` _ =
283282
provideDocExtraFiles extraDocs releases
@@ -438,6 +437,7 @@ let initTargets strongname sign incremental =
438437
[<EntryPoint>]
439438
let main argv =
440439

440+
Environment.CurrentDirectory <- Path.getFullName (__SOURCE_DIRECTORY__ </> "..")
441441
Trace.log Environment.CurrentDirectory
442442

443443
argv
@@ -466,7 +466,7 @@ let main argv =
466466
if isIncremental then Trace.log " Option: Incremental"
467467
Trace.log ""
468468

469-
dotnet "--info"
469+
DotNet.exec id "--info" "" |> ignore<ProcessResult>
470470
Trace.log ""
471471

472472
initTargets isStrongname isSign isIncremental

build/build.fsproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<Compile Include="Model.fs" />
11-
<Compile Include="Dotnet.fs" />
12-
<Compile Include="Preparing.fs" />
11+
<Compile Include="Versioning.fs" />
1312
<Compile Include="Building.fs" />
1413
<Compile Include="Testing.fs" />
1514
<Compile Include="Packaging.fs" />

src/FSharp/FSharp.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Control.Describe now includes CPU architecture and family identifier if know</Pa
3939
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
4040
<GenerateDocumentationFile>true</GenerateDocumentationFile>
4141
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
42-
<NoWarn>2003</NoWarn>
42+
<NoWarn>2003;NU1604</NoWarn>
4343
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
4444
</PropertyGroup>
4545
<ItemGroup>
@@ -65,10 +65,10 @@ Control.Describe now includes CPU architecture and family identifier if know</Pa
6565
</ItemGroup>
6666
<ItemGroup>
6767
<PackageReference Include="FSharp.Core" Version="5.0.2" />
68+
<PackageReference Include="System.ValueTuple" Version="4.4.0" Condition="'$(TargetFramework)' == 'net461'" />
6869
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
6970
<PrivateAssets>all</PrivateAssets>
7071
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7172
</PackageReference>
72-
<PackageReference Include="System.ValueTuple" Version="4.4.0" Condition="'$(TargetFramework)' == 'net461'" />
7373
</ItemGroup>
7474
</Project>

0 commit comments

Comments
 (0)