Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more big cleanup

  • Loading branch information...
commit 9a5a4e97aba0e4615666402e11a154abeea864fc 1 parent ad49f40
Lucas Meijer authored
View
18 DependencyGraph.cs
@@ -7,8 +7,8 @@ namespace cake
{
public class DependencyGraph
{
- readonly Dictionary<string, TargetGenerateInstructions> _graph = new Dictionary<string, TargetGenerateInstructions>();
- public Action<string, TargetGenerateInstructions> GenerateCallback = (s, i) => { };
+ readonly Dictionary<string, TargetGenerateSettings> _graph = new Dictionary<string, TargetGenerateSettings>();
+ public Action<string, TargetGenerateSettings> GenerateCallback = (s, i) => { };
private readonly BuildHistory _buildHistory;
public DependencyGraph() : this(new BuildHistory())
@@ -31,7 +31,7 @@ public void RequestTarget(string targetFile)
Generate(targetFile, instructions);
}
- private bool NeedToGenerate(string targetFile, TargetGenerateInstructions generateSettings)
+ private bool NeedToGenerate(string targetFile, TargetGenerateSettings generateSettings)
{
var recordOfLastBuild = _buildHistory.FindRecordFor(targetFile);
@@ -50,18 +50,18 @@ private bool NeedToGenerate(string targetFile, TargetGenerateInstructions genera
return generateSettings.InputFiles.Any(sourceFile => recordOfLastBuild.ModificationTimeOf(sourceFile) != File.GetLastWriteTimeUtc(sourceFile));
}
- private void Generate(string targetFile, TargetGenerateInstructions instructions)
+ private void Generate(string targetFile, TargetGenerateSettings settings)
{
- GenerateCallback(targetFile, instructions);
- instructions.Action.Invoke(targetFile, instructions);
+ GenerateCallback(targetFile, settings);
+ settings.Action.Invoke(targetFile, settings);
- var record = new GenerationRecord(targetFile, instructions, "");
+ var record = new GenerationRecord(targetFile, settings);
_buildHistory.AddRecord(record);
}
- public void RegisterTarget(string targetFile, TargetGenerateInstructions instructions)
+ public void RegisterTarget(string targetFile, TargetGenerateSettings settings)
{
- _graph.Add(targetFile,instructions);
+ _graph.Add(targetFile,settings);
}
}
}
View
6 GenerationRecord.cs
@@ -7,14 +7,12 @@ namespace cake
public class GenerationRecord
{
public string TargetFile { get; private set; }
- public TargetGenerateInstructions Settings { get; private set; }
- public string ActionHash { get; private set; }
+ public TargetGenerateSettings Settings { get; private set; }
private readonly Dictionary<string, DateTime> _modificationDates = new Dictionary<string, DateTime>();
- public GenerationRecord(string targetFile, TargetGenerateInstructions settings, string actionHash)
+ public GenerationRecord(string targetFile, TargetGenerateSettings settings)
{
- ActionHash = actionHash;
TargetFile = targetFile;
Settings = settings;
View
2  ITargetGeneratingAction.cs
@@ -2,7 +2,7 @@
{
public interface ITargetGeneratingAction
{
- void Invoke(string target, TargetGenerateInstructions instructions);
+ void Invoke(string target, TargetGenerateSettings settings);
string GetActionHash();
}
}
View
11 TargetGenerateInstructions.cs → TargetGenerateSettings.cs
@@ -3,18 +3,18 @@
namespace cake
{
- public class TargetGenerateInstructions
+ public class TargetGenerateSettings
{
public ITargetGeneratingAction Action;
public HashSet<string> InputFiles { get; private set; }
private string _actionHash;
- public TargetGenerateInstructions(ITargetGeneratingAction action, HashSet<string> inputFiles)
+ public TargetGenerateSettings(ITargetGeneratingAction action, IEnumerable<string> inputFiles)
{
Action = action;
_actionHash = action.GetActionHash();
- InputFiles = inputFiles;
+ InputFiles = new HashSet<string>(inputFiles);
}
//todo: figure out how to write a sane Equals
@@ -23,7 +23,7 @@ public override bool Equals(object obj)
if (obj == null)
return false;
- var other = obj as TargetGenerateInstructions;
+ var other = obj as TargetGenerateSettings;
if (other == null)
return false;
@@ -47,8 +47,5 @@ public override int GetHashCode()
{
return (InputFiles != null ? InputFiles.GetHashCode() : 0);
}
-
-
-
}
}
View
4 Tests/DifferentInputFiles.cs
@@ -33,9 +33,9 @@ public void WhenInputFilesChangeTargetGetsRebuilt()
Assert.AreEqual(2, invocationCount);
}
- private static TargetGenerateInstructions MakeInstructions(ITargetGeneratingAction action, params string[] inputFiles)
+ private static TargetGenerateSettings MakeInstructions(ITargetGeneratingAction action, params string[] inputFiles)
{
- return new TargetGenerateInstructions(action, new HashSet<string>(inputFiles));
+ return new TargetGenerateSettings(action, inputFiles);
}
}
}
View
8 Tests/SimpleAction.cs
@@ -4,18 +4,18 @@ namespace cake.Tests
{
class SimpleAction : ITargetGeneratingAction
{
- private readonly Action<string, TargetGenerateInstructions> _invoke;
+ private readonly Action<string, TargetGenerateSettings> _invoke;
private readonly string _actionHash;
- public SimpleAction(Action<string, TargetGenerateInstructions> invoke, string actionHash)
+ public SimpleAction(Action<string, TargetGenerateSettings> invoke, string actionHash)
{
_invoke = invoke;
_actionHash = actionHash;
}
- public void Invoke(string target, TargetGenerateInstructions instructions)
+ public void Invoke(string target, TargetGenerateSettings settings)
{
- _invoke(target, instructions);
+ _invoke(target, settings);
}
public string GetActionHash()
View
2  Tests/SimpleCopyDepGraph.cs
@@ -64,7 +64,7 @@ public void WillNotRegeneratesWhenTargetGotManuallyUpdated()
private void SetupSimpleCopyDepGraph()
{
var action = new SimpleAction((target, settings) => File.Copy(settings.InputFiles.Single(), target, true), "hash");
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions(action, new HashSet<string>(new[] {defaultSourceFile})));
+ _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(action, new[] {defaultSourceFile}));
}
}
View
11 Tests/TargetWithoutSources.cs
@@ -46,24 +46,17 @@ public void RegenerateWhenActionHashChanges()
bool invoked = false;
var action = new SimpleAction((t, s) => { invoked=true; }, "hash2");
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions(action, new HashSet<string>()));
+ _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(action, new string[0]));
_depGraph.RequestTarget(defaulttargetFile);
Assert.IsTrue(invoked);
}
-
-
-
private void SetupGraphWithOneTargetWithoutSources()
{
var simpleAction = new SimpleAction((t,s) => File.WriteAllText(t, "Hello"), "hash1");
-
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions(simpleAction, new HashSet<string>()));
+ _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(simpleAction, new string[0]));
}
-
-
-
}
}
View
2  cake.csproj
@@ -50,7 +50,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecursiveIncludeScanner.cs" />
- <Compile Include="TargetGenerateInstructions.cs" />
+ <Compile Include="TargetGenerateSettings.cs" />
<Compile Include="CCompilerTask.cs" />
<Compile Include="Tests\CCompilerTests.cs" />
<Compile Include="Tests\DependencyGraphTests.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.