From 010bd0009a98bc941b80d89fb552d143512c5b58 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 27 Jun 2019 18:16:04 -0700 Subject: [PATCH] Added -noVisualStudio flag for build.cmd. (#7071) * Added -compiler flag for build. Does not require VS to build. * Renamed -compiler to -noVisualStudio * Minor fix * Trying to fix unix builds * Update DEVGUIDE.md --- DEVGUIDE.md | 4 ++ eng/Build.ps1 | 70 ++++++++++++++++++--- eng/build-utils.ps1 | 4 +- proto.proj | 3 - src/fsharp/FSharp.Build/FSharp.Build.fsproj | 3 +- src/fsharp/fsc/fsc.fsproj | 3 +- src/fsharp/fsi/fsi.fsproj | 3 +- 7 files changed, 72 insertions(+), 18 deletions(-) diff --git a/DEVGUIDE.md b/DEVGUIDE.md index 1ee9c227d..e944b0731 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -52,6 +52,10 @@ After you build the first time you can open and use this solution: If you are just developing the core compiler and library then building ``FSharp.sln`` will be enough. +If you do not have Visual Studio installed and want to simply build the compiler as a .NET Core application, use this: + + Build.cmd -noVisualStudio + ### Developing the F# Compiler (Linux/macOS) For Linux/Mac: diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 54e6ff5e2..f329cba02 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -53,6 +53,7 @@ param ( [switch]$testVs, [switch]$testAll, [string]$officialSkipTests = "false", + [switch]$noVisualStudio, [parameter(ValueFromRemainingArguments=$true)][string[]]$properties) @@ -96,6 +97,7 @@ function Print-Usage() { Write-Host " -procdump Monitor test runs with procdump" Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" Write-Host " -useGlobalNuGetCache Use global NuGet cache." + Write-Host " -noVisualStudio Only build fsc and fsi as .NET Core applications. No Visual Studio required. '-configuration', '-verbosity', '-norestore', '-rebuild' are supported." Write-Host "" Write-Host "Command line arguments starting with '/p:' are passed through to MSBuild." } @@ -145,8 +147,19 @@ function Process-Arguments() { } function Update-Arguments() { - if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe")) { - $script:bootstrap = $True + if ($script:noVisualStudio) { + $script:bootstrapTfm = "netcoreapp2.1" + $script:msbuildEngine = "dotnet" + } + + if ($bootstrapTfm -eq "netcoreapp2.1") { + if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) { + $script:bootstrap = $True + } + } else { + if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) { + $script:bootstrap = $True + } } } @@ -227,10 +240,37 @@ function TestUsingNUnit([string] $testProject, [string] $targetFramework) { $projectName = [System.IO.Path]::GetFileNameWithoutExtension($testProject) $testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml" $testBinLogPath = "$LogDir\${projectName}_$targetFramework.binlog" - $args = "test $testProject --no-restore --no-build -c $configuration -f $targetFramework -v n --test-adapter-path . --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath" + $args = "test $testProject -c $configuration -f $targetFramework -v n --test-adapter-path . --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath" + + if (-not $noVisualStudio -or $norestore) { + $args += " --no-restore" + } + + if (-not $noVisualStudio) { + $args += " --no-build" + } + Exec-Console $dotnetExe $args } +function BuildCompiler() { + if ($bootstrapTfm -eq "netcoreapp2.1") { + $dotnetPath = InitializeDotNetCli + $dotnetExe = Join-Path $dotnetPath "dotnet.exe" + $fscProject = "$RepoRoot\src\fsharp\fsc\fsc.fsproj" + $fsiProject = "$RepoRoot\src\fsharp\fsi\fsi.fsproj" + + $argNoRestore = if ($norestore) { " --no-restore" } else { "" } + $argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" } + + $args = "build $fscProject -c $configuration -v $verbosity -f netcoreapp2.1" + $argNoRestore + $argNoIncremental + Exec-Console $dotnetExe $args + + $args = "build $fsiProject -c $configuration -v $verbosity -f netcoreapp2.1" + $argNoRestore + $argNoIncremental + Exec-Console $dotnetExe $args + } +} + function Prepare-TempDir() { Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.props") $TempDir Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir @@ -259,7 +299,11 @@ try { } if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) { - BuildSolution + if ($noVisualStudio) { + BuildCompiler + } else { + BuildSolution + } } if ($build) { @@ -269,7 +313,7 @@ try { $desktopTargetFramework = "net472" $coreclrTargetFramework = "netcoreapp2.1" - if ($testDesktop) { + if ($testDesktop -and -not $noVisualStudio) { TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.LanguageServer.UnitTests\FSharp.Compiler.LanguageServer.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $desktopTargetFramework @@ -285,7 +329,7 @@ try { TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework } - if ($testFSharpQA) { + if ($testFSharpQA -and -not $noVisualStudio) { Push-Location "$RepoRoot\tests\fsharpqa\source" $resultsRoot = "$ArtifactsDir\TestResults\$configuration" $resultsLog = "test-net40-fsharpqa-results.log" @@ -304,21 +348,27 @@ try { } if ($testFSharpCore) { - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework + if (-not $noVisualStudio) { + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework + } TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework } if ($testCompiler) { - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework + if (-not $noVisualStudio) { + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework + } TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework } if ($testCambridge) { - TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework + if (-not $noVisualStudio) { + TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework + } TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework } - if ($testVs) { + if ($testVs -and -not $noVisualStudio) { TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\GetTypesVS.UnitTests\GetTypesVS.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework } diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index 335379b2f..fcda1a58e 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -230,7 +230,7 @@ function Run-MSBuild([string]$projectFilePath, [string]$buildArgs = "", [string] # Important to not set $script:bootstrapDir here yet as we're actually in the process of # building the bootstrap. function Make-BootstrapBuild() { - Write-Host "Building bootstrap compiler" + Write-Host "Building bootstrap '$bootstrapTfm' compiler" $dir = Join-Path $ArtifactsDir "Bootstrap" Remove-Item -re $dir -ErrorAction SilentlyContinue @@ -243,7 +243,7 @@ function Make-BootstrapBuild() { # prepare compiler $projectPath = "$RepoRoot\proto.proj" - Run-MSBuild $projectPath "/restore /t:Publish" -logFileName "Bootstrap" -configuration $bootstrapConfiguration + Run-MSBuild $projectPath "/restore /t:Publish /p:TargetFramework=$bootstrapTfm;ProtoTargetFramework=$bootstrapTfm" -logFileName "Bootstrap" -configuration $bootstrapConfiguration Copy-Item "$ArtifactsDir\bin\fsc\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsc" -Force -Recurse Copy-Item "$ArtifactsDir\bin\fsi\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsi" -Force -Recurse diff --git a/proto.proj b/proto.proj index b0ee28897..23d7525d1 100644 --- a/proto.proj +++ b/proto.proj @@ -7,15 +7,12 @@ - TargetFramework=net472 TargetFramework=netcoreapp2.1 - TargetFramework=net472 TargetFramework=netcoreapp2.1 - TargetFramework=net472 TargetFramework=netcoreapp2.1 diff --git a/src/fsharp/FSharp.Build/FSharp.Build.fsproj b/src/fsharp/FSharp.Build/FSharp.Build.fsproj index 0bf32ed19..e22c87970 100644 --- a/src/fsharp/FSharp.Build/FSharp.Build.fsproj +++ b/src/fsharp/FSharp.Build/FSharp.Build.fsproj @@ -4,7 +4,8 @@ Library - net472;netcoreapp2.1 + $(ProtoTargetFramework) + net472;netcoreapp2.1 netcoreapp2.1 FSharp.Build $(NoWarn);45;55;62;75;1204 diff --git a/src/fsharp/fsc/fsc.fsproj b/src/fsharp/fsc/fsc.fsproj index 370664ee6..7bddcb9df 100644 --- a/src/fsharp/fsc/fsc.fsproj +++ b/src/fsharp/fsc/fsc.fsproj @@ -4,7 +4,8 @@ Exe - net472;netcoreapp2.1 + $(ProtoTargetFramework) + net472;netcoreapp2.1 netcoreapp2.1 .exe $(NoWarn);45;55;62;75;1204 diff --git a/src/fsharp/fsi/fsi.fsproj b/src/fsharp/fsi/fsi.fsproj index fb55d4d89..5b4978679 100644 --- a/src/fsharp/fsi/fsi.fsproj +++ b/src/fsharp/fsi/fsi.fsproj @@ -4,7 +4,8 @@ Exe - net472;netcoreapp2.1 + $(ProtoTargetFramework) + net472;netcoreapp2.1 netcoreapp2.1 .exe $(NoWarn);45;55;62;75;1204