Skip to content

Commit

Permalink
add installer
Browse files Browse the repository at this point in the history
  • Loading branch information
inorton committed Mar 27, 2014
1 parent 7b38482 commit 88732ce
Show file tree
Hide file tree
Showing 6 changed files with 5,867 additions and 9 deletions.
54 changes: 54 additions & 0 deletions CClash/CacheSessionContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CClash {
public class CacheSessionContext
{
public ICompilerCache Cache { get; set; }
public Compiler Compiler { get; set; }
public StringBuilder StdOutput { get; set; }
public StringBuilder StdError { get; set; }
DateTime OperationStart { get; set; }

public virtual bool IsSupported(IEnumerable<string> args) {
OperationStart = DateTime.Now;
if (FileUtils.Exists(Compiler.CompilerExe))
{
var rv = Compiler.ProcessArguments(args.ToArray());
if (!rv) {
Logging.Emit("args not supported {0}", Cache.GetType().Name);
}
return rv;
}
throw new FileNotFoundException(Compiler.CompilerExe);
}


public void CopyOutputFiles(DataHash hc)
{
try {
Cache.CopyFile(Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Object), Compiler.ObjectTarget);
if (Compiler.GeneratePdb)
Cache.CopyFile(Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Pdb), Compiler.PdbFile);
} catch (Exception e) {
Logging.Error("{0}", e);
throw;
}
}

public void CopyStdio(DataHash hc)
{
var stderrfile = Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Stderr);
var stdoutfile = Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Stdout);

StdOutput.Clear();
StdError.Clear();
StdOutput.Append(File.ReadAllText(stdoutfile));
StdError.Append(File.ReadAllText(stderrfile));
}
}
}
20 changes: 11 additions & 9 deletions CClash/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ public static int Main(string[] args)
var compiler = Compiler.Find();
if (Settings.ServiceMode)
{
var cc = new CClashServerClient(Settings.CacheDirectory);

if (args.Contains("--stop"))
{
cc.Transact(new CClashRequest() { cmd = Command.Quit });
}
else
{
Console.Out.WriteLine(cc.GetStats(compiler));
for (int i = 0; i < 3; i++ ) {
try {
var cc = new CClashServerClient(Settings.CacheDirectory);
if (args.Contains("--stop")) {
cc.Transact(new CClashRequest() { cmd = Command.Quit });
} else {
Console.Out.WriteLine(cc.GetStats(compiler));
}
} catch (CClashWarningException) {
System.Threading.Thread.Sleep(2000);
}
}
}
else
Expand Down
Loading

0 comments on commit 88732ce

Please sign in to comment.