SkiaSharp/cake/BuildExternals.cake

889 строки
38 KiB
Plaintext
Исходник Обычный вид История

////////////////////////////////////////////////////////////////////////////////////////////////////
// TOOLS & FUNCTIONS - the bits to make it all work
////////////////////////////////////////////////////////////////////////////////////////////////////
var InjectCompatibilityExternals = new Action<bool> ((inject) => {
// some methods don't yet exist, so we must add the compat layer to them.
// we need this as we can't modify the third party files
// all we do is insert our header before all the others
var compatHeader = "native-builds/src/WinRTCompat.h";
var compatSource = "native-builds/src/WinRTCompat.c";
var files = new Dictionary<FilePath, string> {
{ "externals/skia/third_party/externals/dng_sdk/source/dng_string.cpp", "#if qWinOS" },
{ "externals/skia/third_party/externals/dng_sdk/source/dng_utils.cpp", "#if qWinOS" },
{ "externals/skia/third_party/externals/dng_sdk/source/dng_pthread.cpp", "#if qWinOS" },
{ "externals/skia/third_party/externals/zlib/deflate.c", "#include <assert.h>" },
{ "externals/skia/third_party/externals/libjpeg-turbo/simd/jsimd_x86_64.c", "#define JPEG_INTERNALS" },
{ "externals/skia/third_party/externals/libjpeg-turbo/simd/jsimd_i386.c", "#define JPEG_INTERNALS" },
{ "externals/skia/third_party/externals/libjpeg-turbo/simd/jsimd_arm.c", "#define JPEG_INTERNALS" },
{ "externals/skia/third_party/externals/libjpeg-turbo/simd/jsimd_arm64.c", "#define JPEG_INTERNALS" },
};
foreach (var filePair in files) {
var file = filePair.Key;
if (!FileExists (file))
continue;
var root = string.Join ("/", file.GetDirectory ().Segments.Select (x => ".."));
var include = "#include \"" + root + "/" + compatHeader + "\"";
var contents = FileReadLines (file).ToList ();
var index = contents.IndexOf (include);
if (index == -1 && inject) {
Information ("Injecting modifications into third party code: {0}...", file);
if (string.IsNullOrEmpty (filePair.Value)) {
contents.Insert (0, include);
} else {
contents.Insert (contents.IndexOf (filePair.Value), include);
}
FileWriteLines (file, contents.ToArray ());
} else if (index != -1 && !inject) {
Information ("Removing injected modifications from third party code: {0}...", file);
int idx = 0;
if (string.IsNullOrEmpty (filePair.Value)) {
idx = 0;
} else {
idx = contents.IndexOf (filePair.Value) - 1;
}
if (contents [idx] == include) {
contents.RemoveAt (idx);
}
FileWriteLines (file, contents.ToArray ());
}
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
// EXTERNALS - the native C and C++ libraries
////////////////////////////////////////////////////////////////////////////////////////////////////
Task ("externals-init")
.IsDependentOn ("externals-angle-uwp")
.IsDependentOn ("externals-harfbuzz")
.Does (() =>
{
RunProcess (PythonToolPath, new ProcessSettings {
Arguments = SKIA_PATH.CombineWithFilePath ("tools/git-sync-deps").FullPath,
WorkingDirectory = SKIA_PATH.FullPath,
});
// insert compatibility modifications for external code
InjectCompatibilityExternals (true);
});
// this builds the native C and C++ externals
Task ("externals-native")
.IsDependentOn ("externals-uwp")
.IsDependentOn ("externals-windows")
.IsDependentOn ("externals-osx")
.IsDependentOn ("externals-ios")
.IsDependentOn ("externals-tvos")
.IsDependentOn ("externals-watchos")
.IsDependentOn ("externals-android")
2017-01-25 01:33:42 +03:00
.IsDependentOn ("externals-linux")
.Does (() =>
{
// copy all the native files into the output
CopyDirectory ("./native-builds/lib/", "./output/native/");
// copy ANGLE externals
EnsureDirectoryExists ("./output/native/uwp/arm/");
EnsureDirectoryExists ("./output/native/uwp/x86/");
EnsureDirectoryExists ("./output/native/uwp/x64/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/ARM/libEGL.dll"), "./output/native/uwp/arm/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/ARM/libGLESv2.dll"), "./output/native/uwp/arm/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/Win32/libEGL.dll"), "./output/native/uwp/x86/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/Win32/libGLESv2.dll"), "./output/native/uwp/x86/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/x64/libEGL.dll"), "./output/native/uwp/x64/");
CopyFileToDirectory (ANGLE_PATH.CombineWithFilePath ("uwp/bin/UAP/x64/libGLESv2.dll"), "./output/native/uwp/x64/");
});
// this builds the native C and C++ externals for Windows
Task ("externals-windows")
2017-03-16 15:57:43 +03:00
.IsDependentOn ("externals-init")
.WithCriteria (IsRunningOnWindows ())
.Does (() =>
{
// libSkiaSharp
2017-03-16 15:57:43 +03:00
var buildArch = new Action<string, string, string> ((arch, skiaArch, dir) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn.exe"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/win/" + arch + " " +
"--args=\"" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\\\"win\\\" target_cpu=\\\"" + skiaArch + "\\\"" +
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true skia_use_dng_sdk=true" +
2017-07-11 16:01:04 +03:00
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
2017-05-14 22:49:49 +03:00
" extra_cflags=[ \\\"-DSKIA_C_DLL\\\", \\\"/MD\\\", \\\"/EHsc\\\", \\\"/Zi\\\" ]" +
" extra_ldflags=[ \\\"/DEBUG\\\" ]" +
2017-03-18 16:03:10 +03:00
"\"",
2017-03-16 15:57:43 +03:00
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja.exe"), new ProcessSettings {
Arguments = "-C out/win/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
2017-03-16 15:57:43 +03:00
// build libSkiaSharp
2017-05-12 19:25:21 +03:00
RunMSBuildWithPlatformTarget ("native-builds/libSkiaSharp_windows/libSkiaSharp.sln", arch);
2017-03-16 15:57:43 +03:00
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/windows/" + dir);
2017-03-16 15:57:43 +03:00
CopyFileToDirectory ("native-builds/libSkiaSharp_windows/bin/" + arch + "/Release/libSkiaSharp.dll", "native-builds/lib/windows/" + dir);
CopyFileToDirectory ("native-builds/libSkiaSharp_windows/bin/" + arch + "/Release/libSkiaSharp.pdb", "native-builds/lib/windows/" + dir);
});
buildArch ("Win32", "x86", "x86");
2017-03-16 15:57:43 +03:00
buildArch ("x64", "x64", "x64");
// libHarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((arch, dir) => {
// build libHarfBuzzSharp
2017-05-12 19:25:21 +03:00
RunMSBuildWithPlatformTarget ("native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.sln", arch);
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/windows/" + dir);
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_windows/bin/" + arch + "/Release/libHarfBuzzSharp.dll", "native-builds/lib/windows/" + dir);
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_windows/bin/" + arch + "/Release/libHarfBuzzSharp.pdb", "native-builds/lib/windows/" + dir);
});
buildHarfBuzzArch ("Win32", "x86");
buildHarfBuzzArch ("x64", "x64");
});
// this builds the native C and C++ externals for Windows UWP
Task ("externals-uwp")
2017-03-16 15:57:43 +03:00
.IsDependentOn ("externals-init")
.WithCriteria (IsRunningOnWindows ())
.Does (() =>
{
// libSkiaSharp
2017-03-16 15:57:43 +03:00
var buildArch = new Action<string, string, string> ((arch, skiaArch, dir) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn.exe"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/winrt/" + arch + " " +
"--args=\"" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\\\"winrt\\\" target_cpu=\\\"" + skiaArch + "\\\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
2017-03-18 16:03:10 +03:00
" extra_cflags=[ " +
2017-05-14 22:49:49 +03:00
" \\\"-DSKIA_C_DLL\\\", \\\"/MD\\\", \\\"/EHsc\\\", \\\"/Zi\\\", " +
2017-03-18 16:03:10 +03:00
" \\\"-DWINAPI_FAMILY=WINAPI_FAMILY_APP\\\", \\\"-DSK_BUILD_FOR_WINRT\\\", \\\"-DSK_HAS_DWRITE_1_H\\\", \\\"-DSK_HAS_DWRITE_2_H\\\", \\\"-DNO_GETENV\\\" ]" +
2017-05-14 22:49:49 +03:00
" extra_ldflags=[ \\\"/APPCONTAINER\\\", \\\"/DEBUG\\\" ]" +
2017-03-18 16:03:10 +03:00
"\"",
2017-03-16 15:57:43 +03:00
WorkingDirectory = SKIA_PATH.FullPath,
});
2017-03-16 15:57:43 +03:00
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja.exe"), new ProcessSettings {
Arguments = "-C out/winrt/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
2017-03-16 15:57:43 +03:00
// build libSkiaSharp
2017-05-12 19:25:21 +03:00
RunMSBuildWithPlatformTarget ("native-builds/libSkiaSharp_uwp/libSkiaSharp.sln", arch);
2017-03-16 15:57:43 +03:00
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/uwp/" + dir);
2017-03-16 15:57:43 +03:00
CopyFileToDirectory ("native-builds/libSkiaSharp_uwp/bin/" + arch + "/Release/libSkiaSharp.dll", "native-builds/lib/uwp/" + dir);
CopyFileToDirectory ("native-builds/libSkiaSharp_uwp/bin/" + arch + "/Release/libSkiaSharp.pdb", "native-builds/lib/uwp/" + dir);
});
buildArch ("x64", "x64", "x64");
buildArch ("Win32", "x86", "x86");
buildArch ("ARM", "arm", "ARM");
// libHarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((arch, dir) => {
// build libHarfBuzzSharp
2017-05-12 19:25:21 +03:00
RunMSBuildWithPlatformTarget ("native-builds/libHarfBuzzSharp_uwp/libHarfBuzzSharp.sln", arch);
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/uwp/" + dir);
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_uwp/bin/" + arch + "/Release/libHarfBuzzSharp.dll", "native-builds/lib/uwp/" + dir);
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_uwp/bin/" + arch + "/Release/libHarfBuzzSharp.pdb", "native-builds/lib/uwp/" + dir);
});
buildHarfBuzzArch ("Win32", "x86");
buildHarfBuzzArch ("x64", "x64");
buildHarfBuzzArch ("ARM", "arm");
});
// this builds the native C and C++ externals for Mac OS X
Task ("externals-osx")
.IsDependentOn ("externals-init")
2017-01-11 07:35:43 +03:00
.WithCriteria (IsRunningOnMac ())
.Does (() =>
{
2017-04-28 23:03:23 +03:00
// SkiaSharp
var buildArch = new Action<string, string> ((arch, skiaArch) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/mac/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"mac\" target_cpu=\"" + skiaArch + "\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
" extra_cflags=[ \"-DSKIA_C_DLL\", \"-mmacosx-version-min=10.9\" ]" +
2017-03-18 16:03:10 +03:00
" extra_ldflags=[ \"-Wl,macosx_version_min=10.9\" ]" +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/mac/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
// build libSkiaSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libSkiaSharp_osx/libSkiaSharp.xcodeproj",
Target = "libSkiaSharp",
Sdk = "macosx",
Arch = arch,
Configuration = "Release",
});
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/osx/" + arch);
CopyDirectory ("native-builds/libSkiaSharp_osx/build/Release/", "native-builds/lib/osx/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libSkiaSharp.dylib",
WorkingDirectory = "native-builds/lib/osx/" + arch,
});
// re-sign with empty
RunProcess ("codesign", new ProcessSettings {
Arguments = "--force --sign - --timestamp=none libSkiaSharp.dylib",
WorkingDirectory = "native-builds/lib/osx/" + arch,
});
});
buildArch ("i386", "x86");
buildArch ("x86_64", "x64");
2017-04-28 23:03:23 +03:00
// create the fat dylib
RunLipo ("native-builds/lib/osx/", "libSkiaSharp.dylib", new [] {
(FilePath) "i386/libSkiaSharp.dylib",
(FilePath) "x86_64/libSkiaSharp.dylib"
});
2017-04-28 23:03:23 +03:00
// HarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((arch, skiaArch) => {
// build libHarfBuzzSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libHarfBuzzSharp_osx/libHarfBuzzSharp.xcodeproj",
Target = "libHarfBuzzSharp",
Sdk = "macosx",
Arch = arch,
Configuration = "Release",
});
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/osx/" + arch);
2017-04-28 23:03:23 +03:00
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_osx/build/Release/libHarfBuzzSharp.dylib", "native-builds/lib/osx/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libHarfBuzzSharp.dylib",
WorkingDirectory = "native-builds/lib/osx/" + arch,
});
// re-sign with empty
RunProcess ("codesign", new ProcessSettings {
Arguments = "--force --sign - --timestamp=none libHarfBuzzSharp.dylib",
WorkingDirectory = "native-builds/lib/osx/" + arch,
});
});
buildHarfBuzzArch ("i386", "x86");
buildHarfBuzzArch ("x86_64", "x64");
// create the fat dylib
RunLipo ("native-builds/lib/osx/", "libHarfBuzzSharp.dylib", new [] {
(FilePath) "i386/libHarfBuzzSharp.dylib",
(FilePath) "x86_64/libHarfBuzzSharp.dylib"
});
});
// this builds the native C and C++ externals for iOS
Task ("externals-ios")
.IsDependentOn ("externals-init")
2017-01-11 07:35:43 +03:00
.WithCriteria (IsRunningOnMac ())
.Does (() =>
{
2017-04-28 23:03:23 +03:00
// SkiaSharp
var buildArch = new Action<string, string, string> ((sdk, arch, skiaArch) => {
// generate native skia build files
var specifics = "";
// several instances of "error: type 'XXX' requires 8 bytes of alignment and the default allocator only guarantees 4 bytes [-Werror,-Wover-aligned]
// https://groups.google.com/forum/#!topic/skia-discuss/hU1IPFwU6bI
if (arch == "armv7" || arch == "armv7s") {
2017-03-18 16:03:10 +03:00
specifics += ", \"-Wno-over-aligned\"";
}
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/ios/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"ios\" target_cpu=\"" + skiaArch + "\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
" extra_cflags=[ \"-DSKIA_C_DLL\", \"-mios-version-min=8.0\" " + specifics + " ]" +
2017-03-18 16:03:10 +03:00
" extra_ldflags=[ \"-Wl,ios_version_min=8.0\" ]" +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/ios/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
// build libSkiaSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libSkiaSharp_ios/libSkiaSharp.xcodeproj",
Target = "libSkiaSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/ios/" + arch);
CopyDirectory ("native-builds/libSkiaSharp_ios/build/Release-" + sdk, "native-builds/lib/ios/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libSkiaSharp",
WorkingDirectory = "native-builds/lib/ios/" + arch + "/libSkiaSharp.framework",
});
// re-sign with empty
RunProcess ("codesign", new ProcessSettings {
Arguments = "--force --sign - --timestamp=none libSkiaSharp.framework",
WorkingDirectory = "native-builds/lib/ios/" + arch,
});
});
buildArch ("iphonesimulator", "i386", "x86");
buildArch ("iphonesimulator", "x86_64", "x64");
buildArch ("iphoneos", "armv7", "arm");
buildArch ("iphoneos", "arm64", "arm64");
// create the fat framework
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) "arm64/libSkiaSharp.framework/libSkiaSharp"
});
2017-04-28 23:03:23 +03:00
// HarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((sdk, arch) => {
// build libHarfBuzzSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libHarfBuzzSharp_ios/libHarfBuzzSharp.xcodeproj",
Target = "libHarfBuzzSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libHarfBuzzSharp_ios to output
EnsureDirectoryExists ("native-builds/lib/ios/" + arch);
2017-04-28 23:03:23 +03:00
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_ios/build/Release-" + sdk + "/libHarfBuzzSharp.a", "native-builds/lib/ios/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libHarfBuzzSharp.a",
WorkingDirectory = "native-builds/lib/ios/" + arch,
});
});
buildHarfBuzzArch ("iphonesimulator", "i386");
buildHarfBuzzArch ("iphonesimulator", "x86_64");
buildHarfBuzzArch ("iphoneos", "armv7");
buildHarfBuzzArch ("iphoneos", "arm64");
// create the fat archive
RunLipo ("native-builds/lib/ios/", "libHarfBuzzSharp.a", new [] {
(FilePath) "i386/libHarfBuzzSharp.a",
(FilePath) "x86_64/libHarfBuzzSharp.a",
(FilePath) "armv7/libHarfBuzzSharp.a",
(FilePath) "arm64/libHarfBuzzSharp.a"
});
});
// this builds the native C and C++ externals for tvOS
Task ("externals-tvos")
.IsDependentOn ("externals-init")
2017-01-11 07:35:43 +03:00
.WithCriteria (IsRunningOnMac ())
.Does (() =>
{
2017-04-28 23:03:23 +03:00
// SkiaSharp
var buildArch = new Action<string, string, string> ((sdk, arch, skiaArch) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/tvos/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"tvos\" target_cpu=\"" + skiaArch + "\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
2017-07-11 21:19:51 +03:00
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
" extra_cflags=[ \"-DSK_BUILD_FOR_TVOS\", \"-DSKIA_C_DLL\", \"-mtvos-version-min=9.0\" ]" +
2017-03-18 16:03:10 +03:00
" extra_ldflags=[ \"-Wl,tvos_version_min=9.0\" ]" +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/tvos/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
// build libSkiaSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libSkiaSharp_tvos/libSkiaSharp.xcodeproj",
Target = "libSkiaSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/tvos/" + arch);
CopyDirectory ("native-builds/libSkiaSharp_tvos/build/Release-" + sdk, "native-builds/lib/tvos/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libSkiaSharp",
WorkingDirectory = "native-builds/lib/tvos/" + arch + "/libSkiaSharp.framework",
});
// re-sign with empty
RunProcess ("codesign", new ProcessSettings {
Arguments = "--force --sign - --timestamp=none libSkiaSharp.framework",
WorkingDirectory = "native-builds/lib/tvos/" + arch,
});
});
buildArch ("appletvsimulator", "x86_64", "x64");
buildArch ("appletvos", "arm64", "arm64");
// create the fat framework
CopyDirectory ("native-builds/lib/tvos/arm64/libSkiaSharp.framework/", "native-builds/lib/tvos/libSkiaSharp.framework/");
DeleteFile ("native-builds/lib/tvos/libSkiaSharp.framework/libSkiaSharp");
RunLipo ("native-builds/lib/tvos/", "libSkiaSharp.framework/libSkiaSharp", new [] {
(FilePath) "x86_64/libSkiaSharp.framework/libSkiaSharp",
(FilePath) "arm64/libSkiaSharp.framework/libSkiaSharp"
});
2017-04-28 23:03:23 +03:00
// HarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((sdk, arch) => {
// build libHarfBuzzSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libHarfBuzzSharp_tvos/libHarfBuzzSharp.xcodeproj",
Target = "libHarfBuzzSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/tvos/" + arch);
2017-04-28 23:03:23 +03:00
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_tvos/build/Release-" + sdk + "/libHarfBuzzSharp.a", "native-builds/lib/tvos/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libHarfBuzzSharp.a",
WorkingDirectory = "native-builds/lib/tvos/" + arch,
});
});
buildHarfBuzzArch ("appletvsimulator", "x86_64");
buildHarfBuzzArch ("appletvos", "arm64");
// create the fat framework
RunLipo ("native-builds/lib/tvos/", "libHarfBuzzSharp.a", new [] {
(FilePath) "x86_64/libHarfBuzzSharp.a",
(FilePath) "arm64/libHarfBuzzSharp.a"
});
});
// this builds the native C and C++ externals for watchOS
Task ("externals-watchos")
.IsDependentOn ("externals-init")
.WithCriteria (IsRunningOnMac ())
.Does (() =>
{
// SkiaSharp
var buildArch = new Action<string, string, string> ((sdk, arch, skiaArch) => {
var specifics = "";
// several instances of "error: type 'XXX' requires 8 bytes of alignment and the default allocator only guarantees 4 bytes [-Werror,-Wover-aligned]
// https://groups.google.com/forum/#!topic/skia-discuss/hU1IPFwU6bI
if (arch == "armv7k") {
specifics += ", \"-Wno-over-aligned\"";
}
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
"gen out/watchos/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"watchos\" target_cpu=\"" + skiaArch + "\"" +
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
" extra_cflags=[ \"-DSK_BUILD_FOR_WATCHOS\", \"-DSKIA_C_DLL\", \"-mwatchos-version-min=2.0\" " + specifics + " ]" +
" extra_ldflags=[ \"-Wl,watchos_version_min=2.0\" ]" +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/watchos/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
// build libSkiaSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libSkiaSharp_watchos/libSkiaSharp.xcodeproj",
Target = "libSkiaSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/watchos/" + arch);
CopyDirectory ("native-builds/libSkiaSharp_watchos/build/Release-" + sdk, "native-builds/lib/watchos/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libSkiaSharp",
WorkingDirectory = "native-builds/lib/watchos/" + arch + "/libSkiaSharp.framework",
});
// re-sign with empty
RunProcess ("codesign", new ProcessSettings {
Arguments = "--force --sign - --timestamp=none libSkiaSharp.framework",
WorkingDirectory = "native-builds/lib/watchos/" + arch,
});
});
buildArch ("watchsimulator", "i386", "x86");
buildArch ("watchos", "armv7k", "arm");
// create the fat framework
CopyDirectory ("native-builds/lib/watchos/armv7k/libSkiaSharp.framework/", "native-builds/lib/watchos/libSkiaSharp.framework/");
DeleteFile ("native-builds/lib/watchos/libSkiaSharp.framework/libSkiaSharp");
RunLipo ("native-builds/lib/watchos/", "libSkiaSharp.framework/libSkiaSharp", new [] {
(FilePath) "i386/libSkiaSharp.framework/libSkiaSharp",
(FilePath) "armv7k/libSkiaSharp.framework/libSkiaSharp"
});
// HarfBuzzSharp
var buildHarfBuzzArch = new Action<string, string> ((sdk, arch) => {
// build libHarfBuzzSharp
XCodeBuild (new XCodeBuildSettings {
Project = "native-builds/libHarfBuzzSharp_watchos/libHarfBuzzSharp.xcodeproj",
Target = "libHarfBuzzSharp",
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/watchos/" + arch);
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_watchos/build/Release-" + sdk + "/libHarfBuzzSharp.a", "native-builds/lib/watchos/" + arch);
// strip anything we can
RunProcess ("strip", new ProcessSettings {
Arguments = "-x -S libHarfBuzzSharp.a",
WorkingDirectory = "native-builds/lib/watchos/" + arch,
});
});
buildHarfBuzzArch ("watchsimulator", "i386");
buildHarfBuzzArch ("watchos", "armv7k");
// create the fat framework
RunLipo ("native-builds/lib/watchos/", "libHarfBuzzSharp.a", new [] {
(FilePath) "i386/libHarfBuzzSharp.a",
(FilePath) "armv7k/libHarfBuzzSharp.a"
});
});
// this builds the native C and C++ externals for Android
Task ("externals-android")
.IsDependentOn ("externals-init")
2017-01-11 07:35:43 +03:00
.WithCriteria (IsRunningOnMac ())
.Does (() =>
{
2017-04-29 00:18:40 +03:00
// SkiaSharp
var buildArch = new Action<string, string> ((arch, skiaArch) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
2017-03-18 16:03:10 +03:00
"gen out/android/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"android\" target_cpu=\"" + skiaArch + "\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
" extra_cflags=[ \"-DSKIA_C_DLL\" ]" +
2017-03-18 16:03:10 +03:00
" ndk=\"" + ANDROID_NDK_HOME + "\"" +
" ndk_api=" + (skiaArch == "x64" || skiaArch == "arm64" ? 21 : 9) +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/android/" + arch,
WorkingDirectory = SKIA_PATH.FullPath,
});
});
buildArch ("x86", "x86");
buildArch ("x86_64", "x64");
buildArch ("armeabi-v7a", "arm");
buildArch ("arm64-v8a", "arm64");
// build libSkiaSharp
var ndkbuild = MakeAbsolute (Directory (ANDROID_NDK_HOME)).CombineWithFilePath ("ndk-build").FullPath;
RunProcess (ndkbuild, new ProcessSettings {
Arguments = "",
WorkingDirectory = ROOT_PATH.Combine ("native-builds/libSkiaSharp_android").FullPath,
});
// copy libSkiaSharp to output
foreach (var folder in new [] { "x86", "x86_64", "armeabi-v7a", "arm64-v8a" }) {
EnsureDirectoryExists("native-builds/lib/android/" + folder);
CopyFileToDirectory ("native-builds/libSkiaSharp_android/libs/" + folder + "/libSkiaSharp.so", "native-builds/lib/android/" + folder);
}
2017-04-29 00:18:40 +03:00
// HarfBuzzSharp
// build libHarfBuzzSharp
RunProcess (ndkbuild, new ProcessSettings {
Arguments = "",
WorkingDirectory = ROOT_PATH.Combine ("native-builds/libHarfBuzzSharp_android").FullPath,
});
// copy libSkiaSharp to output
foreach (var folder in new [] { "x86", "x86_64", "armeabi-v7a", "arm64-v8a" }) {
EnsureDirectoryExists ("native-builds/lib/android/" + folder);
2017-04-29 00:18:40 +03:00
CopyFileToDirectory ("native-builds/libHarfBuzzSharp_android/libs/" + folder + "/libHarfBuzzSharp.so", "native-builds/lib/android/" + folder);
}
});
2017-01-25 01:33:42 +03:00
// this builds the native C and C++ externals for Linux
Task ("externals-linux")
2017-03-18 16:03:10 +03:00
.IsDependentOn ("externals-init")
2017-01-25 01:33:42 +03:00
.WithCriteria (IsRunningOnLinux ())
.Does (() =>
{
2017-03-18 16:03:10 +03:00
var arches = EnvironmentVariable ("BUILD_ARCH") ?? (Environment.Is64BitOperatingSystem ? "x64" : "x86"); // x64, x86, ARM
var BUILD_ARCH = arches.Split (',').Select (a => a.Trim ()).ToArray ();
var SUPPORT_GPU = (EnvironmentVariable ("SUPPORT_GPU") ?? "1") == "1"; // 1 == true, 0 == false
2017-02-21 05:00:53 +03:00
2017-03-18 16:03:10 +03:00
var buildArch = new Action<string> ((arch) => {
// generate native skia build files
RunProcess (SKIA_PATH.CombineWithFilePath("bin/gn"), new ProcessSettings {
Arguments =
"gen out/linux/" + arch + " " +
"--args='" +
" is_official_build=true skia_enable_tools=false" +
" target_os=\"linux\" target_cpu=\"" + arch + "\"" +
2017-07-11 16:01:04 +03:00
" skia_use_icu=false skia_use_sfntly=false skia_use_piex=true" +
" skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false" +
2017-03-18 16:03:10 +03:00
" skia_enable_gpu=" + (SUPPORT_GPU ? "true" : "false") +
" extra_cflags=[ \"-DSKIA_C_DLL\" ]" +
2017-03-18 16:03:10 +03:00
" extra_ldflags=[ ]" +
"'",
WorkingDirectory = SKIA_PATH.FullPath,
});
2017-01-25 01:33:42 +03:00
2017-03-18 16:03:10 +03:00
// build native skia
RunProcess (DEPOT_PATH.CombineWithFilePath ("ninja"), new ProcessSettings {
Arguments = "-C out/linux/" + arch,
2017-01-25 01:33:42 +03:00
WorkingDirectory = SKIA_PATH.FullPath,
});
2017-03-18 16:03:10 +03:00
2017-01-25 01:33:42 +03:00
// build libSkiaSharp
// RunProcess ("make", new ProcessSettings {
// Arguments = "clean",
// WorkingDirectory = "native-builds/libSkiaSharp_linux",
// });
2017-01-25 01:33:42 +03:00
RunProcess ("make", new ProcessSettings {
2017-03-18 16:03:10 +03:00
Arguments = "ARCH=" + arch + " VERSION=" + VERSION_FILE + " SUPPORT_GPU=" + SUPPORT_GPU,
2017-01-25 01:33:42 +03:00
WorkingDirectory = "native-builds/libSkiaSharp_linux",
});
2017-03-18 16:03:10 +03:00
// copy libSkiaSharp to output
EnsureDirectoryExists ("native-builds/lib/linux/" + arch);
var so = "native-builds/libSkiaSharp_linux/bin/" + arch + "/libSkiaSharp.so." + VERSION_SONAME;
CopyFileToDirectory (so, "native-builds/lib/linux/" + arch);
CopyFile (so, "native-builds/lib/linux/" + arch + "/libSkiaSharp.so");
2017-03-18 16:03:10 +03:00
});
var buildHarfBuzzArch = new Action<string> ((arch) => {
// build libHarfBuzzSharp
// RunProcess ("make", new ProcessSettings {
// Arguments = "clean",
// WorkingDirectory = "native-builds/libHarfBuzzSharp_linux",
// });
RunProcess ("make", new ProcessSettings {
2017-05-02 16:21:30 +03:00
Arguments = "ARCH=" + arch + " VERSION=" + HARFBUZZ_VERSION_FILE,
WorkingDirectory = "native-builds/libHarfBuzzSharp_linux",
});
// copy libHarfBuzzSharp to output
EnsureDirectoryExists ("native-builds/lib/linux/" + arch);
var so = "native-builds/libHarfBuzzSharp_linux/bin/" + arch + "/libHarfBuzzSharp.so." + HARFBUZZ_VERSION_SONAME;
CopyFileToDirectory (so, "native-builds/lib/linux/" + arch);
CopyFile (so, "native-builds/lib/linux/" + arch + "/libHarfBuzzSharp.so");
});
2017-03-18 16:03:10 +03:00
foreach (var arch in BUILD_ARCH) {
buildArch (arch);
buildHarfBuzzArch (arch);
2017-01-25 01:33:42 +03:00
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
// EXTERNALS DOWNLOAD - download any externals that are needed
////////////////////////////////////////////////////////////////////////////////////////////////////
Task ("externals-angle-uwp")
.WithCriteria (!FileExists (ANGLE_PATH.CombineWithFilePath ("uwp/ANGLE.WindowsStore.nuspec")))
.Does (() =>
{
var angleUrl = "https://www.nuget.org/api/v2/package/ANGLE.WindowsStore/" + ANGLE_VERSION_SOURCE;
var angleRoot = ANGLE_PATH.Combine ("uwp");
var angleNupkg = angleRoot.CombineWithFilePath ("angle_" + ANGLE_VERSION_SOURCE + ".nupkg");
EnsureDirectoryExists (angleRoot);
CleanDirectory (angleRoot);
DownloadFile (angleUrl, angleNupkg);
Unzip (angleNupkg, angleRoot);
});
Task ("externals-harfbuzz")
.WithCriteria (
!FileExists (HARFBUZZ_PATH.CombineWithFilePath ("harfbuzz/README")) ||
!FileExists (HARFBUZZ_PATH.CombineWithFilePath ("harfbuzz-" + HARFBUZZ_VERSION_SOURCE + ".tar.bz2")))
.Does (() =>
{
string url = "https://github.com/behdad/harfbuzz/releases/download/" + HARFBUZZ_VERSION_SOURCE + "/harfbuzz-" + HARFBUZZ_VERSION_SOURCE + ".tar.bz2";
DirectoryPath root = HARFBUZZ_PATH;
FilePath archive = root.CombineWithFilePath ("harfbuzz-" + HARFBUZZ_VERSION_SOURCE + ".tar.bz2");
EnsureDirectoryExists (root);
CleanDirectory (root);
DownloadFile (url, archive);
DecompressArchive (archive, root);
MoveDirectory (root.Combine ("harfbuzz-" + HARFBUZZ_VERSION_SOURCE), HARFBUZZ_PATH.Combine ("harfbuzz"));
2017-04-28 23:03:23 +03:00
if (IsRunningOnWindows ()) {
// copy the default config header file
CopyFile ("externals/harfbuzz/harfbuzz/win32/config.h.win32", "externals/harfbuzz/harfbuzz/win32/config.h");
} else {
RunProcess ("bash", new ProcessSettings {
Arguments = "configure",
WorkingDirectory = HARFBUZZ_PATH.Combine ("harfbuzz"),
});
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
// CLEAN - remove all the build artefacts
////////////////////////////////////////////////////////////////////////////////////////////////////
Task ("externals-deinit").Does (() =>
{
// remove compatibility
InjectCompatibilityExternals (false);
});
Task ("clean-externals")
.IsDependentOn ("externals-deinit")
.Does (() =>
{
// skia
CleanDirectories ("externals/skia/out");
CleanDirectories ("externals/skia/xcodebuild");
// harfbuzz
CleanDirectories ("externals/harfbuzz");
2017-04-28 23:03:23 +03:00
// angle
CleanDirectories ("externals/angle");
// all
CleanDirectories ("native-builds/lib");
// android
CleanDirectories ("native-builds/libSkiaSharp_android/obj");
CleanDirectories ("native-builds/libSkiaSharp_android/libs");
// ios
CleanDirectories ("native-builds/libSkiaSharp_ios/build");
2017-04-28 23:03:23 +03:00
CleanDirectories ("native-builds/libHarfBuzzSharp_ios/build");
// tvos
CleanDirectories ("native-builds/libSkiaSharp_tvos/build");
2017-04-28 23:03:23 +03:00
CleanDirectories ("native-builds/libHarfBuzzSharp_tvos/build");
// watchos
CleanDirectories ("native-builds/libSkiaSharp_watchos/build");
CleanDirectories ("native-builds/libHarfBuzzSharp_watchos/build");
// osx
CleanDirectories ("native-builds/libSkiaSharp_osx/build");
2017-04-28 23:03:23 +03:00
CleanDirectories ("native-builds/libHarfBuzzSharp_osx/build");
// windows
2016-09-15 05:57:22 +03:00
CleanDirectories ("native-builds/libSkiaSharp_windows/bin");
CleanDirectories ("native-builds/libSkiaSharp_windows/obj");
CleanDirectories ("native-builds/libHarfBuzzSharp_windows/bin");
CleanDirectories ("native-builds/libHarfBuzzSharp_windows/obj");
// uwp
2016-09-15 05:57:22 +03:00
CleanDirectories ("native-builds/libSkiaSharp_uwp/bin");
CleanDirectories ("native-builds/libSkiaSharp_uwp/obj");
CleanDirectories ("native-builds/libHarfBuzzSharp_uwp/bin");
CleanDirectories ("native-builds/libHarfBuzzSharp_uwp/obj");
2017-01-25 01:33:42 +03:00
// linux
CleanDirectories ("native-builds/libSkiaSharp_linux/bin");
CleanDirectories ("native-builds/libSkiaSharp_linux/obj");
});