提交 40aa31e9 编写于 作者: J Jared Parsons

Everything compiling again

上级 d00363d8
......@@ -127,6 +127,7 @@ Global
src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4
src\Test\Utilities\Shared\TestUtilities.projitems*{6ff42825-5464-4151-ac55-ed828168c192}*SharedItemsImports = 13
src\Test\Utilities\Shared\TestUtilities.projitems*{76c6f005-c89d-4348-bb4a-391898dbeb52}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{8ce3a581-2969-4864-a803-013e9d977c3a}*SharedItemsImports = 4
src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4
......
......@@ -44,6 +44,9 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs">
<Link>CoreClrAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -69,4 +72,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -35,6 +35,12 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopBuildClient.cs">
<Link>DesktopBuildClient.cs</Link>
</Compile>
......@@ -61,4 +67,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -10,7 +10,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BuildProtocol.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BuildClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleUtil.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NativeMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CompilerServerLogger.cs" />
......
......@@ -8,6 +8,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks.Hosting;
using Microsoft.Build.Utilities;
using Microsoft.CodeAnalysis.CommandLine;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -277,6 +278,8 @@ protected internal override void AddResponseFileCommands(CommandLineBuilderExten
#endregion
internal override RequestLanguage Language => RequestLanguage.CSharpCompile;
/// <summary>
/// The C# compiler (starting with Whidbey) supports assembly aliasing for references.
/// See spec at http://devdiv/spectool/Documents/Whidbey/VCSharp/Design%20Time/M3%20DCRs/DCR%20Assembly%20aliases.doc.
......
......@@ -31,6 +31,9 @@
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\Portable\InternalUtilities\CommandLineUtilities.cs">
<Link>CommandLineUtilities.cs</Link>
</Compile>
......@@ -69,5 +72,6 @@
<LastGenOutput>ErrorString.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="..\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
\ No newline at end of file
......@@ -11,6 +11,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CommandLine;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -23,6 +24,8 @@ public abstract class ManagedCompiler : ToolTask
private CancellationTokenSource _sharedCompileCts;
internal readonly PropertyDictionary _store = new PropertyDictionary();
internal abstract RequestLanguage Language { get; }
public ManagedCompiler()
{
TaskResources = ErrorString.ResourceManager;
......@@ -391,12 +394,11 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
if (!UseSharedCompilation ||
!string.IsNullOrEmpty(ToolPath) ||
!Utilities.IsCompilerServerSupported)
!BuildServerConnection.IsCompilerServerSupported)
{
return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
}
/* TODO: This needs to get fixed obviously
using (_sharedCompileCts = new CancellationTokenSource())
{
try
......@@ -416,14 +418,14 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
Log.LogMessage(ErrorString.UsingSharedCompilation, clientDir);
var workingDir = CurrentDirectoryToUse();
var buildPaths = new BuildPaths(
var buildPaths = new BuildPathsAlt(
clientDir: clientDir,
// MSBuild doesn't need the .NET SDK directory
sdkDir: null,
workingDir: workingDir,
tempDir: BuildClient.GetTempPath(workingDir));
tempDir: BuildServerConnection.GetTempPath(workingDir));
var responseTask = DesktopBuildClient.RunServerCompilation(
var responseTask = BuildServerConnection.RunServerCompilation(
Language,
GetArguments(commandLineCommands, responseFileCommands).ToList(),
buildPaths,
......@@ -456,12 +458,10 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand
ExitCode = -1;
}
}
*/
return ExitCode;
}
/// <summary>
/// Try to get the directory this assembly is in. Returns null if assembly
/// was in the GAC or DLL location can not be retrieved.
......@@ -572,7 +572,6 @@ private string LibDirectoryToUse()
[Output]
public new int ExitCode { get; private set; }
/*
/// <summary>
/// Handle a response from the server, reporting messages and returning
/// the appropriate exit code.
......@@ -582,7 +581,7 @@ private int HandleResponse(BuildResponse response, string pathToTool, string res
switch (response.Type)
{
case BuildResponse.ResponseType.MismatchedVersion:
LogErrorOutput(CommandLineParser.MismatchedVersionErrorText);
LogErrorOutput("Roslyn compiler server reports different protocol version than build task.");
return -1;
case BuildResponse.ResponseType.Completed:
......@@ -608,7 +607,6 @@ private int HandleResponse(BuildResponse response, string pathToTool, string res
throw new InvalidOperationException("Encountered unknown response type");
}
}
*/
private void LogErrorOutput(string output)
{
......
......@@ -15,17 +15,6 @@ namespace Microsoft.CodeAnalysis.BuildTasks
/// </summary>
internal static class Utilities
{
/// <summary>
/// False if the compiler server is not supported on this platform.
/// </summary>
internal static bool IsCompilerServerSupported => true;
/* TODO: fix this
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
DesktopBuildClient.GetRuntimeDirectoryOpt() != null &&
// Test that we can retrieve a valid pipe name
DesktopBuildClient.GetPipeNameForPathOpt("") != null;
*/
/// <summary>
/// Convert a task item metadata to bool. Throw an exception if the string is badly formed and can't
/// be converted.
......
......@@ -9,6 +9,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Build.Tasks.Hosting;
using Microsoft.CodeAnalysis.CommandLine;
namespace Microsoft.CodeAnalysis.BuildTasks
{
......@@ -34,6 +35,8 @@ public class Vbc : ManagedCompiler
private bool _isDoneOutputtingErrorMessage;
private int _numberOfLinesInErrorMessage;
internal override RequestLanguage Language => RequestLanguage.VisualBasicCompile;
#region Properties
// Please keep these alphabetized. These are the parameters specific to Vbc. The
......
......@@ -80,13 +80,13 @@ protected override Task<Stream> ConnectForShutdownAsync(string pipeName, int tim
protected override string GetDefaultPipeName()
{
var clientDirectory = AppDomain.CurrentDomain.BaseDirectory;
return DesktopBuildClient.GetPipeNameForPathOpt(clientDirectory);
return BuildServerConnection.GetPipeNameForPathOpt(clientDirectory);
}
protected override bool? WasServerRunning(string pipeName)
{
string mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
return DesktopBuildClient.WasServerMutexOpen(mutexName);
string mutexName = BuildServerConnection.GetServerMutexName(pipeName);
return BuildServerConnection.WasServerMutexOpen(mutexName);
}
protected override int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan? keepAlive, CancellationToken cancellationToken)
......@@ -94,7 +94,7 @@ protected override int RunServerCore(string pipeName, IClientConnectionHost conn
// Grab the server mutex to prevent multiple servers from starting with the same
// pipename and consuming excess resources. If someone else holds the mutex
// exit immediately with a non-zero exit code
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: mutexName,
......
......@@ -45,6 +45,12 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopAnalyzerAssemblyLoader.cs">
<Link>DesktopAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -77,4 +83,4 @@
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\ServerShared\ServerShared.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -301,7 +301,7 @@ public void ClientExceptionShouldBeginShutdown()
public void MutexStopsServerStarting()
{
var pipeName = Guid.NewGuid().ToString("N");
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var mutex = new Mutex(initiallyOwned: true,
......@@ -326,7 +326,7 @@ public void MutexStopsServerStarting()
public void MutexAcquiredWhenRunningServer()
{
var pipeName = Guid.NewGuid().ToString("N");
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
var host = new Mock<IClientConnectionHost>(MockBehavior.Strict);
host
.Setup(x => x.CreateListenTask(It.IsAny<CancellationToken>()))
......
......@@ -62,7 +62,7 @@ public bool TryConnectToNamedPipeWithSpinWait(int timeoutMs, CancellationToken c
{
using (var pipeStream = new NamedPipeClientStream(".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous))
{
return TryConnectToNamedPipeWithSpinWait(pipeStream, timeoutMs, cancellationToken);
return BuildServerConnection.TryConnectToNamedPipeWithSpinWait(pipeStream, timeoutMs, cancellationToken);
}
}
}
......@@ -127,7 +127,7 @@ public void ConnectToServerFails()
// compilation.
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: DesktopBuildClient.GetServerMutexName(_pipeName),
name: BuildServerConnection.GetServerMutexName(_pipeName),
createdNew: out holdsMutex))
{
Assert.True(holdsMutex);
......@@ -371,10 +371,10 @@ public class MiscTest
public void GetBasePipeNameSlashes()
{
var path = string.Format(@"q:{0}the{0}path", Path.DirectorySeparatorChar);
var name = DesktopBuildClient.GetBasePipeName(path);
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path));
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path + Path.DirectorySeparatorChar));
Assert.Equal(name, DesktopBuildClient.GetBasePipeName(path + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar));
var name = BuildServerConnection.GetBasePipeName(path);
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path));
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path + Path.DirectorySeparatorChar));
Assert.Equal(name, BuildServerConnection.GetBasePipeName(path + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar));
}
}
}
......
......@@ -95,7 +95,7 @@ internal static BuildPaths CreateBuildPaths(string workingDir, string tempDir)
var serverStatsSource = new TaskCompletionSource<ServerStats>();
var serverListenSource = new TaskCompletionSource<bool>();
var cts = new CancellationTokenSource();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
var thread = new Thread(_ =>
{
var listener = new TestableDiagnosticListener();
......@@ -122,7 +122,7 @@ internal static BuildPaths CreateBuildPaths(string workingDir, string tempDir)
// The contract of this function is that it will return once the server has started. Spin here until
// we can verify the server has started or simply failed to start.
while (DesktopBuildClient.WasServerMutexOpen(mutexName) != true && thread.IsAlive)
while (BuildServerConnection.WasServerMutexOpen(mutexName) != true && thread.IsAlive)
{
Thread.Yield();
}
......@@ -143,7 +143,7 @@ internal static ServerData CreateServerFailsConnection(string pipeName = null)
{
var thread = new Thread(_ =>
{
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
using (var serverMutex = new Mutex(initiallyOwned: true,
name: mutexName,
......
......@@ -55,7 +55,7 @@ public async Task NoServerConnection()
using (var doneMre = new ManualResetEvent(initialState: false))
{
var pipeName = Guid.NewGuid().ToString();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool created = false;
bool connected = false;
......@@ -104,7 +104,7 @@ public async Task ServerShutdownsDuringProcessing()
using (var doneMre = new ManualResetEvent(initialState: false))
{
var pipeName = Guid.NewGuid().ToString();
var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool created = false;
bool connected = false;
......
......@@ -207,46 +207,5 @@ private static IEnumerable<string> GetCommandLineWindows(IEnumerable<string> arg
// The first argument will be the executable name hence we skip it.
return CommandLineParser.SplitCommandLineIntoArguments(commandLine, removeHashComments: false).Skip(1);
}
/// <summary>
/// Gets the value of the temporary path for the current environment assuming the working directory
/// is <paramref name="workingDir"/>. This function must emulate <see cref="Path.GetTempPath"/> as
/// closely as possible.
/// </summary>
public static string GetTempPath(string workingDir)
{
var tmp = Environment.GetEnvironmentVariable("TMP");
if (Path.IsPathRooted(tmp))
{
return tmp;
}
var temp = Environment.GetEnvironmentVariable("TEMP");
if (Path.IsPathRooted(temp))
{
return temp;
}
if (!string.IsNullOrEmpty(workingDir))
{
if (!string.IsNullOrEmpty(tmp))
{
return Path.Combine(workingDir, tmp);
}
if (!string.IsNullOrEmpty(temp))
{
return Path.Combine(workingDir, temp);
}
}
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
if (Path.IsPathRooted(userProfile))
{
return userProfile;
}
return Environment.GetEnvironmentVariable("SYSTEMROOT");
}
}
}
此差异已折叠。
......@@ -32,7 +32,7 @@ internal static int Run(IEnumerable<string> arguments, RequestLanguage language,
var client = new CoreClrBuildClient(language, compileFunc);
var clientDir = AppContext.BaseDirectory;
var workingDir = Directory.GetCurrentDirectory();
var tempDir = GetTempPath(workingDir);
var tempDir = Path.GetTempPath();
var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: null, tempDir: tempDir);
return client.RunCompilation(arguments, buildPaths).ExitCode;
}
......
......@@ -44,6 +44,9 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs">
<Link>CoreClrAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -69,4 +72,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
......@@ -35,6 +35,12 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link>
</Compile>
<Compile Include="..\..\Shared\BuildServerConnection.cs">
<Link>BuildServerConnection.cs</Link>
</Compile>
<Compile Include="..\..\Shared\DesktopBuildClient.cs">
<Link>DesktopBuildClient.cs</Link>
</Compile>
......@@ -61,4 +67,4 @@
</ItemGroup>
<Import Project="..\..\Core\CommandLine\CommandLine.projitems" Label="Shared" />
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</Project>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册