|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +#Requires -Version 7.1 |
| 5 | + |
| 6 | +& (Join-Path $PSScriptRoot .. .. .. .. build set-env.ps1) |
| 7 | +$FailureCommands = 'Write-Host "##vso[task.logissue type=error;] Failed to build SparseSimulator. See errors below or above." ; Pop-Location ; Exit 1' |
| 8 | + |
| 9 | +# BULD NATIVE PART |
| 10 | + |
| 11 | +# mkdir Native\build\(Debug|Release) |
| 12 | +$BuildDir = (Join-Path $PSScriptRoot "Native" "build" $Env:BUILD_CONFIGURATION) |
| 13 | +if (-not (Test-Path $BuildDir)) { |
| 14 | + New-Item -Path $BuildDir -ItemType "directory" | Out-Null |
| 15 | +} |
| 16 | + |
| 17 | +# pushd Native\build\(Debug|Release) |
| 18 | +Push-Location $BuildDir |
| 19 | + |
| 20 | + $CmakeConfigCommand = "cmake -G Ninja -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON -D CMAKE_BUILD_TYPE=$Env:BUILD_CONFIGURATION -S ..\.. " # Without `-G Ninja` the compiler chosen is always `cl.exe`. |
| 21 | + |
| 22 | + if (($IsMacOS) -or ((Test-Path Env:/AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Darwin")))) |
| 23 | + { |
| 24 | + Write-Host "On MacOS build using the default C/C++ compiler (should be AppleClang)" |
| 25 | + } |
| 26 | + else { |
| 27 | + if (($IsLinux) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Lin")))) |
| 28 | + { |
| 29 | + Write-Host "On Linux build using Clang" |
| 30 | + $CC = "clang-11" |
| 31 | + $CXX = "clang++-11" |
| 32 | + #$clangTidy = "-DCMAKE_CXX_CLANG_TIDY=clang-tidy-11" |
| 33 | + } |
| 34 | + elseif (($IsWindows) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win")))) |
| 35 | + { |
| 36 | + Write-Host "On Windows build using Clang" |
| 37 | + $CC = "clang.exe" |
| 38 | + $CXX = "clang++.exe" |
| 39 | + |
| 40 | + if (!(Get-Command clang -ErrorAction SilentlyContinue) -and (choco find --idonly -l llvm) -contains "llvm") { |
| 41 | + # LLVM was installed by Chocolatey, so add the install location to the path. |
| 42 | + $env:PATH += ";$($env:SystemDrive)\Program Files\LLVM\bin" |
| 43 | + } |
| 44 | + |
| 45 | + #if (Get-Command clang-tidy -ErrorAction SilentlyContinue) { |
| 46 | + # # Only run clang-tidy if it's installed. This is because the package used by chocolatey on |
| 47 | + # # the build pipeline doesn't include clang-tidy, so we allow skipping that there and let |
| 48 | + # # the Linux build catch tidy issues. |
| 49 | + # $clangTidy = "-DCMAKE_CXX_CLANG_TIDY=clang-tidy" |
| 50 | + #} |
| 51 | + } |
| 52 | + |
| 53 | + $CmakeConfigCommand += " -D CMAKE_C_COMPILER=$CC -D CMAKE_CXX_COMPILER=$CXX " |
| 54 | + } |
| 55 | + |
| 56 | + # Generate the build scripts: |
| 57 | + ( Invoke-Expression $CmakeConfigCommand ) || ( Invoke-Expression $FailureCommands ) |
| 58 | + |
| 59 | + # Invoke the build scripts: |
| 60 | + ( cmake --build . ) || ( Invoke-Expression $FailureCommands ) |
| 61 | + |
| 62 | +# popd |
| 63 | +Pop-Location |
| 64 | + |
| 65 | + |
| 66 | +# BUILD C# PART AND TESTS |
| 67 | + |
| 68 | +Push-Location $PSScriptRoot |
| 69 | + ( dotnet build . --configuration $Env:BUILD_CONFIGURATION ) || ( Invoke-Expression $FailureCommands ) |
| 70 | +Pop-Location |
0 commit comments