Коммит
1aa9855d12
576
build.cake
576
build.cake
|
@ -1,16 +1,60 @@
|
|||
#addin "Cake.Xamarin"
|
||||
#addin "Cake.XCode"
|
||||
|
||||
#load "common.cake"
|
||||
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
var ROOT_PATH = MakeAbsolute(File(".")).GetDirectory();
|
||||
var DEPOT_PATH = MakeAbsolute(ROOT_PATH.Combine("depot_tools"));
|
||||
var SKIA_PATH = MakeAbsolute(ROOT_PATH.Combine("skia"));
|
||||
var TARGET = Argument ("t", Argument ("target", Argument ("Target", "Default")));
|
||||
|
||||
var RunGyp = new Action (() => {
|
||||
var NuGetSources = new [] { "https://www.nuget.org/api/v2/" };
|
||||
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");
|
||||
|
||||
DirectoryPath ROOT_PATH = MakeAbsolute(File(".")).GetDirectory();
|
||||
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) => {
|
||||
Environment.SetEnvironmentVariable (name, value, EnvironmentVariableTarget.Process);
|
||||
});
|
||||
var AppendEnvironmentVariable = new Action<string, string> ((name, value) => {
|
||||
var old = EnvironmentVariable (name);
|
||||
value += (IsRunningOnWindows () ? ";" : ":") + old;
|
||||
SetEnvironmentVariable (name, value);
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
var RunNuGetRestore = new Action<FilePath> ((solution) =>
|
||||
{
|
||||
NuGetRestore (solution, new NuGetRestoreSettings {
|
||||
ToolPath = NugetToolPath
|
||||
});
|
||||
});
|
||||
|
||||
var RunGyp = new Action (() =>
|
||||
{
|
||||
Information ("Running 'sync-and-gyp'...");
|
||||
Information ("\tGYP_GENERATORS = " + EnvironmentVariable ("GYP_GENERATORS"));
|
||||
Information ("\tGYP_DEFINES = " + EnvironmentVariable ("GYP_DEFINES"));
|
||||
|
@ -21,177 +65,96 @@ var RunGyp = new Action (() => {
|
|||
});
|
||||
});
|
||||
|
||||
var SetEnvironmentVariable = new Action<string, string> ((name, value) => {
|
||||
Environment.SetEnvironmentVariable (name, value, EnvironmentVariableTarget.Process);
|
||||
});
|
||||
var AppendEnvironmentVariable = new Action<string, string> ((name, value) => {
|
||||
var old = EnvironmentVariable (name);
|
||||
value += (IsRunningOnWindows () ? ";" : ":") + old;
|
||||
SetEnvironmentVariable (name, value);
|
||||
var RunInstallNameTool = new Action<DirectoryPath, string, string, FilePath> ((directory, oldName, newName, library) =>
|
||||
{
|
||||
if (!IsRunningOnUnix ()) {
|
||||
throw new InvalidOperationException ("install_name_tool is only available on Unix.");
|
||||
}
|
||||
|
||||
StartProcess ("install_name_tool", new ProcessSettings {
|
||||
Arguments = string.Format("-change {0} {1} \"{2}\"", oldName, newName, library),
|
||||
WorkingDirectory = directory,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
CakeSpec.Libs = new ISolutionBuilder [] {
|
||||
new IOSSolutionBuilder {
|
||||
SolutionPath = "binding/SkiaSharp.Mac.sln",
|
||||
IsWindowsCompatible = false,
|
||||
IsMacCompatible = true,
|
||||
OutputFiles = new [] {
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Android/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/android/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.iOS/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/ios/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.OSX/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/osx/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.OSX/bin/Release/SkiaSharp.OSX.targets",
|
||||
ToDirectory = "./output/osx/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Portable/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/portable/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/mac/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.Desktop.targets",
|
||||
ToDirectory = "./output/mac/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll.config",
|
||||
ToDirectory = "./output/mac/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/mac/libskia_osx.dylib",
|
||||
ToDirectory = "./output/mac/"
|
||||
},
|
||||
var RunLipo = new Action<DirectoryPath, FilePath, FilePath[]> ((directory, output, inputs) =>
|
||||
{
|
||||
if (!IsRunningOnUnix ()) {
|
||||
throw new InvalidOperationException ("lipo is only available on Unix.");
|
||||
}
|
||||
},
|
||||
new DefaultSolutionBuilder {
|
||||
SolutionPath = "binding/SkiaSharp.Windows.sln",
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
OutputFiles = new [] {
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Portable/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/portable/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll",
|
||||
ToDirectory = "./output/windows/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.pdb",
|
||||
ToDirectory = "./output/windows/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.dll.config",
|
||||
ToDirectory = "./output/windows/"
|
||||
},
|
||||
new OutputFileCopy {
|
||||
FromFile = "./binding/SkiaSharp.Desktop/bin/Release/SkiaSharp.Desktop.targets",
|
||||
ToDirectory = "./output/windows/"
|
||||
},
|
||||
|
||||
var dir = directory.CombineWithFilePath (output).GetDirectory ();
|
||||
if (!DirectoryExists (dir)) {
|
||||
CreateDirectory (dir);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
CakeSpec.Samples = new ISolutionBuilder [] {
|
||||
new IOSSolutionBuilder {
|
||||
IsWindowsCompatible = false,
|
||||
IsMacCompatible = true,
|
||||
SolutionPath = "./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln"
|
||||
},
|
||||
new IOSSolutionBuilder {
|
||||
IsWindowsCompatible = false,
|
||||
IsMacCompatible = true,
|
||||
SolutionPath = "./samples/Skia.Forms.Demo/Skia.Forms.Demo.sln"
|
||||
},
|
||||
new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
Platform = "x86",
|
||||
SolutionPath = "./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln"
|
||||
},
|
||||
};
|
||||
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,
|
||||
});
|
||||
});
|
||||
|
||||
CakeSpec.Tests = new SolutionTestRunner [] {
|
||||
// Windows (x86 and x64)
|
||||
new SolutionTestRunner {
|
||||
SolutionBuilder = new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
SolutionPath = "./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln",
|
||||
Platform = "x86",
|
||||
},
|
||||
TestAssembly = "./tests/SkiaSharp.Desktop.Tests/bin/x86/Release/SkiaSharp.Desktop.Tests.dll",
|
||||
},
|
||||
new SolutionTestRunner {
|
||||
SolutionBuilder = new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = false,
|
||||
SolutionPath = "./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln",
|
||||
Platform = "x64",
|
||||
},
|
||||
TestAssembly = "./tests/SkiaSharp.Desktop.Tests/bin/x64/Release/SkiaSharp.Desktop.Tests.dll",
|
||||
},
|
||||
// Mac OSX (Any CPU)
|
||||
new SolutionTestRunner {
|
||||
SolutionBuilder = new DefaultSolutionBuilder {
|
||||
IsWindowsCompatible = false,
|
||||
IsMacCompatible = true,
|
||||
SolutionPath = "./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln",
|
||||
},
|
||||
TestAssembly = "./tests/SkiaSharp.Desktop.Tests/bin/Release/SkiaSharp.Desktop.Tests.dll",
|
||||
},
|
||||
};
|
||||
var PackageNuGet = new Action<FilePath, DirectoryPath> ((nuspecPath, outputPath) =>
|
||||
{
|
||||
// NuGet messes up path on mac, so let's add ./ in front twice
|
||||
var basePath = IsRunningOnUnix () ? "././" : "./";
|
||||
|
||||
if (IsRunningOnWindows ()) {
|
||||
CakeSpec.NuSpecs = new [] {
|
||||
"./nuget/Xamarin.SkiaSharp.Windows.nuspec",
|
||||
};
|
||||
}
|
||||
if (!DirectoryExists (outputPath)) {
|
||||
CreateDirectory (outputPath);
|
||||
}
|
||||
|
||||
if (IsRunningOnUnix ()) {
|
||||
CakeSpec.NuSpecs = new [] {
|
||||
"./nuget/Xamarin.SkiaSharp.Mac.nuspec",
|
||||
"./nuget/Xamarin.SkiaSharp.nuspec",
|
||||
};
|
||||
}
|
||||
NuGetPack (nuspecPath, new NuGetPackSettings {
|
||||
Verbosity = NuGetVerbosity.Detailed,
|
||||
OutputDirectory = outputPath,
|
||||
BasePath = basePath,
|
||||
ToolPath = NugetToolPath
|
||||
});
|
||||
});
|
||||
|
||||
Task ("libs")
|
||||
.IsDependentOn ("externals")
|
||||
.IsDependentOn ("libs-base")
|
||||
var RunTests = new Action<FilePath> ((testAssembly) =>
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
var RunMdocUpdate = new Action<FilePath, DirectoryPath> ((assembly, docsRoot) =>
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
StartProcess (mdocPath, new ProcessSettings {
|
||||
Arguments = string.Format ("update --out=\"{0}\" \"{1}\"", docsRoot, assembly),
|
||||
});
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// EXTERNALS - the native C and C++ libraries
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// this builds all the externals
|
||||
Task ("externals")
|
||||
.IsDependentOn ("externals-genapi")
|
||||
.IsDependentOn ("externals-native")
|
||||
.Does (() =>
|
||||
{
|
||||
if (IsRunningOnUnix ()) {
|
||||
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/osx/");
|
||||
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/mac/");
|
||||
}
|
||||
if (IsRunningOnWindows ()) {
|
||||
if (!DirectoryExists ("./output/windows/x86/")) {
|
||||
CreateDirectory ("./output/windows/x86/");
|
||||
}
|
||||
if (!DirectoryExists ("./output/windows/x64/")) {
|
||||
CreateDirectory ("./output/windows/x64/");
|
||||
}
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x86/libskia_windows.dll", "./output/windows/x86/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x86/libskia_windows.pdb", "./output/windows/x86/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x64/libskia_windows.dll", "./output/windows/x64/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x64/libskia_windows.pdb", "./output/windows/x64/");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Task ("externals")
|
||||
// this builds the native C and C++ externals
|
||||
Task ("externals-native")
|
||||
.IsDependentOn ("externals-windows")
|
||||
.IsDependentOn ("externals-osx")
|
||||
.IsDependentOn ("externals-ios")
|
||||
|
@ -201,24 +164,42 @@ Task ("externals")
|
|||
// copy all the native files into the output
|
||||
CopyDirectory ("./native-builds/lib/", "./output/native/");
|
||||
|
||||
// copy the non-embedded native files into the output
|
||||
if (IsRunningOnWindows ()) {
|
||||
if (!DirectoryExists ("./output/windows/x86")) CreateDirectory ("./output/windows/x86");
|
||||
if (!DirectoryExists ("./output/windows/x64")) CreateDirectory ("./output/windows/x64");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x86/libskia_windows.dll", "./output/windows/x86/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x86/libskia_windows.pdb", "./output/windows/x86/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x64/libskia_windows.dll", "./output/windows/x64/");
|
||||
CopyFileToDirectory ("./native-builds/lib/windows/x64/libskia_windows.pdb", "./output/windows/x64/");
|
||||
}
|
||||
if (IsRunningOnUnix ()) {
|
||||
if (!DirectoryExists ("./output/osx")) CreateDirectory ("./output/osx");
|
||||
if (!DirectoryExists ("./output/mac")) CreateDirectory ("./output/mac");
|
||||
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/osx/");
|
||||
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/mac/");
|
||||
}
|
||||
});
|
||||
// this builds the managed PCL external
|
||||
Task ("externals-genapi")
|
||||
.Does (() =>
|
||||
{
|
||||
// build the dummy project
|
||||
var generic = new DefaultSolutionBuilder {
|
||||
SolutionPath = "binding/SkiaSharp.Generic.sln",
|
||||
IsWindowsCompatible = true,
|
||||
IsMacCompatible = true,
|
||||
};
|
||||
generic.BuildSolution ();
|
||||
DotNetBuild ("binding/SkiaSharp.Generic.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
c.Properties ["Platform"] = new [] { "\"Any CPU\"" };
|
||||
});
|
||||
|
||||
// generate the PCL
|
||||
FilePath input = "binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll";
|
||||
var libPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/,.";
|
||||
StartProcess (CakeStealer.GenApiToolPath, new ProcessSettings {
|
||||
StartProcess (GenApiToolPath, new ProcessSettings {
|
||||
Arguments = string.Format("-libPath:{2} -out \"{0}\" \"{1}\"", input.GetFilename () + ".cs", input.GetFilename (), libPath),
|
||||
WorkingDirectory = input.GetDirectory ().FullPath,
|
||||
});
|
||||
CopyFile ("binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll.cs", "binding/SkiaSharp.Portable/SkiaPortable.cs");
|
||||
});
|
||||
|
||||
// this builds the native C and C++ externals for Windows
|
||||
Task ("externals-windows")
|
||||
.WithCriteria (IsRunningOnWindows ())
|
||||
.WithCriteria (
|
||||
|
@ -254,9 +235,7 @@ Task ("externals-windows")
|
|||
c.Configuration = "Release";
|
||||
c.Properties ["Platform"] = new [] { "Win32" };
|
||||
});
|
||||
if (!DirectoryExists ("native-builds/lib/windows/x86")) {
|
||||
CreateDirectory ("native-builds/lib/windows/x86");
|
||||
}
|
||||
if (!DirectoryExists ("native-builds/lib/windows/x86")) CreateDirectory ("native-builds/lib/windows/x86");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/x86");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/x86");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/x86");
|
||||
|
@ -269,13 +248,12 @@ Task ("externals-windows")
|
|||
c.Configuration = "Release";
|
||||
c.Properties ["Platform"] = new [] { "x64" };
|
||||
});
|
||||
if (!DirectoryExists ("native-builds/lib/windows/x64")) {
|
||||
CreateDirectory ("native-builds/lib/windows/x64");
|
||||
}
|
||||
if (!DirectoryExists ("native-builds/lib/windows/x64")) CreateDirectory ("native-builds/lib/windows/x64");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/x64");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/x64");
|
||||
CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/x64");
|
||||
});
|
||||
// this builds the native C and C++ externals for Mac OS X
|
||||
Task ("externals-osx")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
|
@ -308,10 +286,12 @@ Task ("externals-osx")
|
|||
buildArch ("x86_64", "x86_64");
|
||||
|
||||
// create the fat dylib
|
||||
RunLipo ("native-builds/lib/osx/", "libskia_osx.dylib",
|
||||
"i386/libskia_osx.dylib",
|
||||
"x86_64/libskia_osx.dylib");
|
||||
RunLipo ("native-builds/lib/osx/", "libskia_osx.dylib", new [] {
|
||||
(FilePath) "i386/libskia_osx.dylib",
|
||||
(FilePath) "x86_64/libskia_osx.dylib"
|
||||
});
|
||||
});
|
||||
// this builds the native C and C++ externals for iOS
|
||||
Task ("externals-ios")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
|
@ -348,13 +328,15 @@ Task ("externals-ios")
|
|||
// create the fat framework
|
||||
CopyDirectory ("native-builds/lib/ios/armv7/libskia_ios.framework/", "native-builds/lib/ios/libskia_ios.framework/");
|
||||
DeleteFile ("native-builds/lib/ios/libskia_ios.framework/libskia_ios");
|
||||
RunLipo ("native-builds/lib/ios/", "libskia_ios.framework/libskia_ios",
|
||||
"i386/libskia_ios.framework/libskia_ios",
|
||||
"x86_64/libskia_ios.framework/libskia_ios",
|
||||
"armv7/libskia_ios.framework/libskia_ios",
|
||||
"armv7s/libskia_ios.framework/libskia_ios",
|
||||
"arm64/libskia_ios.framework/libskia_ios");
|
||||
RunLipo ("native-builds/lib/ios/", "libskia_ios.framework/libskia_ios", new [] {
|
||||
(FilePath) "i386/libskia_ios.framework/libskia_ios",
|
||||
(FilePath) "x86_64/libskia_ios.framework/libskia_ios",
|
||||
(FilePath) "armv7/libskia_ios.framework/libskia_ios",
|
||||
(FilePath) "armv7s/libskia_ios.framework/libskia_ios",
|
||||
(FilePath) "arm64/libskia_ios.framework/libskia_ios"
|
||||
});
|
||||
});
|
||||
// this builds the native C and C++ externals for Android
|
||||
Task ("externals-android")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
|
@ -405,12 +387,196 @@ Task ("externals-android")
|
|||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LIBS - the managed C# libraries
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("libs")
|
||||
.IsDependentOn ("libs-windows")
|
||||
.IsDependentOn ("libs-osx")
|
||||
.Does (() =>
|
||||
{
|
||||
});
|
||||
Task ("libs-windows")
|
||||
.WithCriteria (IsRunningOnWindows ())
|
||||
.IsDependentOn ("externals")
|
||||
.Does (() =>
|
||||
{
|
||||
// build
|
||||
RunNuGetRestore ("binding/SkiaSharp.Windows.sln");
|
||||
DotNetBuild ("binding/SkiaSharp.Windows.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
});
|
||||
|
||||
if (!DirectoryExists ("./output/portable/")) CreateDirectory ("./output/portable/");
|
||||
if (!DirectoryExists ("./output/windows/")) CreateDirectory ("./output/windows/");
|
||||
|
||||
// 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/");
|
||||
});
|
||||
Task ("libs-osx")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.IsDependentOn ("externals")
|
||||
.Does (() =>
|
||||
{
|
||||
// build
|
||||
RunNuGetRestore ("binding/SkiaSharp.Mac.sln");
|
||||
DotNetBuild ("binding/SkiaSharp.Mac.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
});
|
||||
|
||||
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/");
|
||||
|
||||
// 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 (() =>
|
||||
{
|
||||
RunNuGetRestore ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln");
|
||||
|
||||
// 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";
|
||||
});
|
||||
RunTests("./tests/SkiaSharp.Desktop.Tests/bin/Release/SkiaSharp.Desktop.Tests.dll");
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SAMPLES - the demo apps showing off the work
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("samples")
|
||||
.IsDependentOn ("libs")
|
||||
.Does (() =>
|
||||
{
|
||||
if (IsRunningOnUnix ()) {
|
||||
RunNuGetRestore ("./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln");
|
||||
DotNetBuild ("./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
});
|
||||
RunNuGetRestore ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.sln");
|
||||
DotNetBuild ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
c.Properties ["Platform"] = new [] { "iPhone" };
|
||||
});
|
||||
}
|
||||
|
||||
RunNuGetRestore ("./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln");
|
||||
DotNetBuild ("./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln", c => {
|
||||
c.Configuration = "Release";
|
||||
c.Properties ["Platform"] = new [] { "x86" };
|
||||
});
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DOCS - building the API documentation
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("docs")
|
||||
.IsDependentOn ("externals-genapi")
|
||||
.Does (() =>
|
||||
{
|
||||
RunMdocUpdate ("./binding/SkiaSharp.Generic/bin/Release/SkiaSharp.dll", "./docs/en/");
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NUGET - building the package for NuGet.org
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("nuget")
|
||||
.IsDependentOn ("libs")
|
||||
.Does (() =>
|
||||
{
|
||||
if (IsRunningOnWindows ()) {
|
||||
PackageNuGet ("./nuget/Xamarin.SkiaSharp.Windows.nuspec", "./output/");
|
||||
}
|
||||
|
||||
if (IsRunningOnUnix ()) {
|
||||
PackageNuGet ("./nuget/Xamarin.SkiaSharp.Mac.nuspec", "./output/");
|
||||
PackageNuGet ("./nuget/Xamarin.SkiaSharp.nuspec", "./output/");
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// COMPONENT - building the package for components.xamarin.com
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("component")
|
||||
.IsDependentOn ("nuget")
|
||||
.Does (() =>
|
||||
{
|
||||
// TODO: Not yet ready
|
||||
|
||||
// if (!DirectoryExists ("./output/")) {
|
||||
// CreateDirectory ("./output/");
|
||||
// }
|
||||
|
||||
// FilePath yaml = "./component/component.yaml";
|
||||
// var yamlDir = yaml.GetDirectory ();
|
||||
// PackageComponent (yamlDir, new XamarinComponentSettings {
|
||||
// ToolPath = XamarinComponentToolPath
|
||||
// });
|
||||
|
||||
// MoveFiles (yamlDir.FullPath.TrimEnd ('/') + "/*.xam", "./output/");
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CLEAN - remove all the build artefacts
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("clean")
|
||||
.IsDependentOn ("clean-externals")
|
||||
.Does (() =>
|
||||
{
|
||||
});
|
||||
CleanDirectories ("./binding/**/bin");
|
||||
CleanDirectories ("./binding/**/obj");
|
||||
|
||||
CleanDirectories ("./samples/**/bin");
|
||||
CleanDirectories ("./samples/**/obj");
|
||||
|
||||
CleanDirectories ("./tests/**/bin");
|
||||
CleanDirectories ("./tests/**/obj");
|
||||
|
||||
if (DirectoryExists ("./output"))
|
||||
DeleteDirectory ("./output", true);
|
||||
});
|
||||
Task ("clean-externals").Does (() =>
|
||||
{
|
||||
// skia
|
||||
|
@ -431,7 +597,37 @@ Task ("clean-externals").Does (() =>
|
|||
CleanDirectories ("native-builds/libskia_windows/x64/Release");
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DEFAULT - target for common development
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DefineDefaultTasks ();
|
||||
Task ("Default")
|
||||
.IsDependentOn ("externals")
|
||||
.IsDependentOn ("libs");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CI - the master target to build everything
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task ("CI")
|
||||
.IsDependentOn ("externals")
|
||||
.IsDependentOn ("libs")
|
||||
.IsDependentOn ("docs")
|
||||
.IsDependentOn ("nuget")
|
||||
.IsDependentOn ("component")
|
||||
.IsDependentOn ("tests")
|
||||
.IsDependentOn ("samples");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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);
|
||||
|
||||
ListEnvironmentVariables ();
|
||||
|
||||
RunTarget (TARGET);
|
||||
|
|
627
common.cake
627
common.cake
|
@ -1,627 +0,0 @@
|
|||
#addin "Cake.Xamarin"
|
||||
#addin "Cake.XCode"
|
||||
|
||||
#pragma warning disable 0169
|
||||
var NUGET_RESTORE_SOURCES = new [] { "https://www.nuget.org/api/v2/", "https://www.myget.org/F/xamprojectci/api/v2" };
|
||||
#pragma warning restore 0169
|
||||
|
||||
FilePath GetCakeToolPath ()
|
||||
{
|
||||
var appRootExe = Context.Environment.GetApplicationRoot ().CombineWithFilePath ("Cake.exe");
|
||||
|
||||
if (FileExists (appRootExe))
|
||||
return appRootExe;
|
||||
|
||||
var possibleExe = GetFiles ("../**/tools/Cake/Cake.exe").FirstOrDefault ();
|
||||
|
||||
if (possibleExe != null)
|
||||
return possibleExe;
|
||||
|
||||
var p = System.Diagnostics.Process.GetCurrentProcess ();
|
||||
return new FilePath (p.Modules[0].FileName);
|
||||
}
|
||||
|
||||
FilePath GetNUnitConsoleToolPath ()
|
||||
{
|
||||
var appRoot = Context.Environment.GetApplicationRoot ();
|
||||
|
||||
var consolePath = appRoot.Combine ("../").CombineWithFilePath ("NUnit.Console/tools/nunit3-console.exe");
|
||||
|
||||
if (FileExists (consolePath))
|
||||
return consolePath;
|
||||
|
||||
return GetFiles ("../../../**/nunit3-console.exe").FirstOrDefault ();
|
||||
}
|
||||
|
||||
FilePath GetNugetToolPath ()
|
||||
{
|
||||
if (IsRunningOnUnix ())
|
||||
return null;
|
||||
|
||||
var appRoot = Context.Environment.GetApplicationRoot ();
|
||||
|
||||
var nugetPath = appRoot.Combine ("../").CombineWithFilePath ("nuget.exe");
|
||||
|
||||
if (FileExists (nugetPath))
|
||||
return nugetPath;
|
||||
|
||||
return GetFiles ("../../../**/nuget.exe").FirstOrDefault ();
|
||||
}
|
||||
|
||||
FilePath GetXamarinComponentToolPath ()
|
||||
{
|
||||
var appRoot = Context.Environment.GetApplicationRoot();
|
||||
|
||||
var nugetPath = appRoot.Combine ("../").CombineWithFilePath ("xamarin-component.exe");
|
||||
|
||||
if (FileExists (nugetPath))
|
||||
return nugetPath;
|
||||
|
||||
return GetFiles ("../../../**/xamarin-component.exe").FirstOrDefault ();
|
||||
}
|
||||
|
||||
FilePath GetGenApiToolPath ()
|
||||
{
|
||||
var appRoot = Context.Environment.GetApplicationRoot();
|
||||
|
||||
var nugetPath = appRoot.Combine ("../").CombineWithFilePath ("genapi.exe");
|
||||
|
||||
if (FileExists (nugetPath))
|
||||
return nugetPath;
|
||||
|
||||
return GetFiles ("../../../**/genapi.exe").FirstOrDefault ();
|
||||
}
|
||||
|
||||
void CopyDirectory (DirectoryPath sourceDir, DirectoryPath destDir, bool overwrite = true, bool copySubDirs = true)
|
||||
{
|
||||
var sourceDirName = MakeAbsolute(sourceDir).FullPath;
|
||||
var destDirName = MakeAbsolute(destDir).FullPath;
|
||||
var dir = new DirectoryInfo(sourceDirName);
|
||||
|
||||
// If the source directory does not exist, throw an exception.
|
||||
if (!dir.Exists) {
|
||||
throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourceDirName);
|
||||
}
|
||||
|
||||
// If the destination directory does not exist, create it.
|
||||
if (!DirectoryExists(destDir)) {
|
||||
CreateDirectory(destDir);
|
||||
}
|
||||
|
||||
// Get the file contents of the directory to copy.
|
||||
foreach (FileInfo file in dir.GetFiles()) {
|
||||
file.CopyTo(destDir.CombineWithFilePath(file.Name).FullPath, false);
|
||||
}
|
||||
|
||||
// If copySubDirs is true, copy the subdirectories.
|
||||
if (copySubDirs) {
|
||||
foreach (DirectoryInfo subdir in dir.GetDirectories()) {
|
||||
CopyDirectory(subdir.FullName, destDir.Combine(subdir.Name).FullPath, copySubDirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the target to run in subfolders
|
||||
var TARGET = Argument ("t", Argument ("target", Argument ("Target", "Default")));
|
||||
|
||||
CakeStealer.CakeContext = Context;
|
||||
CakeStealer.NuGetSources = NUGET_RESTORE_SOURCES;
|
||||
CakeStealer.NugetToolPath = GetNugetToolPath ();
|
||||
CakeStealer.XamarinComponentToolPath = GetXamarinComponentToolPath ();
|
||||
CakeStealer.CakeToolPath = GetCakeToolPath ();
|
||||
CakeStealer.NUnitConsoleToolPath = GetNUnitConsoleToolPath ();
|
||||
CakeStealer.GenApiToolPath = GetGenApiToolPath ();
|
||||
|
||||
Information ("Cake.exe ToolPath: {0}", CakeStealer.CakeToolPath);
|
||||
Information ("Cake.exe NUnitConsoleToolPath: {0}", CakeStealer.NUnitConsoleToolPath);
|
||||
Information ("NuGet.exe ToolPath: {0}", CakeStealer.NugetToolPath);
|
||||
Information ("Xamarin-Component.exe ToolPath: {0}", CakeStealer.XamarinComponentToolPath);
|
||||
Information ("genapi.exe ToolPath: {0}", CakeStealer.GenApiToolPath);
|
||||
|
||||
void ListEnvironmentVariables ()
|
||||
{
|
||||
Information ("Environment Variables:");
|
||||
foreach (var envVar in EnvironmentVariables ()) {
|
||||
Information ("\tKey: {0}\tValue: \"{1}\"", envVar.Key, envVar.Value);
|
||||
}
|
||||
}
|
||||
ListEnvironmentVariables ();
|
||||
|
||||
public class CakeStealer
|
||||
{
|
||||
static public ICakeContext CakeContext { get; set; }
|
||||
static public string[] NuGetSources { get; set; }
|
||||
static public FilePath NugetToolPath { get;set; }
|
||||
static public FilePath XamarinComponentToolPath { get; set; }
|
||||
static public FilePath CakeToolPath { get;set; }
|
||||
static public FilePath NUnitConsoleToolPath { get;set; }
|
||||
static public FilePath GenApiToolPath { get;set; }
|
||||
}
|
||||
|
||||
public interface ISolutionBuilder
|
||||
{
|
||||
void BuildSolution ();
|
||||
void CopyOutput ();
|
||||
}
|
||||
|
||||
public class OutputFileCopy
|
||||
{
|
||||
public FilePath FromFile { get; set; }
|
||||
public DirectoryPath ToDirectory { get; set; }
|
||||
public FilePath NewFileName { get; set; }
|
||||
}
|
||||
|
||||
public class DefaultSolutionBuilder : CakeStealer, ISolutionBuilder
|
||||
{
|
||||
public DefaultSolutionBuilder ()
|
||||
{
|
||||
DefaultOutputDirectory = "./output";
|
||||
RestoreComponents = false;
|
||||
IsWindowsCompatible = false;
|
||||
IsMacCompatible = true;
|
||||
Platform = DefaultPlatform;
|
||||
Configuration = DefaultConfiguration;
|
||||
Properties = new Dictionary<string, List<string>> ();
|
||||
}
|
||||
|
||||
public string SolutionPath {get; set;}
|
||||
public bool IsWindowsCompatible { get; set; }
|
||||
public bool IsMacCompatible { get; set; }
|
||||
public Dictionary<string, List<string>> Properties { get; set; }
|
||||
public IEnumerable<string> Targets { get; set; }
|
||||
|
||||
public virtual string Configuration { get; set; }
|
||||
protected virtual string DefaultConfiguration { get {return "Release"; } }
|
||||
|
||||
public virtual string Platform { get; set; }
|
||||
protected virtual string DefaultPlatform { get {return "\"Any CPU\""; } }
|
||||
|
||||
public OutputFileCopy [] OutputFiles { get; set; }
|
||||
public virtual string DefaultOutputDirectory { get; set; }
|
||||
public virtual bool RestoreComponents { get; set; }
|
||||
|
||||
public Action PreBuildAction { get;set; }
|
||||
public Action PostBuildAction { get;set; }
|
||||
|
||||
public virtual bool CanBuildOnPlatform {
|
||||
get {
|
||||
if (CakeContext.IsRunningOnWindows () && !IsWindowsCompatible)
|
||||
return false;
|
||||
if (CakeContext.IsRunningOnUnix () && !IsMacCompatible)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void BuildSolution ()
|
||||
{
|
||||
if (!CanBuildOnPlatform) {
|
||||
CakeContext.Information ("Solution is not configured to build on this platform: {0}", SolutionPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PreBuildAction != null)
|
||||
PreBuildAction ();
|
||||
|
||||
if (RestoreComponents) {
|
||||
RunComponentRestore (SolutionPath);
|
||||
}
|
||||
|
||||
RunNuGetRestore (SolutionPath);
|
||||
RunBuild (SolutionPath);
|
||||
|
||||
if (PostBuildAction != null)
|
||||
PostBuildAction ();
|
||||
}
|
||||
|
||||
public static void RunNuGetRestore (FilePath solution)
|
||||
{
|
||||
CakeContext.NuGetRestore (solution, new NuGetRestoreSettings { Source = NuGetSources, ToolPath = NugetToolPath });
|
||||
}
|
||||
|
||||
public static void RunComponentRestore (FilePath solution)
|
||||
{
|
||||
CakeContext.RestoreComponents (solution, new XamarinComponentRestoreSettings {
|
||||
ToolPath = XamarinComponentToolPath
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void RunBuild (FilePath solution)
|
||||
{
|
||||
CakeContext.DotNetBuild (solution, c => {
|
||||
c.Configuration = Configuration;
|
||||
if (!string.IsNullOrEmpty (Platform))
|
||||
c.Properties ["Platform"] = new [] { Platform };
|
||||
if (Targets != null && Targets.Any ()) {
|
||||
foreach (var t in Targets)
|
||||
c.Targets.Add (t);
|
||||
}
|
||||
if (Properties != null && Properties.Any ()) {
|
||||
foreach (var kvp in Properties)
|
||||
c.Properties.Add (kvp.Key, kvp.Value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void CopyOutput ()
|
||||
{
|
||||
if (OutputFiles == null)
|
||||
return;
|
||||
|
||||
if (!CanBuildOnPlatform)
|
||||
return;
|
||||
|
||||
foreach (var fileCopy in OutputFiles) {
|
||||
FilePath targetFileName;
|
||||
|
||||
var targetDir = fileCopy.ToDirectory == null ? DefaultOutputDirectory : fileCopy.ToDirectory;
|
||||
CakeContext.CreateDirectory (targetDir);
|
||||
|
||||
if (fileCopy.NewFileName != null) {
|
||||
targetFileName = targetDir.CombineWithFilePath (fileCopy.NewFileName);
|
||||
} else {
|
||||
targetFileName = targetDir.CombineWithFilePath (fileCopy.FromFile.GetFilename ());
|
||||
}
|
||||
|
||||
var srcAbs = CakeContext.MakeAbsolute (fileCopy.FromFile);
|
||||
var destAbs = CakeContext.MakeAbsolute (targetFileName);
|
||||
|
||||
var sourceTime = System.IO.File.GetLastAccessTime (srcAbs.ToString ());
|
||||
var destTime = System.IO.File.GetLastAccessTime (destAbs.ToString ());
|
||||
|
||||
CakeContext.Information ("Target Dir: Exists? {0}, {1}", CakeContext.DirectoryExists (targetDir), targetDir);
|
||||
|
||||
CakeContext.Information ("Copy From: Exists? {0}, Dir Exists? {1}, Modified: {2}, {3}",
|
||||
CakeContext.FileExists (srcAbs), CakeContext.DirectoryExists (srcAbs.GetDirectory ()), sourceTime, srcAbs);
|
||||
CakeContext.Information ("Copy To: Exists? {0}, Dir Exists? {1}, Modified: {2}, {3}",
|
||||
CakeContext.FileExists (destAbs), CakeContext.DirectoryExists (destAbs.GetDirectory ()), destTime, destAbs);
|
||||
|
||||
if (sourceTime > destTime || !CakeContext.FileExists (destAbs)) {
|
||||
CakeContext.Information ("Copying File: {0} to {1}", srcAbs, targetDir);
|
||||
CakeContext.CopyFileToDirectory (srcAbs, targetDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class IOSSolutionBuilder : DefaultSolutionBuilder
|
||||
{
|
||||
protected override string DefaultPlatform { get { return "iPhone"; } }
|
||||
|
||||
public override void RunBuild (FilePath solution)
|
||||
{
|
||||
if (!CanBuildOnPlatform) {
|
||||
CakeContext.Information ("Solution is not configured to build on this platform: {0}", SolutionPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CakeContext.IsRunningOnUnix ()) {
|
||||
CakeContext.MDToolBuild (solution, c => {
|
||||
c.Configuration = Configuration;
|
||||
});
|
||||
} else {
|
||||
base.RunBuild (solution);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WpSolutionBuilder : DefaultSolutionBuilder
|
||||
{
|
||||
public WpSolutionBuilder () : base ()
|
||||
{
|
||||
IsWindowsCompatible = true;
|
||||
IsMacCompatible = false;
|
||||
}
|
||||
|
||||
protected override string DefaultPlatform { get { return ""; } }
|
||||
|
||||
public string WpPlatformTarget { get; set; }
|
||||
|
||||
|
||||
public override void RunBuild (FilePath solution)
|
||||
{
|
||||
if (!CanBuildOnPlatform) {
|
||||
CakeContext.Information ("Solution is not configured to build on this platform: {0}", SolutionPath);
|
||||
return;
|
||||
}
|
||||
|
||||
var buildTargets = "";
|
||||
if (Targets != null) {
|
||||
foreach (var t in Targets)
|
||||
buildTargets += "/target:" + t + " ";
|
||||
}
|
||||
|
||||
// We need to invoke MSBuild manually for now since Cake wants to set Platform=x86 if we use the x86 msbuild.exe version
|
||||
// and the amd64 msbuild.exe cannot be used to build windows phone projects
|
||||
// This should be fixable in cake 0.6.1
|
||||
var programFilesPath = CakeContext.Environment.GetSpecialPath(SpecialPath.ProgramFilesX86);
|
||||
var binPath = programFilesPath.Combine(string.Concat("MSBuild/", "14.0", "/Bin"));
|
||||
var msBuild = binPath.CombineWithFilePath("MSBuild.exe");
|
||||
|
||||
if (!CakeContext.FileExists (msBuild)) {
|
||||
binPath = programFilesPath.Combine(string.Concat("MSBuild/", "12.0", "/Bin"));
|
||||
msBuild = binPath.CombineWithFilePath("MSBuild.exe");
|
||||
}
|
||||
|
||||
CakeContext.StartProcess (msBuild, "/m /v:Normal /p:Configuration=Release " + buildTargets.Trim () + " \"" + CakeContext.MakeAbsolute (solution).ToString () + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
public class SolutionTestRunner : CakeStealer
|
||||
{
|
||||
public DefaultSolutionBuilder SolutionBuilder { get; set; }
|
||||
|
||||
public FilePath TestAssembly { get; set; }
|
||||
|
||||
public DirectoryPath TestDiectory { get; set; }
|
||||
|
||||
public void BuildSolution ()
|
||||
{
|
||||
SolutionBuilder.BuildSolution ();
|
||||
SolutionBuilder.CopyOutput ();
|
||||
}
|
||||
|
||||
public void RunTests ()
|
||||
{
|
||||
if (!SolutionBuilder.CanBuildOnPlatform) {
|
||||
CakeContext.Information ("Solution is not configured to run test on this platform: {0}", SolutionBuilder.SolutionPath);
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = TestDiectory == null ? TestAssembly.GetDirectory() : TestDiectory;
|
||||
var result = CakeContext.StartProcess(NUnitConsoleToolPath, new ProcessSettings {
|
||||
Arguments = string.Format ("\"{0}\" --work=\"{1}\"", TestAssembly, dir),
|
||||
});
|
||||
|
||||
if (result != 0) {
|
||||
throw new Exception ("NUnit test failed with error: " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CakeSpec
|
||||
{
|
||||
static CakeSpec ()
|
||||
{
|
||||
Libs = new ISolutionBuilder [] {};
|
||||
Tests = new SolutionTestRunner [] {};
|
||||
Samples = new ISolutionBuilder [] {};
|
||||
NuSpecs = new string [] {};
|
||||
}
|
||||
|
||||
static public ISolutionBuilder [] Libs { get; set; }
|
||||
static public SolutionTestRunner [] Tests { get; set; }
|
||||
static public ISolutionBuilder [] Samples { get; set; }
|
||||
static public string [] NuSpecs { get; set; }
|
||||
}
|
||||
|
||||
void RunMake (DirectoryPath directory, string target = "all")
|
||||
{
|
||||
StartProcess ("make", new ProcessSettings {
|
||||
Arguments = target,
|
||||
WorkingDirectory = directory,
|
||||
});
|
||||
}
|
||||
|
||||
void RunInstallNameTool (DirectoryPath directory, string oldName, string newName, FilePath library)
|
||||
{
|
||||
StartProcess ("install_name_tool", new ProcessSettings {
|
||||
Arguments = string.Format("-change {0} {1} \"{2}\"", oldName, newName, library),
|
||||
WorkingDirectory = directory,
|
||||
});
|
||||
}
|
||||
|
||||
void RunLipo (DirectoryPath directory, FilePath output, params FilePath[] inputs)
|
||||
{
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
void RunLibtoolStatic (DirectoryPath directory, FilePath output, params FilePath[] inputs)
|
||||
{
|
||||
var inputString = string.Join(" ", inputs.Select (i => string.Format ("\"{0}\"", i)));
|
||||
StartProcess ("libtool", new ProcessSettings {
|
||||
Arguments = string.Format("-static -o \"{0}\" {1}", output, inputString),
|
||||
WorkingDirectory = directory,
|
||||
});
|
||||
}
|
||||
|
||||
void BuildXCode (FilePath project, string target, string libraryTitle = null, FilePath fatLibrary = null, DirectoryPath workingDirectory = null)
|
||||
{
|
||||
libraryTitle = libraryTitle ?? target;
|
||||
fatLibrary = fatLibrary ?? string.Format("lib{0}.a", libraryTitle);
|
||||
workingDirectory = workingDirectory ?? Directory("./externals/");
|
||||
|
||||
var output = string.Format ("lib{0}.a", libraryTitle);
|
||||
var i386 = string.Format ("lib{0}-i386.a", libraryTitle);
|
||||
var x86_64 = string.Format ("lib{0}-x86_64.a", libraryTitle);
|
||||
var armv7 = string.Format ("lib{0}-armv7.a", libraryTitle);
|
||||
var armv7s = string.Format ("lib{0}-armv7s.a", libraryTitle);
|
||||
var arm64 = string.Format ("lib{0}-arm64.a", libraryTitle);
|
||||
|
||||
var buildArch = new Action<string, string, FilePath> ((sdk, arch, dest) => {
|
||||
if (!FileExists (dest)) {
|
||||
XCodeBuild (new XCodeBuildSettings {
|
||||
Project = workingDirectory.CombineWithFilePath (project).ToString (),
|
||||
Target = target,
|
||||
Sdk = sdk,
|
||||
Arch = arch,
|
||||
Configuration = "Release",
|
||||
});
|
||||
var outputPath = workingDirectory.Combine ("build").Combine ("Release-" + sdk).CombineWithFilePath (output);
|
||||
CopyFile (outputPath, dest);
|
||||
}
|
||||
});
|
||||
|
||||
buildArch ("iphonesimulator", "i386", workingDirectory.CombineWithFilePath (i386));
|
||||
buildArch ("iphonesimulator", "x86_64", workingDirectory.CombineWithFilePath (x86_64));
|
||||
|
||||
buildArch ("iphoneos", "armv7", workingDirectory.CombineWithFilePath (armv7));
|
||||
buildArch ("iphoneos", "armv7s", workingDirectory.CombineWithFilePath (armv7s));
|
||||
buildArch ("iphoneos", "arm64", workingDirectory.CombineWithFilePath (arm64));
|
||||
|
||||
RunLipo (workingDirectory, fatLibrary, i386, x86_64, armv7, armv7s, arm64);
|
||||
}
|
||||
|
||||
void CleanXCodeBuild (DirectoryPath projectRoot = null, DirectoryPath workingDirectory = null)
|
||||
{
|
||||
workingDirectory = workingDirectory ?? Directory ("./externals/");
|
||||
projectRoot = projectRoot ?? workingDirectory;
|
||||
|
||||
if (DirectoryExists (workingDirectory.Combine ("build")))
|
||||
DeleteDirectory (workingDirectory.Combine ("build"), true);
|
||||
|
||||
if (DirectoryExists (workingDirectory.Combine (projectRoot)))
|
||||
DeleteDirectory (workingDirectory.Combine (projectRoot), true);
|
||||
|
||||
DeleteFiles (System.IO.Path.Combine (workingDirectory.ToString (), "*.a"));
|
||||
}
|
||||
|
||||
void CreatePodfile (DirectoryPath podfilePath, string platform, string platformVersion, IDictionary<string, string> pods)
|
||||
{
|
||||
var builder = new StringBuilder ();
|
||||
builder.AppendFormat ("platform :{0}, '{1}'", platform, platformVersion);
|
||||
builder.AppendLine ();
|
||||
foreach (var pod in pods) {
|
||||
builder.AppendFormat ("pod '{0}', '{1}'", pod.Key, pod.Value);
|
||||
builder.AppendLine ();
|
||||
}
|
||||
|
||||
if (!DirectoryExists (podfilePath)) {
|
||||
CreateDirectory (podfilePath);
|
||||
}
|
||||
|
||||
System.IO.File.WriteAllText (podfilePath.CombineWithFilePath ("Podfile").ToString (), builder.ToString ());
|
||||
}
|
||||
|
||||
void BuildNuGets (string outputPath)
|
||||
{
|
||||
// NuGet messes up path on mac, so let's add ./ in front twice
|
||||
var basePath = IsRunningOnUnix () ? "././" : "./";
|
||||
|
||||
if (!DirectoryExists (outputPath)) {
|
||||
CreateDirectory (outputPath);
|
||||
}
|
||||
|
||||
foreach (var n in CakeSpec.NuSpecs) {
|
||||
NuGetPack (n, new NuGetPackSettings {
|
||||
Verbosity = NuGetVerbosity.Detailed,
|
||||
OutputDirectory = outputPath,
|
||||
BasePath = basePath,
|
||||
ToolPath = CakeStealer.NugetToolPath
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void DefineDefaultTasks ()
|
||||
{
|
||||
Task ("libs-base").Does (() =>
|
||||
{
|
||||
foreach (var l in CakeSpec.Libs) {
|
||||
l.BuildSolution ();
|
||||
l.CopyOutput ();
|
||||
}
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "libs").Any ())
|
||||
{
|
||||
Task ("libs").IsDependentOn ("externals").IsDependentOn ("libs-base");
|
||||
}
|
||||
|
||||
Task ("tests-base").Does (() =>
|
||||
{
|
||||
foreach (var t in CakeSpec.Tests) {
|
||||
t.BuildSolution ();
|
||||
t.RunTests ();
|
||||
}
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "tests").Any ())
|
||||
{
|
||||
Task ("tests").IsDependentOn ("libs").IsDependentOn ("tests-base");
|
||||
}
|
||||
|
||||
Task ("samples-base").Does (() =>
|
||||
{
|
||||
foreach (var s in CakeSpec.Samples) {
|
||||
s.BuildSolution ();
|
||||
s.CopyOutput ();
|
||||
}
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "samples").Any ())
|
||||
{
|
||||
Task ("samples").IsDependentOn ("libs").IsDependentOn ("samples-base");
|
||||
}
|
||||
|
||||
Task ("nuget-base").Does (() =>
|
||||
{
|
||||
BuildNuGets ("./output");
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "nuget").Any ())
|
||||
{
|
||||
Task ("nuget").IsDependentOn ("libs").IsDependentOn ("nuget-base");
|
||||
}
|
||||
|
||||
Task ("component-base").IsDependentOn ("nuget").Does (() =>
|
||||
{
|
||||
// Clear out existing .xam files
|
||||
if (!DirectoryExists ("./output/"))
|
||||
CreateDirectory ("./output/");
|
||||
DeleteFiles ("./output/*.xam");
|
||||
|
||||
// Look for all the component.yaml files to build
|
||||
var componentYamls = GetFiles ("./**/component.yaml");
|
||||
foreach (var yaml in componentYamls) {
|
||||
var yamlDir = yaml.GetDirectory ();
|
||||
|
||||
PackageComponent (yamlDir, new XamarinComponentSettings {
|
||||
ToolPath = CakeStealer.XamarinComponentToolPath
|
||||
});
|
||||
|
||||
MoveFiles (yamlDir.FullPath.TrimEnd ('/') + "/*.xam", "./output/");
|
||||
}
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "component").Any ())
|
||||
{
|
||||
Task ("component").IsDependentOn ("nuget").IsDependentOn ("component-base");
|
||||
}
|
||||
|
||||
Task ("externals-base");
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "externals").Any ())
|
||||
{
|
||||
Task ("externals").IsDependentOn ("externals-base");
|
||||
}
|
||||
|
||||
Task ("clean-base").Does (() =>
|
||||
{
|
||||
CleanDirectories ("./**/bin");
|
||||
CleanDirectories ("./**/obj");
|
||||
|
||||
if (DirectoryExists ("./output"))
|
||||
DeleteDirectory ("./output", true);
|
||||
});
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "clean").Any ())
|
||||
{
|
||||
Task ("clean").IsDependentOn ("clean-base");
|
||||
}
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "Default").Any ())
|
||||
{
|
||||
Task ("Default").IsDependentOn ("libs");
|
||||
}
|
||||
|
||||
if (!Tasks.Where (tsk => tsk.Name == "CI").Any ())
|
||||
{
|
||||
Task ("CI").IsDependentOn ("libs").IsDependentOn ("component").IsDependentOn ("tests").IsDependentOn ("samples");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,26 +29,26 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче