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

Regenerate Libraries #464

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.13.2011.802-alpha" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.14.201219763-alpha" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 16 additions & 6 deletions src/Simulation/CsharpGeneration/RewriteStep.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,22 @@ type Emitter() =
let context = CodegenContext.Create (compilation, step.AssemblyConstants)
let allSources = GetSourceFiles.Apply compilation.Namespaces

for source in allSources |> Seq.filter context.GenerateCodeForSource do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
for source in allSources |> Seq.filter (not << context.GenerateCodeForSource) do
let content = SimulationCode.loadedViaTestNames source context
if content <> null then CompilationLoader.GeneratedFile(source, dir, ".dll.g.cs", content) |> ignore
let isExe =
match context.assemblyConstants.TryGetValue AssemblyConstants.QsharpOutputType with
| true, outputType -> outputType = AssemblyConstants.QsharpExe
| _ -> false

if isExe then
Copy link
Contributor

@bettinaheim bettinaheim Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for determining whether to emit C# for a particular source (whether source code or an assembly reference) is handled by GenerateCodeForSource. Please adapt it there rather than adding an additional branching here.

for source in allSources do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
else
for source in allSources |> Seq.filter context.GenerateCodeForSource do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
for source in allSources |> Seq.filter (not << context.GenerateCodeForSource) do
let content = SimulationCode.loadedViaTestNames source context
if content <> null then CompilationLoader.GeneratedFile(source, dir, ".dll.g.cs", content) |> ignore

if not compilation.EntryPoints.IsEmpty then
let callable = context.allCallables.[Seq.exactlyOne compilation.EntryPoints]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\Simulators.Dev.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<CsharpGeneration>false</CsharpGeneration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.14.201219763-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down