2016-01-14 07:42:16 +03:00
|
|
|
#addin "Cake.Xamarin"
|
|
|
|
#addin "Cake.XCode"
|
|
|
|
|
|
|
|
using System.Xml;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var TARGET = Argument ("t", Argument ("target", Argument ("Target", "Default")));
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
var RunGyp = new Action (() =>
|
|
|
|
{
|
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-01-14 07:42:16 +03:00
|
|
|
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-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) =>
|
|
|
|
{
|
|
|
|
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) =>
|
|
|
|
{
|
|
|
|
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) =>
|
|
|
|
{
|
|
|
|
// NuGet messes up path on mac, so let's add ./ in front twice
|
|
|
|
var basePath = IsRunningOnUnix () ? "././" : "./";
|
2016-01-15 03:18:32 +03:00
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
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,
|
|
|
|
BasePath = basePath,
|
|
|
|
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 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-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 00:14:48 +03:00
|
|
|
});
|
|
|
|
// this builds the managed PCL external
|
|
|
|
Task ("externals-genapi")
|
|
|
|
.IsDependentOn ("externals-windows")
|
|
|
|
.IsDependentOn ("externals-osx")
|
|
|
|
.IsDependentOn ("externals-ios")
|
|
|
|
.IsDependentOn ("externals-android")
|
|
|
|
.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-02-23 00:14:48 +03:00
|
|
|
// this builds the native C and C++ externals for Windows
|
2016-01-15 15:24:57 +03:00
|
|
|
Task ("externals-windows")
|
|
|
|
.WithCriteria (IsRunningOnWindows ())
|
|
|
|
.WithCriteria (
|
|
|
|
!FileExists ("native-builds/lib/windows/x86/libskia_windows.dll") ||
|
|
|
|
!FileExists ("native-builds/lib/windows/x64/libskia_windows.dll"))
|
|
|
|
.Does (() =>
|
2016-01-14 07:42:16 +03:00
|
|
|
{
|
|
|
|
var fixup = new Action (() => {
|
|
|
|
var props = SKIA_PATH.Combine ("out/gyp/libjpeg-turbo.props").FullPath;
|
|
|
|
var xdoc = XDocument.Load (props);
|
|
|
|
var ns = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003";
|
|
|
|
var temp = xdoc.Root
|
|
|
|
.Elements (ns + "ItemDefinitionGroup")
|
|
|
|
.Elements (ns + "assemble")
|
|
|
|
.Elements (ns + "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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
2016-01-15 00:41:16 +03:00
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
|
|
|
SetEnvironmentVariable ("GYP_GENERATORS", "ninja,msvs");
|
2016-01-14 07:42:16 +03:00
|
|
|
|
2016-01-15 00:41:16 +03:00
|
|
|
// build the x86 vesion
|
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='x86'");
|
|
|
|
RunGyp ();
|
|
|
|
fixup ();
|
|
|
|
DotNetBuild ("native-builds/libskia_windows/libskia_windows_x86.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "Win32" };
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/windows/x86")) {
|
2016-01-14 07:42:16 +03:00
|
|
|
CreateDirectory ("native-builds/lib/windows/x86");
|
|
|
|
}
|
2016-01-15 00:41:16 +03:00
|
|
|
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");
|
|
|
|
|
|
|
|
// build the x64 vesion
|
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='x86_64'");
|
|
|
|
RunGyp ();
|
|
|
|
fixup ();
|
|
|
|
DotNetBuild ("native-builds/libskia_windows/libskia_windows_x64.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "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");
|
2016-02-23 00:14:48 +03:00
|
|
|
|
|
|
|
// copy native output
|
|
|
|
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/");
|
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 Mac OS X
|
2016-01-15 15:24:57 +03:00
|
|
|
Task ("externals-osx")
|
|
|
|
.WithCriteria (IsRunningOnUnix ())
|
|
|
|
.WithCriteria (
|
2016-02-02 20:38:48 +03:00
|
|
|
!FileExists ("native-builds/lib/osx/libskia_osx.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) => {
|
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='" + skiaArch + "'");
|
|
|
|
RunGyp ();
|
|
|
|
|
2016-01-15 00:41:16 +03:00
|
|
|
XCodeBuild (new XCodeBuildSettings {
|
|
|
|
Project = "native-builds/libskia_osx/libskia_osx.xcodeproj",
|
|
|
|
Target = "libskia_osx",
|
|
|
|
Sdk = "macosx",
|
|
|
|
Arch = arch,
|
|
|
|
Configuration = "Release",
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/osx/" + arch)) {
|
|
|
|
CreateDirectory ("native-builds/lib/osx/" + arch);
|
|
|
|
}
|
|
|
|
CopyDirectory ("native-builds/libskia_osx/build/Release/", "native-builds/lib/osx/" + arch);
|
2016-02-02 20:38:48 +03:00
|
|
|
RunInstallNameTool ("native-builds/lib/osx/" + arch, "lib/libskia_osx.dylib", "@loader_path/libskia_osx.dylib", "libskia_osx.dylib");
|
2016-01-15 00:41:16 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
|
|
|
SetEnvironmentVariable ("GYP_GENERATORS", "ninja,xcode");
|
|
|
|
|
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-02-23 00:14:48 +03:00
|
|
|
RunLipo ("native-builds/lib/osx/", "libskia_osx.dylib", new [] {
|
|
|
|
(FilePath) "i386/libskia_osx.dylib",
|
|
|
|
(FilePath) "x86_64/libskia_osx.dylib"
|
|
|
|
});
|
|
|
|
|
|
|
|
// copy native output
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/osx/");
|
|
|
|
CopyFileToDirectory ("./native-builds/lib/osx/libskia_osx.dylib", "./output/mac/");
|
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 (
|
|
|
|
!FileExists ("native-builds/lib/ios/libskia_ios.framework/libskia_ios"))
|
|
|
|
.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 {
|
|
|
|
Project = "native-builds/libskia_ios/libskia_ios.xcodeproj",
|
|
|
|
Target = "libskia_ios",
|
|
|
|
Sdk = sdk,
|
|
|
|
Arch = arch,
|
|
|
|
Configuration = "Release",
|
|
|
|
});
|
|
|
|
if (!DirectoryExists ("native-builds/lib/ios/" + arch)) {
|
|
|
|
CreateDirectory ("native-builds/lib/ios/" + arch);
|
|
|
|
}
|
|
|
|
CopyDirectory ("native-builds/libskia_ios/build/Release-" + sdk, "native-builds/lib/ios/" + arch);
|
|
|
|
});
|
|
|
|
|
|
|
|
// set up the gyp environment variables
|
|
|
|
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
|
|
|
|
SetEnvironmentVariable ("GYP_DEFINES", "skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0");
|
|
|
|
SetEnvironmentVariable ("GYP_GENERATORS", "ninja,xcode");
|
|
|
|
|
|
|
|
RunGyp ();
|
|
|
|
|
|
|
|
buildArch ("iphonesimulator", "i386");
|
|
|
|
buildArch ("iphonesimulator", "x86_64");
|
|
|
|
buildArch ("iphoneos", "armv7");
|
|
|
|
buildArch ("iphoneos", "armv7s");
|
|
|
|
buildArch ("iphoneos", "arm64");
|
|
|
|
|
|
|
|
// 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");
|
2016-02-23 00:14:48 +03:00
|
|
|
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"
|
|
|
|
});
|
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 (
|
|
|
|
!FileExists ("native-builds/lib/android/x86/libskia_android.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/x86_64/libskia_android.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/armeabi/libskia_android.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/armeabi-v7a/libskia_android.so") ||
|
|
|
|
!FileExists ("native-builds/lib/android/arm64-v8a/libskia_android.so"))
|
|
|
|
.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 {
|
|
|
|
Arguments = "-d " + arch + " \"skia_lib\"",
|
|
|
|
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 = "",
|
|
|
|
WorkingDirectory = ROOT_PATH.Combine ("native-builds/libskia_android").FullPath,
|
|
|
|
});
|
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);
|
|
|
|
}
|
|
|
|
CopyFileToDirectory ("native-builds/libskia_android/libs/" + folder + "/libskia_android.so", "native-builds/lib/android/" + folder);
|
|
|
|
}
|
2016-01-14 07:42:16 +03:00
|
|
|
});
|
|
|
|
|
2016-02-23 00:14:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LIBS - the managed C# libraries
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("libs")
|
|
|
|
.IsDependentOn ("libs-windows")
|
|
|
|
.IsDependentOn ("libs-osx")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
});
|
|
|
|
Task ("libs-windows")
|
|
|
|
.WithCriteria (IsRunningOnWindows ())
|
|
|
|
.IsDependentOn ("externals")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
// build
|
|
|
|
NuGetRestore ("binding/SkiaSharp.Windows.sln", new NuGetRestoreSettings { ToolPath = NugetToolPath });
|
|
|
|
DotNetBuild ("binding/SkiaSharp.Windows.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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
|
|
|
|
NuGetRestore ("binding/SkiaSharp.Mac.sln", new NuGetRestoreSettings { ToolPath = NugetToolPath });
|
|
|
|
DotNetBuild ("binding/SkiaSharp.Mac.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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/");
|
|
|
|
CopyFileToDirectory ("./binding/SkiaSharp.Desktop/bin/Release/mac/libskia_osx.dylib", "./output/mac/");
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TESTS - some test cases to make sure it works
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("tests")
|
|
|
|
.IsDependentOn ("libs")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
// 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";
|
|
|
|
c.Properties ["Platform"] = new [] { "\"Any CPU\"" };
|
|
|
|
});
|
|
|
|
RunTests("./tests/SkiaSharp.Desktop.Tests/bin/x86/Release/SkiaSharp.Desktop.Tests.dll");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SAMPLES - the demo apps showing off the work
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Task ("samples")
|
|
|
|
.IsDependentOn ("libs")
|
|
|
|
.Does (() =>
|
|
|
|
{
|
|
|
|
if (IsRunningOnUnix ()) {
|
|
|
|
DotNetBuild ("./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
});
|
|
|
|
DotNetBuild ("./samples/Skia.Forms.Demo/Skia.Forms.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "iPhone" };
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DotNetBuild ("./samples/Skia.WindowsDesktop.Demo/Skia.WindowsDesktop.Demo.sln", c => {
|
|
|
|
c.Configuration = "Release";
|
|
|
|
c.Properties ["Platform"] = new [] { "x86" };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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 (() =>
|
|
|
|
{
|
|
|
|
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
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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
|
|
|
|
CleanDirectories ("native-builds/libskia_android/obj");
|
|
|
|
CleanDirectories ("native-builds/libskia_android/libs");
|
|
|
|
// ios
|
|
|
|
CleanDirectories ("native-builds/libskia_ios/build");
|
|
|
|
// osx
|
|
|
|
CleanDirectories ("native-builds/libskia_osx/build");
|
|
|
|
// windows
|
|
|
|
CleanDirectories ("native-builds/libskia_windows/Release");
|
|
|
|
CleanDirectories ("native-builds/libskia_windows/x64/Release");
|
|
|
|
});
|
|
|
|
|
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")
|
|
|
|
.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);
|
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);
|