Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions bootstrap.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ git --version || GOTO missingGit
:: Initialize C++ runtime project
CALL :runtimeBootstrap || EXIT /B 1

:: Initialize the compiler's nuspec file
CALL :nuspecBootstrap || EXIT /B 1

:: Next steps are only needed for developers environment, they are skipped for cloud builds.
IF NOT "%AGENT_ID%" == "" GOTO EOF

Expand All @@ -33,17 +30,6 @@ popd
EXIT /B


:: Bootstrap the compiler nuspec
:nuspecBootstrap
pushd src\Simulation\CsharpGeneration
CALL powershell -NoProfile .\FindNuspecReferences.ps1 || EXIT /B 1
popd

pushd src\Simulation\Simulators
CALL powershell -NoProfile .\FindNuspecReferences.ps1 || EXIT /B 1
popd
EXIT /B

:missingGit
echo.
echo This script depends on git.
Expand Down
24 changes: 24 additions & 0 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

$ErrorActionPreference = 'Stop'

Push-Location (Join-Path $PSScriptRoot "src/Simulation/CsharpGeneration")
.\FindNuspecReferences.ps1
Pop-Location

Push-Location (Join-Path $PSScriptRoot "src/Simulation/Simulators")
.\FindNuspecReferences.ps1
Pop-Location

# bootstrap native folder
if ($Env:ENABLE_NATIVE -ne "false") {
## Run the right script based on the OS.
if (-not (Test-Path Env:AGENT_OS) -or ($Env:AGENT_OS.StartsWith("Win"))) {
.\bootstrap.cmd
} else {
.\bootstrap.sh
}
} else {
Write-Host "Skipping native. ENABLE_NATIVE variable set to: $Env:ENABLE_NATIVE."
}
16 changes: 10 additions & 6 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ $ErrorActionPreference = 'Stop'
& "$PSScriptRoot/set-env.ps1"
$all_ok = $True

Write-Host "##[info]Build Native simulator"
cmake --build (Join-Path $PSScriptRoot "../src/Simulation/Native/build") --config $Env:BUILD_CONFIGURATION
if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to build Native simulator."
$script:all_ok = $False
if ($Env:ENABLE_NATIVE -ne "false") {
Write-Host "##[info]Build Native simulator"
$nativeBuild = (Join-Path $PSScriptRoot "../src/Simulation/Native/build")
cmake --build $nativeBuild --config $Env:BUILD_CONFIGURATION
if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to build Native simulator."
$script:all_ok = $False
}
} else {
Write-Host "Skipping native. ENABLE_NATIVE variable set to: $Env:ENABLE_NATIVE."
}


function Build-One {
param(
[string]$action,
Expand Down
38 changes: 13 additions & 25 deletions build/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,22 @@ variables:
Drop.Native: $(System.DefaultWorkingDirectory)/xplat

jobs:
- job: macOS
pool:
vmImage: 'macOS-latest'
steps:
- template: steps-xplat.yml

- job: build
displayName: Build
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
mac:
imageName: 'macOS-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)

- job: Linux
pool:
vmImage: 'ubuntu-latest'
steps:
- template: steps-xplat.yml


- job: Windows
pool:
vmImage: 'windows-2019'
dependsOn:
- macOS
- Linux
condition: succeeded()
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download xplat native binaries'
inputs:
artifactName: xplat
downloadPath: $(System.DefaultWorkingDirectory)
- template: steps.yml

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
Expand Down
18 changes: 9 additions & 9 deletions build/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
);
Assemblies = @(
".\src\Azure\Azure.Quantum.Client\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Azure.Quantum.Client.dll",
".\src\simulation\CsharpGeneration\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.CsharpGeneration.dll",
".\src\simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.CsharpGeneration.App.dll",
".\src\simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.RoslynWrapper.dll",
".\src\simulation\Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Runtime.Core.dll",
".\src\simulation\EntryPointDriver\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.EntryPointDriver.dll",
".\src\simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll",
".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll",
".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll",
".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll",
".\src\Simulation\CsharpGeneration\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.CsharpGeneration.dll",
".\src\Simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.CsharpGeneration.App.dll",
".\src\Simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.RoslynWrapper.dll",
".\src\Simulation\Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Runtime.Core.dll",
".\src\Simulation\EntryPointDriver\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.EntryPointDriver.dll",
".\src\Simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll",
".\src\Xunit\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Xunit.dll"
) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot (Join-Path ".." $_)) };
} | Write-Output;
8 changes: 3 additions & 5 deletions build/steps-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ steps:
##
# Bootstrap
##
- task: BatchScript@1
displayName: 'Prepare build'
inputs:
filename: bootstrap.cmd
modifyEnvironment: true
- pwsh: ./bootstrap.ps1
displayName: "Bootstrap repository"
workingDirectory: $(System.DefaultWorkingDirectory)
3 changes: 2 additions & 1 deletion build/steps-wrap-up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ steps:
testRunTitle: 'Q# runtime tests'

- task: PublishSymbols@1
displayName: 'Publish symbols'
displayName: 'Publish symbols (Windows only)'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
continueOnError: true
inputs:
SearchPattern: '$(System.DefaultWorkingDirectory)/src/**/*.pdb'
Expand Down
50 changes: 0 additions & 50 deletions build/steps-xplat.yml

This file was deleted.

3 changes: 2 additions & 1 deletion build/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ steps:


- powershell: ./pack.ps1
displayName: "Pack Q# runtime"
displayName: "Pack Q# runtime (Windows only)"
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
workingDirectory: $(System.DefaultWorkingDirectory)/build


Expand Down
21 changes: 12 additions & 9 deletions build/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
& "$PSScriptRoot/set-env.ps1"
$all_ok = $True

Write-Host "##[info]Test Native simulator"
pushd (Join-Path $PSScriptRoot "../src/Simulation/Native/build")
cmake --build . --config $Env:BUILD_CONFIGURATION
ctest -C $Env:BUILD_CONFIGURATION
if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to test Native Simulator"
$script:all_ok = $False
if ($Env:ENABLE_NATIVE -ne "false") {
Write-Host "##[info]Test Native simulator"
pushd (Join-Path $PSScriptRoot "../src/Simulation/Native/build")
cmake --build . --config $Env:BUILD_CONFIGURATION
ctest -C $Env:BUILD_CONFIGURATION
if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to test Native Simulator"
$script:all_ok = $False
}
popd
} else {
Write-Host "Skipping native. ENABLE_NATIVE variable set to: $Env:ENABLE_NATIVE."
}
popd


function Test-One {
Param($project)
Expand Down
19 changes: 15 additions & 4 deletions src/Simulation/Common/Simulators.Dev.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
<DocumentationFile>bin\$(BuildConfiguration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<EnlistmentRoot>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory)..\..\..\))</EnlistmentRoot>
<NativeBuildPath>$([MSBuild]::NormalizePath($(EnlistmentRoot)src/Simulation/Native/build/))</NativeBuildPath>
</PropertyGroup>

<PropertyGroup Condition="'$(QsimDll)' == ''">
<QsimDllMac>$([MSBuild]::NormalizePath($(NativeBuildPath)/libMicrosoft.Quantum.Simulator.Runtime.dylib))</QsimDllMac>
<QsimDllLinux>$([MSBuild]::NormalizePath($(NativeBuildPath)/libMicrosoft.Quantum.Simulator.Runtime.so))</QsimDllLinux>
<QsimDllWindowsRelease>$([MSBuild]::NormalizePath($(NativeBuildPath)/Release/Microsoft.Quantum.Simulator.Runtime.dll))</QsimDllWindowsRelease>
<QsimDllWindowsDebug>$([MSBuild]::NormalizePath($(NativeBuildPath)/Debug/Microsoft.Quantum.Simulator.Runtime.dll))</QsimDllWindowsDebug>
<QSimDll Condition="Exists('$(QsimDllMac)')">$(QsimDllMac)</QSimDll>
<QSimDll Condition="Exists('$(QsimDllLinux)')">$(QsimDllLinux)</QSimDll>
<QSimDll Condition="Exists('$(QsimDllWindowsRelease)')">$(QsimDllWindowsRelease)</QSimDll>
<QSimDll Condition="'$(QsimDll)' == ''">$(QsimDllWindowsDebug)</QSimDll>
<QSimDll Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(QsimDllMac)</QSimDll>
<QSimDll Condition="$([MSBuild]::IsOsPlatform('Linux'))">$(QsimDllLinux)</QSimDll>
<QSimDll Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(QsimDllWindowsRelease)</QSimDll>
<QSimDll Condition="$([MSBuild]::IsOsPlatform('Windows')) And Exists('$(QsimDllWindowsDebug)')">$(QsimDllWindowsDebug)</QSimDll>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,6 +26,14 @@
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj" Condition=" '$([MSBuild]::NormalizePath($(EnlistmentRoot)src\Simulation\Simulators))' != '$(MSBuildProjectDirectory)'" IncludeInSimulatorPackage="true" />
</ItemGroup>

<ItemGroup>
<None Include="$(QSimDll)" >
<Link>Microsoft.Quantum.Simulator.Runtime.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
</ItemGroup>

<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
Expand Down
4 changes: 2 additions & 2 deletions src/Simulation/CsharpGeneration/FindNuspecReferences.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

using namespace System.IO

$target = 'Microsoft.Quantum.CsharpGeneration.nuspec'
$target = Join-Path $PSScriptRoot 'Microsoft.Quantum.CsharpGeneration.nuspec'
if (Test-Path $target) {
Write-Host "$target exists. Skipping generating new one."
exit
}

$nuspec = [Xml](Get-Content 'Microsoft.Quantum.CsharpGeneration.nuspec.template')
$nuspec = [Xml](Get-Content (Join-Path $PSScriptRoot 'Microsoft.Quantum.CsharpGeneration.nuspec.template'))
$dependencies = $nuspec.CreateElement('dependencies', $nuspec.package.metadata.NamespaceURI)

# Adds a dependency to the dependencies element if it does not already exist.
Expand Down
4 changes: 2 additions & 2 deletions src/Simulation/Simulators/FindNuspecReferences.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# nuget is tracking this problem at: https://github.com/NuGet/Home/issues/4491
########################################

$target = "Microsoft.Quantum.Simulators.nuspec"
$target = Join-Path $PSScriptRoot "Microsoft.Quantum.Simulators.nuspec"

if (Test-Path $target) {
Write-Host "$target exists. Skipping generating new one."
Expand All @@ -28,7 +28,7 @@ if (Test-Path $target) {


# Start with the nuspec template
$nuspec = [xml](Get-Content "Microsoft.Quantum.Simulators.nuspec.template")
$nuspec = [xml](Get-Content (Join-Path $PSScriptRoot "Microsoft.Quantum.Simulators.nuspec.template"))
$dep = $nuspec.CreateElement('dependencies', $nuspec.package.metadata.NamespaceURI)

function Add-PackageReferenceIfNew($ref)
Expand Down
6 changes: 0 additions & 6 deletions src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
</ItemGroup>

<ItemGroup>
<None Include="$(QSimDll)">
<Link>Microsoft.Quantum.Simulator.Runtime.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>

<None Include="..\Native\win10\**\*">
<Link>runtimes\win-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down