Skip to content

Commit

Permalink
housekeeping: Use Pharmacist for platform code generation. (reactiveu…
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson authored Jun 14, 2019
1 parent a8d1439 commit e044cd1
Show file tree
Hide file tree
Showing 47 changed files with 30 additions and 2,809 deletions.
71 changes: 21 additions & 50 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

const string project = "ReactiveUI";

private const string PharmacistTool = "#tool dotnet:?package=Pharmacist&prerelease";

//////////////////////////////////////////////////////////////////////
// PROJECTS
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -52,21 +54,18 @@ if (IsRunningOnWindows())
});
}

var eventGenerators = new List<(string targetName, DirectoryPath destination)>
var eventGenerators = new List<(string[] targetNames, DirectoryPath destination)>
{
("android", MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
("ios", MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
("mac", MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
("tvos", MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
(new[] { "android", "ios", "mac", "tvos" }, MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
(new[] { "wpf" }, MakeAbsolute(Directory("src/ReactiveUI.Events.WPF/"))),
(new[] { "winforms" }, MakeAbsolute(Directory("src/ReactiveUI.Events.Winforms/"))),
};

if (IsRunningOnWindows())
{
eventGenerators.AddRange(new []
{
("wpf", MakeAbsolute(Directory("src/ReactiveUI.Events.WPF/"))),
("uwp", MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
("winforms", MakeAbsolute(Directory("src/ReactiveUI.Events.Winforms/"))),
(new[] { "uwp" }, MakeAbsolute(Directory("src/ReactiveUI.Events/"))),
});
}

Expand All @@ -90,58 +89,30 @@ ToolSettings.SetToolSettings(context: Context);
// TASKS
//////////////////////////////////////////////////////////////////////

Task("BuildEventBuilder")
.Does(() =>
{
BuildProject("./src/EventBuilder.sln", false);
});

Task("GenerateEvents")
.IsDependentOn("BuildEventBuilder")
.Does (() =>
.Does(() => RequireGlobalTool(PharmacistTool, () =>
{
var eventsArtifactDirectory = BuildParameters.ArtifactsDirectory.Combine("Events");
EnsureDirectoryExists(eventsArtifactDirectory);

var workingDirectory = MakeAbsolute(Directory("./src/EventBuilder/bin/Release/netcoreapp2.1"));
var eventBuilder = workingDirectory.CombineWithFilePath("EventBuilder.dll");

DirectoryPath referenceAssembliesPath = null;
if (IsRunningOnWindows())
{
referenceAssembliesPath = ToolSettings.VsLocation.Combine("./Common7/IDE/ReferenceAssemblies/Microsoft/Framework");
}
else
{
referenceAssembliesPath = Directory("⁨/Library⁩/Frameworks⁩/Libraries/⁨mono⁩");
}

foreach (var eventGenerator in eventGenerators)
{
var (platform, directory) = eventGenerator;

var settings = new DotNetCoreExecuteSettings
{
WorkingDirectory = workingDirectory,
};

var filename = String.Format("Events_{0}.cs", platform);
var output = directory.CombineWithFilePath(filename);

Information("Generating events for '{0}'", platform);
DotNetCoreExecute(
eventBuilder,
new ProcessArgumentBuilder()
.AppendSwitch("--platform","=", platform)
.AppendSwitchQuoted("--reference","=", referenceAssembliesPath.ToString())
.AppendSwitchQuoted("--output-path", "=", output.ToString()),
settings);

Information("The events have been written to '{0}'", output);
var (platforms, directory) = eventGenerator;

Information("Generating events for '{0}'", string.Join(", ", platforms));
StartProcess(Context.Tools.Resolve("Pharmacist*").ToString(), new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("generate-platform")
.AppendSwitch("-p", string.Join(",", platforms))
.AppendSwitch("-o", directory.ToString())
.AppendSwitch("--output-prefix", "Events_")
});

Information("The events have been written to '{0}'", directory);
}

CopyFiles(GetFiles("./src/ReactiveUI.**/Events_*.cs"), eventsArtifactDirectory);
});
}));

BuildParameters.Tasks.BuildTask.IsDependentOn("GenerateEvents");

Expand Down
25 changes: 0 additions & 25 deletions src/EventBuilder.sln

This file was deleted.

19 changes: 0 additions & 19 deletions src/EventBuilder/App.config

This file was deleted.

70 changes: 0 additions & 70 deletions src/EventBuilder/AutoPlatform.cs

This file was deleted.

111 changes: 0 additions & 111 deletions src/EventBuilder/Cecil/DelegateTemplateInformation.cs

This file was deleted.

Loading

0 comments on commit e044cd1

Please sign in to comment.