2016-01-14 07:42:16 +03:00
|
|
|
#addin "Cake.Xamarin"
|
|
|
|
#addin "Cake.XCode"
|
2016-02-24 22:10:20 +03:00
|
|
|
#addin "Cake.FileHelpers"
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-02-24 22:10:20 +03:00
|
|
|
using System.Text.RegularExpressions;
|
2016-01-14 07:42:16 +03:00
|
|
|
using System.Xml;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var TARGET = Argument ("t", Argument ("target", Argument ("Target", "Default")));
|
|
|
|
|
2016-06-04 11:11:26 +03:00
|
|
|
var NuGetSources = new [] { "https://www.nuget.org/api/v2/", "https://www.myget.org/F/xamprojectci/api/v2" };
|
2016-02-23 00:14:48 +03:00
|
|
|
var NugetToolPath = GetToolPath ("../nuget.exe");
|
|
|
|
var XamarinComponentToolPath = GetToolPath ("../xamarin-component.exe");
|
|
|
|
var CakeToolPath = GetToolPath ("Cake.exe");
|
|
|
|
var NUnitConsoleToolPath = GetToolPath ("../NUnit.Console/tools/nunit3-console.exe");
|
|
|
|
var GenApiToolPath = GetToolPath ("../genapi.exe");
|
2016-05-05 04:24:31 +03:00
|
|
|
var MDocPath = GetMDocPath ();
|
2016-02-23 00:14:48 +03:00
|
|
|
|
2016-05-06 18:39:38 +03:00
|
|
|
DirectoryPath ROOT_PATH = MakeAbsolute(Directory("."));
|
2016-02-23 00:14:48 +03:00
|
|
|
DirectoryPath DEPOT_PATH = MakeAbsolute(ROOT_PATH.Combine("depot_tools"));
|
|
|
|
DirectoryPath SKIA_PATH = MakeAbsolute(ROOT_PATH.Combine("skia"));
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TOOLS & FUNCTIONS - the bits to make it all work
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
var SetEnvironmentVariable = new Action<string, string> ((name, value) => {
|
2016-04-15 01:21:56 +03:00
|
|
|
Information ("Setting Environment Variable {0} to {1}", name, value);
|
2016-02-23 00:14:48 +03:00
|
|
|
Environment.SetEnvironmentVariable (name, value, EnvironmentVariableTarget.Process);
|
|
|
|
});
|
|
|
|
var AppendEnvironmentVariable = new Action<string, string> ((name, value) => {
|
|
|
|
var old = EnvironmentVariable (name);
|
2016-04-15 01:21:56 +03:00
|
|
|
var sep = IsRunningOnWindows () ? ';' : ':';
|
|
|
|
|
|
|
|
if (!old.ToUpper ().Split (sep).Contains (value.ToUpper ())) {
|
|
|
|
Information ("Adding {0} to Environment Variable {1}", value, name);
|
|
|
|
value += sep + old;
|
|
|
|
SetEnvironmentVariable (name, value);
|
|
|
|
}
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
|
|
|
void ListEnvironmentVariables ()
|
|
|
|
{
|
|
|
|
Information ("Environment Variables:");
|
|
|
|
foreach (var envVar in EnvironmentVariables ()) {
|
|
|
|
Information ("\tKey: {0}\tValue: \"{1}\"", envVar.Key, envVar.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FilePath GetToolPath (FilePath toolPath)
|
|
|
|
{
|
|
|
|
var appRoot = Context.Environment.GetApplicationRoot ();
|
|
|
|
var appRootExe = appRoot.CombineWithFilePath (toolPath);
|
|
|
|
if (FileExists (appRootExe))
|
|
|
|
return appRootExe;
|
|
|
|
throw new FileNotFoundException ("Unable to find tool: " + appRootExe);
|
|
|
|
}
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-05-05 04:24:31 +03:00
|
|
|
FilePath GetMDocPath ()
|
|
|
|
{
|
|
|
|
FilePath mdocPath;
|
|
|
|
if (IsRunningOnUnix ()) {
|
|
|
|
mdocPath = "/Library/Frameworks/Mono.framework/Versions/Current/bin/mdoc";
|
|
|
|
} else {
|
|
|
|
DirectoryPath progFiles = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
|
|
|
|
mdocPath = progFiles.CombineWithFilePath ("Mono/bin/mdoc.bat");
|
|
|
|
}
|
|
|
|
if (!FileExists (mdocPath)) {
|
|
|
|
mdocPath = "mdoc";
|
|
|
|
}
|
|
|
|
return mdocPath;
|
|
|
|
}
|
|
|
|
|
2016-02-23 03:31:17 +03:00
|
|
|
var RunNuGetRestore = new Action<FilePath> ((solution) =>
|
2016-02-23 01:18:12 +03:00
|
|
|
{
|
|
|
|
NuGetRestore (solution, new NuGetRestoreSettings {
|
|
|
|
ToolPath = NugetToolPath
|
|
|
|
});
|
2016-02-23 03:31:17 +03:00
|
|
|
});
|
2016-02-23 01:18:12 +03:00
|
|
|
|
2016-04-15 01:21:56 +03:00
|
|
|
var RunGyp = new Action<string, string> ((defines, generators) =>
|
2016-02-23 00:14:48 +03:00
|
|
|
{
|
2016-04-15 01:21:56 +03:00
|
|
|
SetEnvironmentVariable ("GYP_GENERATORS", generators);
|
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", defines);
|
|
|
|
|
2016-02-05 00:07:32 +03:00
|
|
|
Information ("Running 'sync-and-gyp'...");
|
|
|
|
Information ("\tGYP_GENERATORS = " + EnvironmentVariable ("GYP_GENERATORS"));
|
|
|
|
Information ("\tGYP_DEFINES = " + EnvironmentVariable ("GYP_DEFINES"));
|
|
|
|
|
2016-04-15 01:21:56 +03:00
|
|
|
var result = StartProcess ("python", new ProcessSettings {
|
2016-01-15 00:41:16 +03:00
|
|
|
Arguments = SKIA_PATH.CombineWithFilePath("bin/sync-and-gyp").FullPath,
|
2016-01-14 07:42:16 +03:00
|
|
|
WorkingDirectory = SKIA_PATH.FullPath,
|
|
|
|
});
|
2016-04-15 01:21:56 +03:00
|
|
|
if (result != 0) {
|
|
|
|
throw new Exception ("sync-and-gyp failed with error: " + result);
|
|
|
|
}
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var RunInstallNameTool = new Action<DirectoryPath, string, string, FilePath> ((directory, oldName, newName, library) =>
|
|
|
|
{
|
2016-02-23 13:57:08 +03:00
|
|
|
if (!IsRunningOnUnix ()) {
|
|
|
|
throw new InvalidOperationException ("install_name_tool is only available on Unix.");
|
|
|
|
}
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
StartProcess ("install_name_tool", new ProcessSettings {
|
|
|
|
Arguments = string.Format("-change {0} {1} \"{2}\"", oldName, newName, library),
|
|
|
|
WorkingDirectory = directory,
|
|
|
|
});
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
2016-02-23 00:14:48 +03:00
|
|
|
|
|
|
|
var RunLipo = new Action<DirectoryPath, FilePath, FilePath[]> ((directory, output, inputs) =>
|
|
|
|
{
|
2016-02-23 13:57:08 +03:00
|
|
|
if (!IsRunningOnUnix ()) {
|
|
|
|
throw new InvalidOperationException ("lipo is only available on Unix.");
|
|
|
|
}
|
|
|
|
|
2016-02-23 03:31:17 +03:00
|
|
|
var dir = directory.CombineWithFilePath (output).GetDirectory ();
|
|
|
|
if (!DirectoryExists (dir)) {
|
|
|
|
CreateDirectory (dir);
|
|
|
|
}
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var inputString = string.Join(" ", inputs.Select (i => string.Format ("\"{0}\"", i)));
|
|
|
|
StartProcess ("lipo", new ProcessSettings {
|
|
|
|
Arguments = string.Format("-create -output \"{0}\" {1}", output, inputString),
|
|
|
|
WorkingDirectory = directory,
|
|
|
|
});
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var PackageNuGet = new Action<FilePath, DirectoryPath> ((nuspecPath, outputPath) =>
|
|
|
|
{
|
|
|
|
if (!DirectoryExists (outputPath)) {
|
|
|
|
CreateDirectory (outputPath);
|
|
|
|
}
|
2016-02-04 22:46:42 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
NuGetPack (nuspecPath, new NuGetPackSettings {
|
|
|
|
Verbosity = NuGetVerbosity.Detailed,
|
|
|
|
OutputDirectory = outputPath,
|
2016-05-12 02:05:57 +03:00
|
|
|
BasePath = "./",
|
2016-02-23 00:14:48 +03:00
|
|
|
ToolPath = NugetToolPath
|
|
|
|
});
|
|
|
|
});
|
2016-01-19 01:35:35 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var RunTests = new Action<FilePath> ((testAssembly) =>
|
2016-02-02 17:39:03 +03:00
|
|
|
{
|
2016-02-23 00:14:48 +03:00
|
|
|
var dir = testAssembly.GetDirectory ();
|
|
|
|
var result = StartProcess (NUnitConsoleToolPath, new ProcessSettings {
|
|
|
|
Arguments = string.Format ("\"{0}\" --work=\"{1}\"", testAssembly, dir),
|
|
|
|
});
|
|
|
|
|
|
|
|
if (result != 0) {
|
|
|
|
throw new Exception ("NUnit test failed with error: " + result);
|
2016-02-02 17:39:03 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-23 13:57:08 +03:00
|
|
|
var RunMdocUpdate = new Action<FilePath, DirectoryPath> ((assembly, docsRoot) =>
|
|
|
|
{
|
2016-05-05 04:24:31 +03:00
|
|
|
StartProcess (MDocPath, new ProcessSettings {
|
2016-05-14 02:12:32 +03:00
|
|
|
Arguments = string.Format ("update --delete --out=\"{0}\" \"{1}\"", docsRoot, assembly),
|
2016-02-23 13:57:08 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-05-05 04:24:31 +03:00
|
|
|
var RunMdocMSXml = new Action<DirectoryPath, FilePath> ((docsRoot, output) =>
|
|
|
|
{
|
|
|
|
StartProcess (MDocPath, new ProcessSettings {
|
|
|
|
Arguments = string.Format ("export-msxdoc --out=\"{0}\" \"{1}\"", output, docsRoot),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var RunMdocAssemble = new Action<DirectoryPath, FilePath> ((docsRoot, output) =>
|
|
|
|
{
|
|
|
|
StartProcess (MDocPath, new ProcessSettings {
|
|
|
|
Arguments = string.Format ("assemble --out=\"{0}\" \"{1}\"", output, docsRoot),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-02-24 22:10:20 +03:00
|
|
|
var ProcessSolutionProjects = new Action<FilePath, Action<string, FilePath>> ((solutionFilePath, process) => {
|
|
|
|
var solutionFile = MakeAbsolute (solutionFilePath).FullPath;
|
|
|
|
foreach (var line in FileReadLines (solutionFile)) {
|
|
|
|
var match = Regex.Match (line, @"Project\(""(?<type>.*)""\) = ""(?<name>.*)"", ""(?<path>.*)"", "".*""");
|
|
|
|
if (match.Success && match.Groups ["type"].Value == "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") {
|
|
|
|
var path = match.Groups["path"].Value;
|
|
|
|
var projectFilePath = MakeAbsolute (solutionFilePath.GetDirectory ().CombineWithFilePath (path));
|
|
|
|
Information ("Processing project file: " + projectFilePath);
|
|
|
|
process (match.Groups["name"].Value, projectFilePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-15 01:21:56 +03:00
|
|
|
var MSBuildNS = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003";
|
|
|
|
|
|
|
|
var SetXValue = new Action<XElement, string, string> ((root, element, value) => {
|
|
|
|
var node = root.Element (MSBuildNS + element);
|
|
|
|
if (node == null)
|
|
|
|
root.Add (new XElement (MSBuildNS + element, value));
|
|
|
|
else
|
|
|
|
node.Value = value;
|
|
|
|
});
|
|
|
|
var AddXValue = new Action<XElement, string, string> ((root, element, value) => {
|
|
|
|
var node = root.Element (MSBuildNS + element);
|
|
|
|
if (node == null)
|
|
|
|
root.Add (new XElement (MSBuildNS + element, value));
|
2016-06-03 15:55:39 +03:00
|
|
|
else if (!node.Value.Contains (value))
|
2016-04-15 01:21:56 +03:00
|
|
|
node.Value += value;
|
|
|
|
});
|
2016-06-03 15:55:39 +03:00
|
|
|
var RemoveXValue = new Action<XElement, string, string> ((root, element, value) => {
|
|
|
|
var node = root.Element (MSBuildNS + element);
|
|
|
|
if (node != null)
|
|
|
|
node.Value = node.Value.Replace (value, string.Empty);
|
|
|
|
});
|
2016-04-15 01:21:56 +03:00
|
|
|
var SetXValues = new Action<XElement, string[], string, string> ((root, parents, element, value) => {
|
|
|
|
IEnumerable<XElement> nodes = new [] { root };
|
|
|
|
foreach (var p in parents) {
|
|
|
|
nodes = nodes.Elements (MSBuildNS + p);
|
|
|
|
}
|
|
|
|
foreach (var n in nodes) {
|
|
|
|
SetXValue (n, element, value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var AddXValues = new Action<XElement, string[], string, string> ((root, parents, element, value) => {
|
|
|
|
IEnumerable<XElement> nodes = new [] { root };
|
|
|
|
foreach (var p in parents) {
|
|
|
|
nodes = nodes.Elements (MSBuildNS + p);
|
|
|
|
}
|
|
|
|
foreach (var n in nodes) {
|
|
|
|
AddXValue (n, element, value);
|
|
|
|
}
|
|
|
|
});
|
2016-06-03 15:55:39 +03:00
|
|
|
var RemoveXValues = new Action<XElement, string[], string, string> ((root, parents, element, value) => {
|
|
|
|
IEnumerable<XElement> nodes = new [] { root };
|
|
|
|
foreach (var p in parents) {
|
|
|
|
nodes = nodes.Elements (MSBuildNS + p);
|
|
|
|
}
|
|
|
|
foreach (var n in nodes) {
|
|
|
|
RemoveXValue (n, element, value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var RemoveFileReference = new Action<XElement, string> ((root, filename) => {
|
|
|
|
var element = root
|
|
|
|
.Elements (MSBuildNS + "ItemGroup")
|
|
|
|
.Elements (MSBuildNS + "ClCompile")
|
|
|
|
.Where (e => e.Attribute ("Include") != null)
|
|
|
|
.Where (e => e.Attribute ("Include").Value.Contains (filename))
|
|
|
|
.FirstOrDefault ();
|
|
|
|
if (element != null) {
|
|
|
|
element.Remove ();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var AddFileReference = new Action<XElement, string> ((root, filename) => {
|
|
|
|
var element = root
|
|
|
|
.Elements (MSBuildNS + "ItemGroup")
|
|
|
|
.Elements (MSBuildNS + "ClCompile")
|
|
|
|
.Where (e => e.Attribute ("Include") != null)
|
|
|
|
.Where (e => e.Attribute ("Include").Value.Contains (filename))
|
|
|
|
.FirstOrDefault ();
|
|
|
|
if (element == null) {
|
|
|
|
root.Elements (MSBuildNS + "ItemGroup")
|
|
|
|
.Elements (MSBuildNS + "ClCompile")
|
|
|
|
.Last ()
|
|
|
|
.Parent
|
|
|
|
.Add (new XElement (MSBuildNS + "ClCompile", new XAttribute ("Include", filename)));
|
|
|
|
}
|
|
|
|
});
|
2016-04-15 01:21:56 +03:00
|
|
|
|
2016-05-05 04:24:31 +03:00
|
|
|
// find a better place for this / or fix the path issue
|
|
|
|
var VisualStudioPathFixup = new Action (() => {
|
|
|
|
var props = SKIA_PATH.CombineWithFilePath ("out/gyp/libjpeg-turbo.props").FullPath;
|
|
|
|
var xdoc = XDocument.Load (props);
|
|
|
|
var temp = xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "ItemDefinitionGroup")
|
|
|
|
.Elements (MSBuildNS + "assemble")
|
|
|
|
.Elements (MSBuildNS + "CommandLineTemplate")
|
|
|
|
.Single ();
|
|
|
|
var newInclude = SKIA_PATH.Combine ("third_party/externals/libjpeg-turbo/win/").FullPath;
|
|
|
|
if (!temp.Value.Contains (newInclude)) {
|
|
|
|
temp.Value += " \"-I" + newInclude + "\"";
|
|
|
|
xdoc.Save (props);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// EXTERNALS - the native C and C++ libraries
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-01-15 03:18:32 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
// this builds all the externals
|
2016-01-14 07:42:16 +03:00
|
|
|
Task ("externals")
|
2016-02-23 00:14:48 +03:00
|
|
|
.IsDependentOn ("externals-genapi")
|
|
|
|
.IsDependentOn ("externals-native")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
});
|
|
|
|
// this builds the native C and C++ externals
|
|
|
|
Task ("externals-native")
|
2016-04-15 01:21:56 +03:00
|
|
|
.IsDependentOn ("externals-uwp")
|
2016-01-14 07:42:16 +03:00
|
|
|
.IsDependentOn ("externals-windows")
|
|
|
|
.IsDependentOn ("externals-osx")
|
|
|
|
.IsDependentOn ("externals-ios")
|
|
|
|
.IsDependentOn ("externals-android")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-02 17:39:03 +03:00
|
|
|
// copy all the native files into the output
|
|
|
|
CopyDirectory ("./native-builds/lib/", "./output/native/");
|
2016-02-23 03:31:17 +03:00
|
|
|
|
|
|
|
// copy the non-embedded native files into the output
|
|
|
|
if (IsRunningOnWindows ()) {
|
2016-02-23 13:57:08 +03:00
|
|
|
if (!DirectoryExists ("./output/windows/x86")) CreateDirectory ("./output/windows/x86");
|
|
|
|
if (!DirectoryExists ("./output/windows/x64")) CreateDirectory ("./output/windows/x64");
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("./native-builds/lib/windows/x86/libSkiaSharp.dll", "./output/windows/x86/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/windows/x86/libSkiaSharp.pdb", "./output/windows/x86/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/windows/x64/libSkiaSharp.dll", "./output/windows/x64/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/windows/x64/libSkiaSharp.pdb", "./output/windows/x64/");
|
2016-05-06 18:39:38 +03:00
|
|
|
if (!DirectoryExists ("./output/uwp/x86")) CreateDirectory ("./output/uwp/x86");
|
|
|
|
if (!DirectoryExists ("./output/uwp/x64")) CreateDirectory ("./output/uwp/x64");
|
|
|
|
if (!DirectoryExists ("./output/uwp/arm")) CreateDirectory ("./output/uwp/arm");
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/x86/libSkiaSharp.dll", "./output/uwp/x86/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/x86/libSkiaSharp.pdb", "./output/uwp/x86/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/x64/libSkiaSharp.dll", "./output/uwp/x64/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/x64/libSkiaSharp.pdb", "./output/uwp/x64/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/arm/libSkiaSharp.dll", "./output/uwp/arm/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/uwp/arm/libSkiaSharp.pdb", "./output/uwp/arm/");
|
2016-02-23 03:31:17 +03:00
|
|
|
}
|
|
|
|
if (IsRunningOnUnix ()) {
|
2016-02-23 13:57:08 +03:00
|
|
|
if (!DirectoryExists ("./output/osx")) CreateDirectory ("./output/osx");
|
|
|
|
if (!DirectoryExists ("./output/mac")) CreateDirectory ("./output/mac");
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("./native-builds/lib/osx/libSkiaSharp.dylib", "./output/osx/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/osx/libSkiaSharp.dylib", "./output/mac/");
|
2016-02-23 03:31:17 +03:00
|
|
|
}
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
|
|
|
// this builds the managed PCL external
|
|
|
|
Task ("externals-genapi")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-02 17:39:03 +03:00
|
|
|
// build the dummy project
|
2016-02-23 00:14:48 +03:00
|
|
|
DotNetBuild ("binding/SkiaSharp.Generic.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "\"Any CPU\"" };
|
|
|
|
});
|
2016-01-19 00:30:36 +03:00
|
|
|
|
2016-02-02 17:39:03 +03:00
|
|
|
// generate the PCL
|
2016-01-19 00:30:36 +03:00
|
|
|
FilePath input = "binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll";
|
|
|
|
var libPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/,.";
|
2016-02-23 00:14:48 +03:00
|
|
|
StartProcess (GenApiToolPath, new ProcessSettings {
|
2016-02-02 03:33:43 +03:00
|
|
|
Arguments = string.Format("-libPath:{2} -out \"{0}\" \"{1}\"", input.GetFilename () + ".cs", input.GetFilename (), libPath),
|
|
|
|
WorkingDirectory = input.GetDirectory ().FullPath,
|
|
|
|
});
|
2016-01-19 00:30:36 +03:00
|
|
|
CopyFile ("binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll.cs", "binding/SkiaSharp.Portable/SkiaPortable.cs");
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
2016-04-15 01:21:56 +03:00
|
|
|
// this builds the native C and C++ externals for Windows
|
|
|
|
Task ("externals-windows")
|
|
|
|
.WithCriteria (IsRunningOnWindows ())
|
|
|
|
.WithCriteria (
|
2016-05-14 02:12:32 +03:00
|
|
|
!FileExists ("native-builds/lib/windows/x86/libSkiaSharp.dll") ||
|
|
|
|
!FileExists ("native-builds/lib/windows/x64/libSkiaSharp.dll"))
|
2016-04-15 01:21:56 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-24 22:10:20 +03:00
|
|
|
var buildArch = new Action<string, string, string> ((platform, skiaArch, dir) => {
|
2016-04-15 01:21:56 +03:00
|
|
|
RunGyp ("skia_arch_type='" + skiaArch + "'", "ninja,msvs");
|
|
|
|
VisualStudioPathFixup ();
|
2016-05-14 02:12:32 +03:00
|
|
|
DotNetBuild ("native-builds/libSkiaSharp_windows/libSkiaSharp_" + dir + ".sln", c => {
|
2016-02-24 23:43:48 +03:00
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { platform };
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir);
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_windows/Release/libSkiaSharp.lib", "native-builds/lib/windows/" + dir);
|
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_windows/Release/libSkiaSharp.dll", "native-builds/lib/windows/" + dir);
|
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_windows/Release/libSkiaSharp.pdb", "native-builds/lib/windows/" + dir);
|
2016-02-24 22:10:20 +03:00
|
|
|
});
|
2016-01-14 07:42:16 +03:00
|
|
|
|
|
|
|
// set up the gyp environment variables
|
2016-01-15 00:41:16 +03:00
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
2016-04-15 01:21:56 +03:00
|
|
|
|
2016-02-24 22:10:20 +03:00
|
|
|
buildArch ("Win32", "x86", "x86");
|
|
|
|
buildArch ("x64", "x86_64", "x64");
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
2016-04-15 01:21:56 +03:00
|
|
|
// this builds the native C and C++ externals for Windows UWP
|
|
|
|
Task ("externals-uwp")
|
|
|
|
.WithCriteria (IsRunningOnWindows ())
|
|
|
|
.WithCriteria (
|
2016-05-14 02:12:32 +03:00
|
|
|
!FileExists ("native-builds/lib/uwp/ARM/libSkiaSharp.dll") ||
|
|
|
|
!FileExists ("native-builds/lib/uwp/x86/libSkiaSharp.dll") ||
|
|
|
|
!FileExists ("native-builds/lib/uwp/x64/libSkiaSharp.dll"))
|
2016-04-15 01:21:56 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
var convertDesktopToUWP = new Action<FilePath, string> ((projectFilePath, platform) => {
|
|
|
|
//
|
|
|
|
// TODO: the stuff in this block must be moved into the gyp files !!
|
|
|
|
//
|
|
|
|
|
|
|
|
var projectFile = MakeAbsolute (projectFilePath).FullPath;
|
|
|
|
var xdoc = XDocument.Load (projectFile);
|
|
|
|
|
|
|
|
var configType = xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "PropertyGroup")
|
|
|
|
.Elements (MSBuildNS + "ConfigurationType")
|
|
|
|
.Select (e => e.Value)
|
|
|
|
.FirstOrDefault ();
|
|
|
|
if (configType != "StaticLibrary") {
|
|
|
|
// skip over "Utility" projects as they aren't actually
|
|
|
|
// library projects, but intermediate build steps.
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
// special case for ARM, gyp does not yet have ARM,
|
|
|
|
// so it defaults to Win32
|
|
|
|
// update and reload
|
|
|
|
if (platform.ToUpper () == "ARM") {
|
|
|
|
ReplaceTextInFiles (projectFile, "Win32", "ARM");
|
|
|
|
xdoc = XDocument.Load (projectFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 15:55:39 +03:00
|
|
|
var rootNamespace = xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "PropertyGroup")
|
|
|
|
.Elements (MSBuildNS + "RootNamespace")
|
|
|
|
.Select (e => e.Value)
|
|
|
|
.FirstOrDefault ();
|
2016-04-15 01:21:56 +03:00
|
|
|
var globals = xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "PropertyGroup")
|
|
|
|
.Where (e => e.Attribute ("Label") != null && e.Attribute ("Label").Value == "Globals")
|
|
|
|
.Single ();
|
|
|
|
|
|
|
|
globals.Elements (MSBuildNS + "WindowsTargetPlatformVersion").Remove ();
|
|
|
|
SetXValue (globals, "Keyword", "StaticLibrary");
|
|
|
|
SetXValue (globals, "AppContainerApplication", "true");
|
|
|
|
SetXValue (globals, "ApplicationType", "Windows Store");
|
|
|
|
SetXValue (globals, "WindowsTargetPlatformVersion", "10.0.10586.0");
|
|
|
|
SetXValue (globals, "WindowsTargetPlatformMinVersion", "10.0.10240.0");
|
|
|
|
SetXValue (globals, "ApplicationTypeRevision", "10.0");
|
|
|
|
SetXValue (globals, "DefaultLanguage", "en-US");
|
|
|
|
|
|
|
|
var properties = xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "PropertyGroup")
|
|
|
|
.Elements (MSBuildNS + "LinkIncremental")
|
|
|
|
.First ()
|
|
|
|
.Parent;
|
|
|
|
SetXValue (properties, "GenerateManifest","false");
|
|
|
|
SetXValue (properties, "IgnoreImportLibrary","false");
|
|
|
|
|
|
|
|
SetXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "ClCompile" }, "CompileAsWinRT", "false");
|
|
|
|
//AddXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "ClCompile" }, "AdditionalOptions", " /sdl ");
|
|
|
|
AddXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "ClCompile" }, "PreprocessorDefinitions", ";SK_BUILD_FOR_WINRT;WINAPI_FAMILY=WINAPI_FAMILY_APP;");
|
|
|
|
AddXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "ClCompile" }, "DisableSpecificWarnings", ";4146;4703;");
|
|
|
|
SetXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "Link" }, "SubSystem", "Console");
|
|
|
|
SetXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "Link" }, "IgnoreAllDefaultLibraries", "false");
|
|
|
|
SetXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "Link" }, "GenerateWindowsMetadata", "false");
|
|
|
|
|
|
|
|
xdoc.Root
|
|
|
|
.Elements (MSBuildNS + "ItemDefinitionGroup")
|
|
|
|
.Elements (MSBuildNS + "Link")
|
|
|
|
.Elements (MSBuildNS + "AdditionalDependencies")
|
|
|
|
.Remove ();
|
|
|
|
|
2016-06-03 15:55:39 +03:00
|
|
|
// remove sfntly as this is not supported for winrt
|
|
|
|
RemoveXValues (xdoc.Root, new [] { "ItemDefinitionGroup", "ClCompile" }, "PreprocessorDefinitions", "SK_SFNTLY_SUBSETTER=\"font_subsetter.h\"");
|
|
|
|
|
|
|
|
if (rootNamespace == "ports" && platform.ToUpper () == "ARM") {
|
|
|
|
// TLS is not available on ARM
|
|
|
|
AddFileReference (xdoc.Root, @"..\..\src\ports\SkTLS_none.cpp");
|
|
|
|
RemoveFileReference (xdoc.Root, "SkTLS_win.cpp");
|
|
|
|
} else if (rootNamespace == "zlib" && platform.ToUpper () == "ARM") {
|
|
|
|
// x86 instructions are not available on ARM
|
|
|
|
RemoveFileReference (xdoc.Root, "x86.c");
|
|
|
|
} else if (rootNamespace == "zlib_x86_simd" && platform.ToUpper () == "ARM") {
|
|
|
|
// SIMD is not available on ARM
|
|
|
|
AddFileReference (xdoc.Root, @"..\..\third_party\externals\zlib\simd_stub.c");
|
|
|
|
RemoveFileReference (xdoc.Root, "crc_folding.c");
|
|
|
|
RemoveFileReference (xdoc.Root, "fill_window_sse.c");
|
|
|
|
} else if (rootNamespace == "skgpu" ) {
|
|
|
|
// GL is not available to WinRT
|
|
|
|
RemoveFileReference (xdoc.Root, "GrGLCreateNativeInterface_none.cpp");
|
|
|
|
AddFileReference (xdoc.Root, @"..\..\src\gpu\gl\GrGLCreateNativeInterface_none.cpp");
|
|
|
|
RemoveFileReference (xdoc.Root, "GrGLCreateNativeInterface_win.cpp");
|
|
|
|
RemoveFileReference (xdoc.Root, "SkCreatePlatformGLContext_win.cpp");
|
|
|
|
}
|
|
|
|
|
2016-04-15 01:21:56 +03:00
|
|
|
xdoc.Save (projectFile);
|
|
|
|
});
|
|
|
|
|
|
|
|
var buildArch = new Action<string, string> ((platform, arch) => {
|
2016-05-14 02:12:32 +03:00
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_uwp/" + arch);
|
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_uwp/Release");
|
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_uwp/Generated Files");
|
|
|
|
ProcessSolutionProjects ("native-builds/libSkiaSharp_uwp/libSkiaSharp_" + arch + ".sln", (projectName, projectPath) => {
|
|
|
|
if (projectName != "libSkiaSharp")
|
2016-04-15 01:21:56 +03:00
|
|
|
convertDesktopToUWP (projectPath, platform);
|
|
|
|
});
|
|
|
|
VisualStudioPathFixup ();
|
2016-05-14 02:12:32 +03:00
|
|
|
DotNetBuild ("native-builds/libSkiaSharp_uwp/libSkiaSharp_" + arch + ".sln", c => {
|
2016-04-15 01:21:56 +03:00
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { platform };
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/uwp/" + arch)) CreateDirectory ("native-builds/lib/uwp/" + arch);
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_uwp/Release/libSkiaSharp.lib", "native-builds/lib/uwp/" + arch);
|
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_uwp/Release/libSkiaSharp.dll", "native-builds/lib/uwp/" + arch);
|
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_uwp/Release/libSkiaSharp.pdb", "native-builds/lib/uwp/" + arch);
|
2016-04-15 01:21:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
|
|
|
|
2016-06-03 15:55:39 +03:00
|
|
|
RunGyp ("skia_arch_type='x86_64'", "ninja,msvs");
|
2016-04-15 01:21:56 +03:00
|
|
|
buildArch ("x64", "x64");
|
|
|
|
|
2016-06-03 15:55:39 +03:00
|
|
|
RunGyp ("skia_arch_type='x86'", "ninja,msvs");
|
2016-04-15 01:21:56 +03:00
|
|
|
buildArch ("Win32", "x86");
|
|
|
|
|
2016-06-03 15:55:39 +03:00
|
|
|
RunGyp ("skia_arch_type='arm' arm_version=7 arm_neon=0", "ninja,msvs");
|
2016-04-15 01:21:56 +03:00
|
|
|
buildArch ("ARM", "arm");
|
|
|
|
});
|
2016-02-23 00:14:48 +03:00
|
|
|
// this builds the native C and C++ externals for Mac OS X
|
2016-01-15 15:24:57 +03:00
|
|
|
Task ("externals-osx")
|
|
|
|
.WithCriteria (IsRunningOnUnix ())
|
|
|
|
.WithCriteria (
|
2016-05-14 02:12:32 +03:00
|
|
|
!FileExists ("native-builds/lib/osx/libSkiaSharp.dylib"))
|
2016-01-15 15:24:57 +03:00
|
|
|
.Does (() =>
|
2016-01-14 07:42:16 +03:00
|
|
|
{
|
2016-02-03 07:18:07 +03:00
|
|
|
var buildArch = new Action<string, string> ((arch, skiaArch) => {
|
2016-04-15 01:21:56 +03:00
|
|
|
RunGyp ("skia_arch_type='" + skiaArch + "'", "ninja,xcode");
|
2016-02-03 07:18:07 +03:00
|
|
|
|
2016-01-15 00:41:16 +03:00
|
|
|
XCodeBuild (new XCodeBuildSettings {
|
2016-05-14 02:12:32 +03:00
|
|
|
Project = "native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj",
|
|
|
|
Target = "libSkiaSharp",
|
2016-01-15 00:41:16 +03:00
|
|
|
Sdk = "macosx",
|
|
|
|
Arch = arch,
|
|
|
|
Configuration = "Release",
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/osx/" + arch)) {
|
|
|
|
CreateDirectory ("native-builds/lib/osx/" + arch);
|
|
|
|
}
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyDirectory ("native-builds/libSkiaSharp_osx/build/Release/", "native-builds/lib/osx/" + arch);
|
|
|
|
RunInstallNameTool ("native-builds/lib/osx/" + arch, "lib/libSkiaSharp.dylib", "@loader_path/libSkiaSharp.dylib", "libSkiaSharp.dylib");
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
|
|
|
|
2016-02-03 07:18:07 +03:00
|
|
|
buildArch ("i386", "x86");
|
|
|
|
buildArch ("x86_64", "x86_64");
|
2016-01-15 00:41:16 +03:00
|
|
|
|
|
|
|
// create the fat dylib
|
2016-05-14 02:12:32 +03:00
|
|
|
RunLipo ("native-builds/lib/osx/", "libSkiaSharp.dylib", new [] {
|
|
|
|
(FilePath) "i386/libSkiaSharp.dylib",
|
|
|
|
(FilePath) "x86_64/libSkiaSharp.dylib"
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
2016-02-23 00:14:48 +03:00
|
|
|
// this builds the native C and C++ externals for iOS
|
2016-01-15 15:24:57 +03:00
|
|
|
Task ("externals-ios")
|
|
|
|
.WithCriteria (IsRunningOnUnix ())
|
|
|
|
.WithCriteria (
|
2016-05-14 02:12:32 +03:00
|
|
|
!FileExists ("native-builds/lib/ios/libSkiaSharp.framework/libSkiaSharp"))
|
2016-01-15 15:24:57 +03:00
|
|
|
.Does (() =>
|
2016-01-14 07:42:16 +03:00
|
|
|
{
|
2016-01-15 00:41:16 +03:00
|
|
|
var buildArch = new Action<string, string> ((sdk, arch) => {
|
|
|
|
XCodeBuild (new XCodeBuildSettings {
|
2016-05-14 02:12:32 +03:00
|
|
|
Project = "native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj",
|
|
|
|
Target = "libSkiaSharp",
|
2016-01-15 00:41:16 +03:00
|
|
|
Sdk = sdk,
|
|
|
|
Arch = arch,
|
|
|
|
Configuration = "Release",
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/ios/" + arch)) {
|
|
|
|
CreateDirectory ("native-builds/lib/ios/" + arch);
|
|
|
|
}
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyDirectory ("native-builds/libSkiaSharp_ios/build/Release-" + sdk, "native-builds/lib/ios/" + arch);
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
2016-04-15 01:21:56 +03:00
|
|
|
|
|
|
|
RunGyp ("skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0", "ninja,xcode");
|
2016-01-15 00:41:16 +03:00
|
|
|
|
|
|
|
buildArch ("iphonesimulator", "i386");
|
|
|
|
buildArch ("iphonesimulator", "x86_64");
|
|
|
|
buildArch ("iphoneos", "armv7");
|
|
|
|
buildArch ("iphoneos", "armv7s");
|
|
|
|
buildArch ("iphoneos", "arm64");
|
|
|
|
|
|
|
|
// create the fat framework
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyDirectory ("native-builds/lib/ios/armv7/libSkiaSharp.framework/", "native-builds/lib/ios/libSkiaSharp.framework/");
|
|
|
|
DeleteFile ("native-builds/lib/ios/libSkiaSharp.framework/libSkiaSharp");
|
|
|
|
RunLipo ("native-builds/lib/ios/", "libSkiaSharp.framework/libSkiaSharp", new [] {
|
|
|
|
(FilePath) "i386/libSkiaSharp.framework/libSkiaSharp",
|
|
|
|
(FilePath) "x86_64/libSkiaSharp.framework/libSkiaSharp",
|
|
|
|
(FilePath) "armv7/libSkiaSharp.framework/libSkiaSharp",
|
|
|
|
(FilePath) "armv7s/libSkiaSharp.framework/libSkiaSharp",
|
|
|
|
(FilePath) "arm64/libSkiaSharp.framework/libSkiaSharp"
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
2016-02-23 00:14:48 +03:00
|
|
|
// this builds the native C and C++ externals for Android
|
2016-01-15 15:24:57 +03:00
|
|
|
Task ("externals-android")
|
|
|
|
.WithCriteria (IsRunningOnUnix ())
|
|
|
|
.WithCriteria (
|
2016-05-14 02:12:32 +03:00
|
|
|
!FileExists ("native-builds/lib/android/x86/libSkiaSharp.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/x86_64/libSkiaSharp.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/armeabi/libSkiaSharp.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/armeabi-v7a/libSkiaSharp.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/arm64-v8a/libSkiaSharp.so"))
|
2016-01-15 15:24:57 +03:00
|
|
|
.Does (() =>
|
2016-01-14 07:42:16 +03:00
|
|
|
{
|
2016-01-15 00:41:16 +03:00
|
|
|
var ANDROID_HOME = EnvironmentVariable ("ANDROID_HOME") ?? EnvironmentVariable ("HOME") + "/Library/Developer/Xamarin/android-sdk-macosx";
|
|
|
|
var ANDROID_SDK_ROOT = EnvironmentVariable ("ANDROID_SDK_ROOT") ?? ANDROID_HOME;
|
|
|
|
var ANDROID_NDK_HOME = EnvironmentVariable ("ANDROID_NDK_HOME") ?? EnvironmentVariable ("HOME") + "/Library/Developer/Xamarin/android-ndk";
|
|
|
|
|
|
|
|
var buildArch = new Action<string, string> ((arch, folder) => {
|
|
|
|
StartProcess (SKIA_PATH.CombineWithFilePath ("platform_tools/android/bin/android_ninja").FullPath, new ProcessSettings {
|
2016-06-03 15:55:39 +03:00
|
|
|
Arguments = "-d " + arch + " skia_lib pdf sfntly icuuc",
|
2016-01-15 00:41:16 +03:00
|
|
|
WorkingDirectory = SKIA_PATH.FullPath,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
2016-01-15 03:18:32 +03:00
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", "");
|
|
|
|
SetEnvironmentVariable ("GYP_GENERATORS", "");
|
2016-01-15 00:41:16 +03:00
|
|
|
SetEnvironmentVariable ("BUILDTYPE", "Release");
|
|
|
|
SetEnvironmentVariable ("ANDROID_HOME", ANDROID_HOME);
|
|
|
|
SetEnvironmentVariable ("ANDROID_SDK_ROOT", ANDROID_SDK_ROOT);
|
|
|
|
SetEnvironmentVariable ("ANDROID_NDK_HOME", ANDROID_NDK_HOME);
|
|
|
|
|
|
|
|
buildArch ("x86", "x86");
|
|
|
|
buildArch ("x86_64", "x86_64");
|
|
|
|
buildArch ("arm", "armeabi");
|
|
|
|
buildArch ("arm_v7_neon", "armeabi-v7a");
|
|
|
|
buildArch ("arm64", "arm64-v8a");
|
|
|
|
|
|
|
|
var ndkbuild = MakeAbsolute (Directory (ANDROID_NDK_HOME)).CombineWithFilePath ("ndk-build").FullPath;
|
|
|
|
StartProcess (ndkbuild, new ProcessSettings {
|
|
|
|
Arguments = "",
|
2016-05-14 02:12:32 +03:00
|
|
|
WorkingDirectory = ROOT_PATH.Combine ("native-builds/libSkiaSharp_android").FullPath,
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
2016-02-03 07:18:07 +03:00
|
|
|
|
|
|
|
foreach (var folder in new [] { "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a" }) {
|
|
|
|
if (!DirectoryExists ("native-builds/lib/android/" + folder)) {
|
|
|
|
CreateDirectory ("native-builds/lib/android/" + folder);
|
|
|
|
}
|
2016-05-14 02:12:32 +03:00
|
|
|
CopyFileToDirectory ("native-builds/libSkiaSharp_android/libs/" + folder + "/libSkiaSharp.so", "native-builds/lib/android/" + folder);
|
2016-02-03 07:18:07 +03:00
|
|
|
}
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LIBS - the managed C# libraries
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("libs")
|
2016-05-05 04:24:31 +03:00
|
|
|
.IsDependentOn ("libs-base")
|
2016-02-23 00:14:48 +03:00
|
|
|
.IsDependentOn ("libs-windows")
|
|
|
|
.IsDependentOn ("libs-osx")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
});
|
2016-05-05 04:24:31 +03:00
|
|
|
Task ("libs-base")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
// set the SHA on the assembly info
|
|
|
|
var sha = EnvironmentVariable ("GIT_COMMIT") ?? string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty (sha) && sha.Length >= 6) {
|
|
|
|
sha = sha.Substring (0, 6);
|
|
|
|
Information ("Setting Git SHA to {0}.", sha);
|
|
|
|
ReplaceTextInFiles ("./binding/SkiaSharp/Properties/SkiaSharpAssemblyInfo.cs", "{GIT_SHA}", sha);
|
|
|
|
}
|
|
|
|
});
|
2016-02-23 00:14:48 +03:00
|
|
|
Task ("libs-windows")
|
|
|
|
.WithCriteria (IsRunningOnWindows ())
|
|
|
|
.IsDependentOn ("externals")
|
2016-05-05 04:24:31 +03:00
|
|
|
.IsDependentOn ("libs-base")
|
2016-02-23 00:14:48 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
// build
|
2016-02-23 01:18:12 +03:00
|
|
|
RunNuGetRestore ("binding/SkiaSharp.Windows.sln");
|
2016-02-23 00:14:48 +03:00
|
|
|
DotNetBuild ("binding/SkiaSharp.Windows.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
|
2016-02-23 03:31:17 +03:00
|
|
|
if (!DirectoryExists ("./output/portable/")) CreateDirectory ("./output/portable/");
|
|
|
|
if (!DirectoryExists ("./output/windows/")) CreateDirectory ("./output/windows/");
|
2016-05-06 18:39:38 +03:00
|
|
|
if (!DirectoryExists ("./output/uwp/")) CreateDirectory ("./output/uwp/");
|
2016-02-23 01:18:12 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
// copy build output
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Portable/bin/Release/SkiaSharp.dll", "./output/portable/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll", "./output/windows/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.pdb", "./output/windows/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll.config", "./output/windows/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.Desktop.targets", "./output/windows/");
|
2016-05-06 18:39:38 +03:00
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.UWP/bin/Release/SkiaSharp.dll", "./output/uwp/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.UWP/bin/Release/SkiaSharp.pdb", "./output/uwp/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.UWP/bin/Release/SkiaSharp.pri", "./output/uwp/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.UWP/bin/Release/SkiaSharp.UWP.targets", "./output/uwp/");
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
|
|
|
Task ("libs-osx")
|
|
|
|
.WithCriteria (IsRunningOnUnix ())
|
|
|
|
.IsDependentOn ("externals")
|
2016-05-05 04:24:31 +03:00
|
|
|
.IsDependentOn ("libs-base")
|
2016-02-23 00:14:48 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
// build
|
2016-02-23 01:18:12 +03:00
|
|
|
RunNuGetRestore ("binding/SkiaSharp.Mac.sln");
|
2016-02-23 00:14:48 +03:00
|
|
|
DotNetBuild ("binding/SkiaSharp.Mac.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
|
2016-02-23 03:31:17 +03:00
|
|
|
if (!DirectoryExists ("./output/android/")) CreateDirectory ("./output/android/");
|
|
|
|
if (!DirectoryExists ("./output/ios/")) CreateDirectory ("./output/ios/");
|
|
|
|
if (!DirectoryExists ("./output/osx/")) CreateDirectory ("./output/osx/");
|
|
|
|
if (!DirectoryExists ("./output/portable/")) CreateDirectory ("./output/portable/");
|
|
|
|
if (!DirectoryExists ("./output/mac/")) CreateDirectory ("./output/mac/");
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
// copy build output
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Android/bin/Release/SkiaSharp.dll", "./output/android/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.iOS/bin/Release/SkiaSharp.dll", "./output/ios/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.OSX/bin/Release/SkiaSharp.dll", "./output/osx/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.OSX/bin/Release/SkiaSharp.OSX.targets", "./output/osx/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Portable/bin/Release/SkiaSharp.dll", "./output/portable/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll", "./output/mac/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.Desktop.targets", "./output/mac/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll.config", "./output/mac/");
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TESTS - some test cases to make sure it works
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("tests")
|
|
|
|
.IsDependentOn ("libs")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-23 01:18:12 +03:00
|
|
|
RunNuGetRestore ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln");
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
// Windows (x86 and x64)
|
|
|
|
if (IsRunningOnWindows ()) {
|
|
|
|
DotNetBuild ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "x86" };
|
|
|
|
});
|
|
|
|
RunTests("./tests/SkiaSharp.Desktop.Tests/bin/x86/Release/SkiaSharp.Desktop.Tests.dll");
|
|
|
|
DotNetBuild ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "x64" };
|
|
|
|
});
|
|
|
|
RunTests("./tests/SkiaSharp.Desktop.Tests/bin/x86/Release/SkiaSharp.Desktop.Tests.dll");
|
|
|
|
}
|
|
|
|
// Mac OSX (Any CPU)
|
|
|
|
if (IsRunningOnUnix ()) {
|
|
|
|
DotNetBuild ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
2016-06-03 16:33:14 +03:00
|
|
|
RunTests("./tests/SkiaSharp.Desktop.Tests/bin/AnyCPU/Release/SkiaSharp.Desktop.Tests.dll");
|
2016-02-23 00:14:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SAMPLES - the demo apps showing off the work
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("samples")
|
|
|
|
.IsDependentOn ("libs")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
if (IsRunningOnUnix ()) {
|
2016-02-23 01:18:12 +03:00
|
|
|
RunNuGetRestore ("./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln");
|
2016-02-23 00:14:48 +03:00
|
|
|
DotNetBuild ("./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
2016-06-03 18:32:14 +03:00
|
|
|
RunNuGetRestore ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.Mac.sln");
|
|
|
|
DotNetBuild ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.Mac.sln", c => {
|
2016-02-23 00:14:48 +03:00
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "iPhone" };
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:32:14 +03:00
|
|
|
if (IsRunningOnWindows ()) {
|
|
|
|
RunNuGetRestore ("./samples/Skia.UWP.Demo/Skia.UWP.Demo.sln");
|
|
|
|
DotNetBuild ("./samples/Skia.UWP.Demo/Skia.UWP.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
RunNuGetRestore ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.Windows.sln");
|
|
|
|
DotNetBuild ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.Windows.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-02-23 01:18:12 +03:00
|
|
|
RunNuGetRestore ("./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln");
|
2016-02-23 00:14:48 +03:00
|
|
|
DotNetBuild ("./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "x86" };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-02-23 13:57:08 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// DOCS - building the API documentation
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("docs")
|
2016-05-14 02:12:32 +03:00
|
|
|
.IsDependentOn ("libs-base")
|
2016-02-23 13:57:08 +03:00
|
|
|
.IsDependentOn ("externals-genapi")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
RunMdocUpdate ("./binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll", "./docs/en/");
|
2016-05-05 04:24:31 +03:00
|
|
|
|
|
|
|
if (!DirectoryExists ("./output/docs/msxml/")) CreateDirectory ("./output/docs/msxml/");
|
|
|
|
RunMdocMSXml ("./docs/en/", "./output/docs/msxml/SkiaSharp.xml");
|
|
|
|
|
|
|
|
if (!DirectoryExists ("./output/docs/mdoc/")) CreateDirectory ("./output/docs/mdoc/");
|
|
|
|
RunMdocAssemble ("./docs/en/", "./output/docs/mdoc/SkiaSharp");
|
2016-02-23 13:57:08 +03:00
|
|
|
});
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NUGET - building the package for NuGet.org
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("nuget")
|
|
|
|
.IsDependentOn ("libs")
|
2016-05-05 04:24:31 +03:00
|
|
|
.IsDependentOn ("docs")
|
2016-02-23 00:14:48 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
if (IsRunningOnWindows ()) {
|
2016-05-05 04:24:31 +03:00
|
|
|
PackageNuGet ("./nuget/SkiaSharp.Windows.nuspec", "./output/");
|
2016-02-23 00:14:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsRunningOnUnix ()) {
|
2016-05-05 04:24:31 +03:00
|
|
|
PackageNuGet ("./nuget/SkiaSharp.Mac.nuspec", "./output/");
|
|
|
|
PackageNuGet ("./nuget/SkiaSharp.nuspec", "./output/");
|
2016-02-23 00:14:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// COMPONENT - building the package for components.xamarin.com
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("component")
|
|
|
|
.IsDependentOn ("nuget")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-23 01:18:12 +03:00
|
|
|
// TODO: Not yet ready
|
2016-02-23 00:14:48 +03:00
|
|
|
|
2016-02-23 01:18:12 +03:00
|
|
|
// if (!DirectoryExists ("./output/")) {
|
|
|
|
// CreateDirectory ("./output/");
|
|
|
|
// }
|
|
|
|
|
|
|
|
// FilePath yaml = "./component/component.yaml";
|
|
|
|
// var yamlDir = yaml.GetDirectory ();
|
|
|
|
// PackageComponent (yamlDir, new XamarinComponentSettings {
|
|
|
|
// ToolPath = XamarinComponentToolPath
|
|
|
|
// });
|
2016-02-23 00:14:48 +03:00
|
|
|
|
2016-02-23 01:18:12 +03:00
|
|
|
// MoveFiles (yamlDir.FullPath.TrimEnd ('/') + "/*.xam", "./output/");
|
2016-02-23 00:14:48 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CLEAN - remove all the build artefacts
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-01-15 03:18:32 +03:00
|
|
|
Task ("clean")
|
|
|
|
.IsDependentOn ("clean-externals")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
2016-02-23 00:19:23 +03:00
|
|
|
CleanDirectories ("./binding/**/bin");
|
|
|
|
CleanDirectories ("./binding/**/obj");
|
|
|
|
|
|
|
|
CleanDirectories ("./samples/**/bin");
|
|
|
|
CleanDirectories ("./samples/**/obj");
|
|
|
|
|
|
|
|
CleanDirectories ("./tests/**/bin");
|
|
|
|
CleanDirectories ("./tests/**/obj");
|
2016-01-15 03:18:32 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
if (DirectoryExists ("./output"))
|
|
|
|
DeleteDirectory ("./output", true);
|
|
|
|
});
|
2016-01-15 03:18:32 +03:00
|
|
|
Task ("clean-externals").Does (() =>
|
|
|
|
{
|
|
|
|
// skia
|
|
|
|
CleanDirectories ("skia/out");
|
|
|
|
CleanDirectories ("skia/xcodebuild");
|
|
|
|
|
|
|
|
// all
|
|
|
|
CleanDirectories ("native-builds/lib");
|
|
|
|
// android
|
2016-05-14 02:12:32 +03:00
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_android/obj");
|
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_android/libs");
|
2016-01-15 03:18:32 +03:00
|
|
|
// ios
|
2016-05-14 02:12:32 +03:00
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_ios/build");
|
2016-01-15 03:18:32 +03:00
|
|
|
// osx
|
2016-05-14 02:12:32 +03:00
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_osx/build");
|
2016-01-15 03:18:32 +03:00
|
|
|
// windows
|
2016-05-14 02:12:32 +03:00
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_windows/Release");
|
|
|
|
CleanDirectories ("native-builds/libSkiaSharp_windows/x64/Release");
|
2016-01-15 03:18:32 +03:00
|
|
|
});
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// DEFAULT - target for common development
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("Default")
|
|
|
|
.IsDependentOn ("externals")
|
|
|
|
.IsDependentOn ("libs");
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CI - the master target to build everything
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("CI")
|
|
|
|
.IsDependentOn ("externals")
|
|
|
|
.IsDependentOn ("libs")
|
2016-02-23 13:57:08 +03:00
|
|
|
.IsDependentOn ("docs")
|
2016-02-23 00:14:48 +03:00
|
|
|
.IsDependentOn ("nuget")
|
|
|
|
.IsDependentOn ("component")
|
|
|
|
.IsDependentOn ("tests")
|
|
|
|
.IsDependentOn ("samples");
|
|
|
|
|
2016-05-05 04:24:31 +03:00
|
|
|
Task ("Windows-CI")
|
|
|
|
.IsDependentOn ("externals")
|
|
|
|
.IsDependentOn ("libs")
|
|
|
|
.IsDependentOn ("tests")
|
|
|
|
.IsDependentOn ("samples");
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// BUILD NOW
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Information ("Cake.exe ToolPath: {0}", CakeToolPath);
|
|
|
|
Information ("Cake.exe NUnitConsoleToolPath: {0}", NUnitConsoleToolPath);
|
|
|
|
Information ("NuGet.exe ToolPath: {0}", NugetToolPath);
|
|
|
|
Information ("Xamarin-Component.exe ToolPath: {0}", XamarinComponentToolPath);
|
|
|
|
Information ("genapi.exe ToolPath: {0}", GenApiToolPath);
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
ListEnvironmentVariables ();
|
2016-01-14 07:42:16 +03:00
|
|
|
|
|
|
|
RunTarget (TARGET);
|