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
This commit is contained in:
Will Smith 2019-06-27 18:16:04 -07:00 коммит произвёл GitHub
Родитель 6af64a7bc0
Коммит 010bd0009a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 72 добавлений и 18 удалений

Просмотреть файл

@ -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 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) ### Developing the F# Compiler (Linux/macOS)
For Linux/Mac: For Linux/Mac:

Просмотреть файл

@ -53,6 +53,7 @@ param (
[switch]$testVs, [switch]$testVs,
[switch]$testAll, [switch]$testAll,
[string]$officialSkipTests = "false", [string]$officialSkipTests = "false",
[switch]$noVisualStudio,
[parameter(ValueFromRemainingArguments=$true)][string[]]$properties) [parameter(ValueFromRemainingArguments=$true)][string[]]$properties)
@ -96,6 +97,7 @@ function Print-Usage() {
Write-Host " -procdump Monitor test runs with procdump" Write-Host " -procdump Monitor test runs with procdump"
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -useGlobalNuGetCache Use global NuGet cache." 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 ""
Write-Host "Command line arguments starting with '/p:' are passed through to MSBuild." Write-Host "Command line arguments starting with '/p:' are passed through to MSBuild."
} }
@ -145,9 +147,20 @@ function Process-Arguments() {
} }
function Update-Arguments() { function Update-Arguments() {
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe")) { 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 $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
}
}
} }
function BuildSolution() { function BuildSolution() {
@ -227,10 +240,37 @@ function TestUsingNUnit([string] $testProject, [string] $targetFramework) {
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($testProject) $projectName = [System.IO.Path]::GetFileNameWithoutExtension($testProject)
$testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml" $testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml"
$testBinLogPath = "$LogDir\${projectName}_$targetFramework.binlog" $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 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() { function Prepare-TempDir() {
Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.props") $TempDir Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.props") $TempDir
Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir
@ -259,8 +299,12 @@ try {
} }
if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) { if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) {
if ($noVisualStudio) {
BuildCompiler
} else {
BuildSolution BuildSolution
} }
}
if ($build) { if ($build) {
VerifyAssemblyVersions VerifyAssemblyVersions
@ -269,7 +313,7 @@ try {
$desktopTargetFramework = "net472" $desktopTargetFramework = "net472"
$coreclrTargetFramework = "netcoreapp2.1" $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.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.Compiler.LanguageServer.UnitTests\FSharp.Compiler.LanguageServer.UnitTests.fsproj" -targetFramework $desktopTargetFramework
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.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 TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
} }
if ($testFSharpQA) { if ($testFSharpQA -and -not $noVisualStudio) {
Push-Location "$RepoRoot\tests\fsharpqa\source" Push-Location "$RepoRoot\tests\fsharpqa\source"
$resultsRoot = "$ArtifactsDir\TestResults\$configuration" $resultsRoot = "$ArtifactsDir\TestResults\$configuration"
$resultsLog = "test-net40-fsharpqa-results.log" $resultsLog = "test-net40-fsharpqa-results.log"
@ -304,21 +348,27 @@ try {
} }
if ($testFSharpCore) { if ($testFSharpCore) {
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 $desktopTargetFramework
}
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
} }
if ($testCompiler) { if ($testCompiler) {
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 $desktopTargetFramework
}
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
} }
if ($testCambridge) { if ($testCambridge) {
if (-not $noVisualStudio) {
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
}
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework 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\GetTypesVS.UnitTests\GetTypesVS.UnitTests.fsproj" -targetFramework $desktopTargetFramework
TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework
} }

Просмотреть файл

@ -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 # Important to not set $script:bootstrapDir here yet as we're actually in the process of
# building the bootstrap. # building the bootstrap.
function Make-BootstrapBuild() { function Make-BootstrapBuild() {
Write-Host "Building bootstrap compiler" Write-Host "Building bootstrap '$bootstrapTfm' compiler"
$dir = Join-Path $ArtifactsDir "Bootstrap" $dir = Join-Path $ArtifactsDir "Bootstrap"
Remove-Item -re $dir -ErrorAction SilentlyContinue Remove-Item -re $dir -ErrorAction SilentlyContinue
@ -243,7 +243,7 @@ function Make-BootstrapBuild() {
# prepare compiler # prepare compiler
$projectPath = "$RepoRoot\proto.proj" $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\fsc\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsc" -Force -Recurse
Copy-Item "$ArtifactsDir\bin\fsi\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsi" -Force -Recurse Copy-Item "$ArtifactsDir\bin\fsi\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsi" -Force -Recurse

Просмотреть файл

@ -7,15 +7,12 @@
<ItemGroup> <ItemGroup>
<Projects Include="src\fsharp\FSharp.Build\FSharp.Build.fsproj"> <Projects Include="src\fsharp\FSharp.Build\FSharp.Build.fsproj">
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties> <AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
</Projects> </Projects>
<Projects Include="src\fsharp\fsc\fsc.fsproj"> <Projects Include="src\fsharp\fsc\fsc.fsproj">
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties> <AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
</Projects> </Projects>
<Projects Include="src\fsharp\fsi\fsi.fsproj"> <Projects Include="src\fsharp\fsi\fsi.fsproj">
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties> <AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
</Projects> </Projects>
</ItemGroup> </ItemGroup>

Просмотреть файл

@ -4,7 +4,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
<AssemblyName>FSharp.Build</AssemblyName> <AssemblyName>FSharp.Build</AssemblyName>
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn> <NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

Просмотреть файл

@ -4,7 +4,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
<TargetExt>.exe</TargetExt> <TargetExt>.exe</TargetExt>
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn> <NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

Просмотреть файл

@ -4,7 +4,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks> <TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
<TargetExt>.exe</TargetExt> <TargetExt>.exe</TargetExt>
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn> <NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>