From 074c57766b2bd71ce375c16a57d0bad3b11595ee Mon Sep 17 00:00:00 2001 From: Ryan Shaffer Date: Wed, 4 Nov 2020 13:34:27 -0800 Subject: [PATCH] Don't set execution target for libraries --- src/AzureClient/EntryPoint/EntryPointGenerator.cs | 10 ++++------ src/Core/Compiler/CompilerService.cs | 14 ++++++-------- src/Core/Compiler/ICompilerService.cs | 6 ++---- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/AzureClient/EntryPoint/EntryPointGenerator.cs b/src/AzureClient/EntryPoint/EntryPointGenerator.cs index 1f617ad0fe..dd7b721d18 100644 --- a/src/AzureClient/EntryPoint/EntryPointGenerator.cs +++ b/src/AzureClient/EntryPoint/EntryPointGenerator.cs @@ -103,15 +103,13 @@ public IEntryPoint Generate(string operationName, string? executionTarget, project.SourceFiles.ToArray(), compilerMetadata.WithAssemblies(workspaceAssemblies.ToArray()), logger, - Path.Combine(Workspace.CacheFolder, $"__entrypoint{project.CacheDllName}"), - executionTarget, - runtimeCapability)); + Path.Combine(Workspace.CacheFolder, $"__entrypoint{project.CacheDllName}"))); } catch (Exception e) { logger.LogError( "IQS004", - $"Error compiling project {project.ProjectFile} for execution target {executionTarget}: {e.Message}"); + $"Error compiling project {project.ProjectFile}: {e.Message}"); } } @@ -131,7 +129,7 @@ public IEntryPoint Generate(string operationName, string? executionTarget, { Logger?.LogDebug($"{snippets.Length} items found in snippets. Compiling."); SnippetsAssemblyInfo = Compiler.BuildSnippets( - snippets, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__snippets__.dll"), executionTarget, runtimeCapability); + snippets, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__snippets__.dll")); if (SnippetsAssemblyInfo == null || logger.HasErrors) { Logger?.LogError($"Error compiling snippets."); @@ -153,7 +151,7 @@ public IEntryPoint Generate(string operationName, string? executionTarget, operationInfo, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__.dll"), executionTarget, runtimeCapability); if (EntryPointAssemblyInfo == null || logger.HasErrors) { - Logger?.LogError($"Error compiling entry point for operation {operationName}."); + Logger?.LogError($"Error compiling entry point operation {operationName} for execution target {executionTarget}."); throw new CompilationErrorsException(logger.Errors.ToArray()); } diff --git a/src/Core/Compiler/CompilerService.cs b/src/Core/Compiler/CompilerService.cs index 2160e399f8..7c957f357f 100644 --- a/src/Core/Compiler/CompilerService.cs +++ b/src/Core/Compiler/CompilerService.cs @@ -171,8 +171,7 @@ public IEnumerable IdentifyElements(string source) /// Each snippet code is wrapped inside the 'SNIPPETS_NAMESPACE' namespace and processed as a file /// with the same name as the snippet id. /// - public AssemblyInfo? BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string? executionTarget = null, - RuntimeCapability? runtimeCapability = null) + public AssemblyInfo? BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName) { string openStatements = string.Join("", AutoOpenNamespaces.Select( entry => string.IsNullOrEmpty(entry.Value) @@ -192,7 +191,7 @@ string WrapInNamespace(Snippet s) => }; warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Add(code)); - var assembly = BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapability); + var assembly = BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false); warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Remove(code)); return assembly; @@ -201,18 +200,17 @@ string WrapInNamespace(Snippet s) => /// /// Builds the corresponding .net core assembly from the code in the given files. /// - public AssemblyInfo? BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string? executionTarget = null, - RuntimeCapability? runtimeCapability = null) + public AssemblyInfo? BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName) { var sources = ProjectManager.LoadSourceFiles(files, d => logger?.Log(d), ex => logger?.Log(ex)); - return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapability); + return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false); } /// /// Builds the corresponding .net core assembly from the Q# syntax tree. /// - private AssemblyInfo? BuildAssembly(ImmutableDictionary sources, CompilerMetadata metadata, QSharpLogger logger, string dllName, bool compileAsExecutable, string? executionTarget, - RuntimeCapability? runtimeCapability = null) + private AssemblyInfo? BuildAssembly(ImmutableDictionary sources, CompilerMetadata metadata, QSharpLogger logger, string dllName, + bool compileAsExecutable, string? executionTarget = null, RuntimeCapability? runtimeCapability = null) { logger.LogDebug($"Compiling the following Q# files: {string.Join(",", sources.Keys.Select(f => f.LocalPath))}"); diff --git a/src/Core/Compiler/ICompilerService.cs b/src/Core/Compiler/ICompilerService.cs index dc3229c71f..06e8142faf 100644 --- a/src/Core/Compiler/ICompilerService.cs +++ b/src/Core/Compiler/ICompilerService.cs @@ -31,14 +31,12 @@ AssemblyInfo BuildEntryPoint(OperationInfo operation, CompilerMetadata metadatas /// /// Builds the corresponding .net core assembly from the code in the given Q# Snippets. /// - AssemblyInfo BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string executionTarget = null, - RuntimeCapability runtimeCapabilities = null); + AssemblyInfo BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName); /// /// Builds the corresponding .net core assembly from the code in the given files. /// - AssemblyInfo BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string executionTarget = null, - RuntimeCapability runtimeCapability = null); + AssemblyInfo BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName); /// /// Returns the names of all declared callables and types.