Make sure to add the compat, and then remove in the clean
This commit is contained in:
Родитель
e48967427c
Коммит
5b3d876e7b
87
build.cake
87
build.cake
|
@ -277,10 +277,59 @@ var VisualStudioPathFixup = new Action (() => {
|
|||
}
|
||||
});
|
||||
|
||||
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> {
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_string.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_utils.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_pthread.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/zlib/deflate.c", "#include <assert.h>" },
|
||||
{ "skia/third_party/externals/libpng/pngpriv.h", "# include <windows.h> /* defines _WINDOWS_ macro */" },
|
||||
};
|
||||
foreach (var filePair in files) {
|
||||
var file = filePair.Key;
|
||||
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) {
|
||||
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) {
|
||||
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-base")
|
||||
.Does (() =>
|
||||
{
|
||||
// add compatibility methods to skia externals
|
||||
InjectCompatibilityExternals (true);
|
||||
});
|
||||
|
||||
// this builds all the externals
|
||||
Task ("externals")
|
||||
.IsDependentOn ("externals-genapi")
|
||||
|
@ -347,6 +396,7 @@ Task ("externals-genapi")
|
|||
});
|
||||
// this builds the native C and C++ externals for Windows
|
||||
Task ("externals-windows")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnWindows ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/windows/x86/libSkiaSharp.dll") ||
|
||||
|
@ -374,6 +424,7 @@ Task ("externals-windows")
|
|||
});
|
||||
// this builds the native C and C++ externals for Windows UWP
|
||||
Task ("externals-uwp")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnWindows ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/uwp/ARM/libSkiaSharp.dll") ||
|
||||
|
@ -386,35 +437,6 @@ Task ("externals-uwp")
|
|||
// TODO: the stuff in this block must be moved into the gyp files !!
|
||||
//
|
||||
|
||||
// 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> {
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_string.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_utils.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/dng_sdk/source/dng_pthread.cpp", "#if qWinOS" },
|
||||
{ "skia/third_party/externals/zlib/deflate.c", "#include <assert.h>" },
|
||||
{ "skia/third_party/externals/libpng/pngpriv.h", "# include <windows.h> /* defines _WINDOWS_ macro */" },
|
||||
};
|
||||
foreach (var filePair in files) {
|
||||
var file = filePair.Key;
|
||||
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) {
|
||||
if (string.IsNullOrEmpty (filePair.Value)) {
|
||||
contents.Insert (0, include);
|
||||
} else {
|
||||
contents.Insert (contents.IndexOf (filePair.Value), include);
|
||||
}
|
||||
FileWriteLines (file, contents.ToArray ());
|
||||
}
|
||||
}
|
||||
|
||||
var projectFile = MakeAbsolute (projectFilePath).FullPath;
|
||||
var xdoc = XDocument.Load (projectFile);
|
||||
|
||||
|
@ -534,6 +556,7 @@ Task ("externals-uwp")
|
|||
});
|
||||
// this builds the native C and C++ externals for Mac OS X
|
||||
Task ("externals-osx")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/osx/libSkiaSharp.dylib"))
|
||||
|
@ -570,6 +593,7 @@ Task ("externals-osx")
|
|||
});
|
||||
// this builds the native C and C++ externals for iOS
|
||||
Task ("externals-ios")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/ios/libSkiaSharp.framework/libSkiaSharp"))
|
||||
|
@ -613,6 +637,7 @@ Task ("externals-ios")
|
|||
});
|
||||
// this builds the native C and C++ externals for tvOS
|
||||
Task ("externals-tvos")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/tvos/libSkiaSharp.framework/libSkiaSharp"))
|
||||
|
@ -659,6 +684,7 @@ Task ("externals-tvos")
|
|||
});
|
||||
// this builds the native C and C++ externals for Android
|
||||
Task ("externals-android")
|
||||
.IsDependentOn ("externals-base")
|
||||
.WithCriteria (IsRunningOnUnix ())
|
||||
.WithCriteria (
|
||||
!FileExists ("native-builds/lib/android/x86/libSkiaSharp.so") ||
|
||||
|
@ -984,6 +1010,9 @@ Task ("clean-externals").Does (() =>
|
|||
// windows
|
||||
CleanDirectories ("native-builds/libSkiaSharp_windows/Release");
|
||||
CleanDirectories ("native-builds/libSkiaSharp_windows/x64/Release");
|
||||
|
||||
// remove compatibility
|
||||
InjectCompatibilityExternals (false);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче