Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 1d1988e

Browse files
ricardo-espinozabamarshabettinaheimRyan ShafferScottCarda-MS
authored
Merging payload from Master branch (#495)
* Use invariant culture for string conversions in tests (#470) * Prevent result equality comparisons for QPRGen0 runtime capabilities (#449) * Prevent result equality with QPRGen0 * Move more fields from SymbolTracker to ResolutionContext * Undo some changes to TypeChecking.cs * Move ResolutionContext up a bit * Better error message * Add basic tests * Add more tests (but not working right now...) * Fix tests * Add tests for not equals * Use static member for Create * Move ResolutionContext to SymbolTracker.fs * Update doc comment to ArgumentException Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com> * Replace failwith with ArgumentException * Mention SymbolTracker versioning in ResolutionContext * Restore supportsEqualityComparison and use VerifyIsOneOf * Undo changes to VerificationTools.fs * Rename ResolutionContext to ScopeContext * Include execution target in error message * Make ScopeContext.ExecutionTarget non-nullable * Update error message Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com> * Fix possible null reference in CompilationLoader (#481) * Revising the plugin mechanism for compiler steps (#472) * Classically Controlled Short Circuit Bug Fix (#478) Reordered the steps of the classically controlled rewrite to have the if-statement restructuring done first. * Don't execute rewrite steps if the validation fails (#473) * Use Uri.LocalPath instead of Uri.AbsolutePath for file IDs (#468) * Use Uri.LocalPath instead of Uri.AbsolutePath * Fix attribute reader test * Update packages to fix tests * Add GetFileId and deprecate TryGetFileId * Re-add null URI check Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com> * Use OnCompilation in transformations. (#484) * Fix to reserve symbol in set statement crash (#486) * Add NoOp to Precondition Dependencies for Classically Controlled (#489) Added NoOp to precondition dependency list for classical control. * NoOp Removed from Dependency List (#490) Removed NoOp to precondition dependency list for classical control. Co-authored-by: Sarah Marshall <33814365+samarsha@users.noreply.github.com> Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com> Co-authored-by: Ryan Shaffer <ryan.shaffer@microsoft.com> Co-authored-by: Scott Carda <55811729+ScottCarda-MS@users.noreply.github.com> Co-authored-by: César Zaragoza Cortés <cesar.zaragoza@outlook.com>
1 parent 3c55e68 commit 1d1988e

File tree

59 files changed

+1622
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1622
-834
lines changed

examples/CompilerExtensions/CompilerExtensions.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29613.14
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{9EFAE282-6480-48EA-B90C-B69CD6050029}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "Demo\Demo.csproj", "{9EFAE282-6480-48EA-B90C-B69CD6050029}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomExtension", "CustomExtension\CustomExtension.csproj", "{3AB91EBB-F33B-4DB8-B11C-AD78E4DCA235}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomExtension", "CustomExtension\CustomExtension.csproj", "{3AB91EBB-F33B-4DB8-B11C-AD78E4DCA235}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomExtension.Package", "ExtensionPackage\CustomExtension.Package.csproj", "{AAFBDEA6-87EA-4FD7-AECD-41A5C5FF4289}"
911
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,10 @@ Global
2123
{3AB91EBB-F33B-4DB8-B11C-AD78E4DCA235}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{3AB91EBB-F33B-4DB8-B11C-AD78E4DCA235}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{3AB91EBB-F33B-4DB8-B11C-AD78E4DCA235}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{AAFBDEA6-87EA-4FD7-AECD-41A5C5FF4289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{AAFBDEA6-87EA-4FD7-AECD-41A5C5FF4289}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{AAFBDEA6-87EA-4FD7-AECD-41A5C5FF4289}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{AAFBDEA6-87EA-4FD7-AECD-41A5C5FF4289}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

examples/CompilerExtensions/CustomExtension/CustomExtension.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.11.2006.411-beta" />
8+
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.11.2006.2118-beta" />
99
</ItemGroup>
1010

1111
</Project>

examples/CompilerExtensions/Demo/Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.411-beta">
1+
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.2118-beta">
22

33
<PropertyGroup>
44
<QscVerbosity>Detailed</QscVerbosity>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<QscRef_CustomExtension_Package>
6+
$(MSBuildThisFileDirectory)/../lib/netstandard2.1/CustomExtension.dll;
7+
$(MSBuildThisFileDirectory)/../lib/netstandard2.1/CustomExtension.Package.dll
8+
</QscRef_CustomExtension_Package>
9+
</PropertyGroup>
10+
11+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\CustomExtension\CustomExtension.csproj" />
9+
</ItemGroup>
10+
11+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
3+
<metadata>
4+
<id>CustomExtension.Package</id>
5+
<version>0.11.2006.1905-beta</version>
6+
<title></title>
7+
<authors>Microsoft</authors>
8+
<owners></owners>
9+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
10+
<description>Example for a Q# compiler extension.</description>
11+
<releaseNotes></releaseNotes>
12+
<copyright></copyright>
13+
<tags></tags>
14+
<dependencies>
15+
<dependency id="Microsoft.Quantum.Compiler" version="0.11.2006.1905-beta" />
16+
</dependencies>
17+
<summary></summary>
18+
</metadata>
19+
<files>
20+
<file src="CompilerExtension.props" target="build\CustomExtension.Package.props" />
21+
<file src="bin\$Configuration$\**\*.dll" exclude="bin\$Configuration$\**\CustomExtension.Package.dll" target="lib" />
22+
</files>
23+
</package>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Creating a NuGet package containing a Q# compiler extension
2+
3+
This project contains a template for packaging a Q# compiler extension. For more information about Q# compiler extensions see [here](https://github.com/microsoft/qsharp-compiler/tree/master/src/QuantumSdk#extending-the-q-compiler). For more information on NuGet packages, see [here](https://docs.microsoft.com/en-us/nuget/what-is-nuget).
4+
5+
Prerequisites: [NuGet tools](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools)
6+
7+
To create the package, follow the following steps:
8+
- From within the project directory, run `dotnet build`.
9+
- From within the project directory, run `nuget pack`.
10+
- Copy the created .nupkg file into you [local NuGet folder](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds).
11+
- You can now use that package like any other NuGet package.
12+
13+
In order to use the created package as a Q# compiler extension when building a Q# project, add the following package reference to your project file:
14+
```
15+
<PackageReference Include="CustomExtension.Package" Version="1.0.0" IsQscReference="true" />
16+
```
17+
The extension will only be included in the build process if`IsQscReference` is set to `true`. For more information, see this [readme](https://github.com/microsoft/qsharp-compiler/blob/master/src/QuantumSdk/README.md).

src/QsCompiler/CommandLineTool/Commands/Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static int Run(BuildOptions options, ConsoleLogger logger)
159159
{
160160
ProjectName = options.ProjectName,
161161
AssemblyConstants = assemblyConstants,
162-
TargetPackageAssembly = options.GetTargetPackageAssemblyPath(logger),
162+
TargetPackageAssemblies = options.TargetSpecificDecompositions,
163163
RuntimeCapabilities = options.RuntimeCapabilites,
164164
SkipMonomorphization = options.RuntimeCapabilites == RuntimeCapabilities.Unknown,
165165
GenerateFunctorSupport = true,

src/QsCompiler/CommandLineTool/Commands/Diagnose.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public static int Run(DiagnoseOptions options, ConsoleLogger logger)
218218
var loadOptions = new CompilationLoader.Configuration
219219
{
220220
AssemblyConstants = assemblyConstants,
221-
TargetPackageAssembly = options.GetTargetPackageAssemblyPath(logger),
221+
TargetPackageAssemblies = options.TargetSpecificDecompositions,
222222
RuntimeCapabilities = options.RuntimeCapabilites,
223223
SkipMonomorphization = options.RuntimeCapabilites == RuntimeCapabilities.Unknown,
224224
GenerateFunctorSupport = true,

src/QsCompiler/CommandLineTool/Options.cs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public class CompilationOptions : Options
3535
public int TrimLevel { get; set; }
3636

3737
[Option("load", Required = false, SetName = CODE_MODE,
38-
HelpText = "[Experimental feature] Path to the .NET Core dll(s) defining additional transformations to include in the compilation process.")]
38+
HelpText = "Path to the .NET Core dll(s) defining additional transformations to include in the compilation process.")]
3939
public IEnumerable<string> Plugins { get; set; }
4040

41-
[Option("target-package", Required = false, SetName = CODE_MODE,
42-
HelpText = "Path to the NuGet package containing target specific information and implementations.")]
43-
public string TargetPackage { get; set; }
41+
[Option("target-specific-decompositions", Required = false, SetName = CODE_MODE,
42+
HelpText = "[Experimental feature] Path to the .NET Core dll(s) containing target specific implementations.")]
43+
public IEnumerable<string> TargetSpecificDecompositions { get; set; }
4444

4545
[Option("load-test-names", Required = false, Default = false, SetName = CODE_MODE,
4646
HelpText = "Specifies whether public types and callables declared in referenced assemblies are exposed via their test name defined by the corresponding attribute.")]
@@ -74,33 +74,6 @@ internal bool ParseAssemblyProperties(out Dictionary<string, string> parsed)
7474
}
7575
return success;
7676
}
77-
78-
/// <summary>
79-
/// Returns null if TargetPackage is null or empty, and
80-
/// returns the path to the assembly containing target specific implementations otherwise.
81-
/// If a logger is specified, logs suitable diagnostics if a TargetPackages is not null or empty,
82-
/// but no path to the target package assembly could be determined.
83-
/// This may be the case if no directory at the TargetPackage location exists, or if its files can't be accessed,
84-
/// or more than one dll matches the pattern by which the target package assembly is identified.
85-
/// </summary>
86-
public string GetTargetPackageAssemblyPath(ILogger logger = null)
87-
{
88-
if (String.IsNullOrEmpty(this.TargetPackage)) return null;
89-
try
90-
{
91-
// Disclaimer: we may revise that in the future.
92-
var targetPackageAssembly = Directory.GetFiles(this.TargetPackage, "*Intrinsics.dll", SearchOption.AllDirectories).SingleOrDefault();
93-
if (targetPackageAssembly != null) return targetPackageAssembly;
94-
}
95-
catch (Exception ex)
96-
{
97-
if (Directory.Exists(this.TargetPackage)) logger?.Log(ex);
98-
else logger?.Log(ErrorCode.CouldNotFindTargetPackage, new[] { this.TargetPackage });
99-
}
100-
101-
logger?.Log(ErrorCode.CouldNotFindTargetPackageAssembly, new[] { this.TargetPackage });
102-
return null;
103-
}
10477
}
10578

10679

0 commit comments

Comments
 (0)