Skip to content
Open
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
376 changes: 273 additions & 103 deletions DistCL.Core/Compiler.cs

Large diffs are not rendered by default.

93 changes: 64 additions & 29 deletions DistCL.Core/Contracts/ICompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,10 @@ public interface ICompiler
bool IsReady();

[OperationContract]
[FaultContract(typeof(CompilerNotFoundFaultContract), Namespace = GeneralSettings.CompilerMessageNamespace)]
[FaultContract(typeof (CompilerNotFoundFaultContract), Namespace = GeneralSettings.CompilerMessageNamespace)]
CompileOutput Compile(CompileInput input);
}

[DataContract(Namespace = GeneralSettings.CompilerMessageNamespace)]
public class CompileStatus
{
public CompileStatus(bool success, int exitCode, CompileArtifactCookie[] cookies)
{
ExitCode = exitCode;
Success = success;
Cookies = cookies;
}

[DataMember]
public bool Success { get; private set; }

[DataMember]
public int ExitCode { get; private set; }

[DataMember]
public CompileArtifactCookie[] Cookies { get; private set; }
}

[MessageContract(WrapperNamespace = GeneralSettings.CompilerMessageNamespace)]
public class CompileInput : IStreamedMessage
{
Expand All @@ -53,6 +33,9 @@ public CompileInput(IStreamedMessage message)
Src = new ProxyStream(message);
}

[MessageHeader]
public string CompilationToken { get; set; }

[MessageHeader]
public string CompilerVersion { get; set; }

Expand Down Expand Up @@ -86,24 +69,28 @@ public long StreamLength
[MessageContract(WrapperNamespace = GeneralSettings.CompilerMessageNamespace)]
public class CompileOutput : IDisposable
{
private readonly CompileStatus _status;
private readonly CompileResult _result;
private Stream _resultData;

public CompileOutput(CompileStatus status, Stream resultData)
public CompileOutput(string compilationToken, string requiredFileName)
{
_result = new SourceFileRequest(compilationToken, requiredFileName);
}

public CompileOutput(CompileResult result, Stream resultData)
{
_status = status;
_result = result;
_resultData = resultData;
}

public CompileOutput(
bool success,
int exitCode,
IDictionary<CompileArtifactDescription, Stream> streams,
IEnumerable<CompileArtifactDescription> artifacts)
{
CompileArtifactCookie[] cookies;
_resultData = CompileResultHelper.Pack(streams, out cookies);

// TODO remove redundant collections copy
if (artifacts != null)
{
Expand All @@ -112,13 +99,13 @@ public CompileOutput(
cookies = list.ToArray();
}

_status = new CompileStatus(success, exitCode, cookies);
_result = new FinishedCompileResult(exitCode, cookies);
}

[MessageHeader]
public CompileStatus Status
public CompileResult Result
{
get { return _status; }
get { return _result; }
}

[MessageBodyMember]
Expand All @@ -136,4 +123,52 @@ public void Dispose()
}
}
}

[DataContract(Namespace = GeneralSettings.CompilerMessageNamespace)]
[KnownType(typeof(FinishedCompileResult))]
[KnownType(typeof(SourceFileRequest))]
public abstract class CompileResult
{
protected CompileResult(bool finished)
{
Finished = finished;
}

[DataMember]
public bool Finished { get; private set; }
}

[DataContract(Namespace = GeneralSettings.CompilerMessageNamespace)]
public class FinishedCompileResult : CompileResult
{
public FinishedCompileResult(int exitCode, CompileArtifactCookie[] cookies)
: base(true)
{
ExitCode = exitCode;
Cookies = cookies;
}

[DataMember]
public int ExitCode { get; private set; }

[DataMember]
public CompileArtifactCookie[] Cookies { get; private set; }
}

[DataContract(Namespace = GeneralSettings.CompilerMessageNamespace)]
public class SourceFileRequest : CompileResult
{
public SourceFileRequest(string compilationToken, string fileName)
: base(false)
{
CompilationToken = compilationToken;
FileName = fileName;
}

[DataMember]
public string FileName { get; private set; }

[DataMember]
public string CompilationToken { get; private set; }
}
}
4 changes: 2 additions & 2 deletions DistCL.Core/Contracts/ILocalCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public PreprocessToken(Guid guid, string accountName, DateTime requested, DateTi
[MessageContract(WrapperNamespace = GeneralSettings.LocalCompilerMessageNamespace)]
public class LocalCompileOutput : CompileOutput
{
public LocalCompileOutput(CompileStatus status, Stream resultData) : base(status, resultData)
public LocalCompileOutput(CompileResult result, Stream resultData) : base(result, resultData)
{
}

Expand All @@ -74,7 +74,7 @@ public LocalCompileOutput(
int exitCode,
IDictionary<CompileArtifactDescription, Stream> streams,
IEnumerable<CompileArtifactDescription> artifacts)
: base(success, exitCode, streams, artifacts)
: base(exitCode, streams, artifacts)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion DistCL.Core/DistCL.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<None Include="Service References\RemoteCompilerService\DistCL.RemoteCompilerService.CompileOutput.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
<None Include="Service References\RemoteCompilerService\DistCL.RemoteCompilerService.CompileStatus.datasource">
<None Include="Service References\RemoteCompilerService\DistCL.RemoteCompilerService.CompileResult.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
<None Include="Service References\RemoteCompilerService\DistCL.RemoteCompilerService.PreprocessToken.datasource">
Expand Down
19 changes: 13 additions & 6 deletions DistCL.Core/Proxies/AgentProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,20 @@ public CompileOutput Compile(CompileInput localInput)

RemoteCompilerService.CompileOutput remoteOutput = _compiler.Compile(remoteInput);

return
new CompileOutput(
new CompileStatus(
remoteOutput.Status.Success,
remoteOutput.Status.ExitCode,
remoteOutput.Status.Cookies),
if (remoteOutput.Result.Finished)
{
var finishedCompileResult = ((RemoteCompilerService.FinishedCompileResult) remoteOutput.Result);
return new CompileOutput(
new FinishedCompileResult(
finishedCompileResult.ExitCode,
finishedCompileResult.Cookies),
remoteOutput.ResultData);
}

var sourceFileRequest = ((RemoteCompilerService.SourceFileRequest) remoteOutput.Result);
return new CompileOutput(
new SourceFileRequest(sourceFileRequest.CompilationToken, sourceFileRequest.FileName),
remoteOutput.ResultData);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="CompileStatus" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>DistCL.RemoteCompilerService.CompileStatus, Service References.RemoteCompilerService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
<GenericObjectDataSource DisplayName="CompileResult" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>DistCL.RemoteCompilerService.CompileResult, Service References.RemoteCompilerService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
Loading