Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
提交
  • Loading branch information
XiaoHeitu committed Mar 14, 2022
commit 96f10dce0dcfafd53f0b16609ce2d075b010c44f
25 changes: 6 additions & 19 deletions src/SmartCode.Generator/GeneratorProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ public async Task Build()
var dataSource = _pluginManager.Resolve<IDataSource>(_project.DataSource.Name);
await dataSource.InitData();

//foreach (var buildKV in _project.BuildTasks)
//{
// _logger.LogInformation($"-------- BuildTask:{buildKV.Key} Start! ---------");
// var output = buildKV.Value.Output;
// var buildContext = new BuildContext
// {
// PluginManager = _pluginManager,
// Project = _project,
// DataSource = dataSource,
// BuildKey = buildKV.Key,
// Build = buildKV.Value,
// Output = output?.Copy()
// };
// await _pluginManager.Resolve<IBuildTask>(buildKV.Value.Type).Build(buildContext);
// _logger.LogInformation($"-------- BuildTask:{buildKV.Key} End! ---------");
//}
BuildContext[] contexts = _project.BuildTasks.Select(d => new BuildContext
{
PluginManager = _pluginManager,
Expand All @@ -57,21 +41,24 @@ public async Task Build()
}).ToArray();
foreach (var context in contexts)
{
context.DependOn = contexts.Where(d => d.Build.DependOn.Contains(d.BuildKey)).ToArray();
context.DependOn = contexts.Where(d => context.Build.DependOn != null && context.Build.DependOn.Contains(d.BuildKey)).ToArray();
}

countdown.Reset();
foreach (var context in contexts)
{
context.BuildTask = Task.Factory.StartNew(this.BuildTask, null, TaskCreationOptions.LongRunning);
context.BuildTask = Task.Factory.StartNew(this.BuildTask, context, TaskCreationOptions.LongRunning);
}

countdown.Signal();

await Task.WhenAll(contexts.Select(d => d.BuildTask).ToArray());
}
private async void BuildTask(object obj)
{
countdown.Wait();
var context = (BuildContext)obj;
_logger.LogInformation($"-------- BuildTask:{context.BuildKey} Wait! ---------");
countdown.Wait();
//�ȴ���������
if (context.DependOn != null)
{
Expand Down
1 change: 0 additions & 1 deletion src/SmartCode/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void SetItem(string key, object item)
}

public IEnumerable<BuildContext> DependOn { get; set; }
public IEnumerable<BuildContext> Next { get; set; }
public Task BuildTask { get; set; }
}
}