From 9e83660c4370884f36e71aefc67b6551cd27d97d Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 24 Feb 2016 21:10:20 +0200 Subject: [PATCH 1/3] Added support for the build running with the wrong VS version from GYP --- build.cake | 88 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/build.cake b/build.cake index ccebc01b..3f6763b9 100644 --- a/build.cake +++ b/build.cake @@ -1,6 +1,8 @@ #addin "Cake.Xamarin" #addin "Cake.XCode" +#addin "Cake.FileHelpers" +using System.Text.RegularExpressions; using System.Xml; using System.Xml.Linq; @@ -142,6 +144,19 @@ var RunMdocUpdate = new Action ((assembly, docsRoot) => }); }); +var ProcessSolutionProjects = new Action> ((solutionFilePath, process) => { + var solutionFile = MakeAbsolute (solutionFilePath).FullPath; + foreach (var line in FileReadLines (solutionFile)) { + var match = Regex.Match (line, @"Project\(""(?.*)""\) = ""(?.*)"", ""(?.*)"", "".*"""); + if (match.Success && match.Groups ["type"].Value == "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") { + var path = match.Groups["path"].Value; + var projectFilePath = MakeAbsolute (solutionFilePath.GetDirectory ().CombineWithFilePath (path)); + Information ("Processing project file: " + projectFilePath); + process (match.Groups["name"].Value, projectFilePath); + } + } +}); + //////////////////////////////////////////////////////////////////////////////////////////////////// // EXTERNALS - the native C and C++ libraries //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -207,8 +222,8 @@ Task ("externals-windows") !FileExists ("native-builds/lib/windows/x64/libskia_windows.dll")) .Does (() => { - var fixup = new Action (() => { - var props = SKIA_PATH.Combine ("out/gyp/libjpeg-turbo.props").FullPath; + var propsFixup = new Action (() => { + var props = SKIA_PATH.CombineWithFilePath ("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 @@ -222,36 +237,55 @@ Task ("externals-windows") xdoc.Save (props); } }); + + var gypVsVersionFixup = new Action ((solutionPlatform) => { + var ns = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003"; + var correctVsVersion = 2015; + var vsVersionVar = EnvironmentVariable ("GYP_MSVS_VERSION") ?? correctVsVersion.ToString (); + var vsVersion = correctVsVersion; + if (!int.TryParse (vsVersionVar, out vsVersion)) { + vsVersion = correctVsVersion; + } + if (vsVersion < correctVsVersion) { + Information ("Fixing VS project versions. Was {0}, now {1}", vsVersionVar, correctVsVersion); + var sln = ROOT_PATH.CombineWithFilePath ("native-builds/libskia_windows/libskia_windows_" + solutionPlatform + ".sln"); + ProcessSolutionProjects (sln, (projectName, projectPath) => { + if (projectName != "libskia_windows") { + var xproj = XDocument.Load (projectPath.FullPath); + var locals = xproj.Root + .Elements (ns + "PropertyGroup") + .Where (e => e.Attribute ("Label") != null && e.Attribute ("Label").Value == "Locals") + .Elements (ns + "PlatformToolset"); + foreach (var local in locals) { + local.Value = "v140"; + } + xproj.Save (projectPath.FullPath); + } + }); + } + }); + + var buildArch = new Action ((platform, skiaArch, dir) => { + SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='" + skiaArch + "'"); + RunGyp (); + gypVsVersionFixup (dir); + propsFixup (); + DotNetBuild ("native-builds/libskia_windows/libskia_windows_" + dir + ".sln", c => { + c.Configuration = "Release"; + c.Properties ["Platform"] = new [] { platform }; + }); + if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/" + dir); + }); // set up the gyp environment variables AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath); SetEnvironmentVariable ("GYP_GENERATORS", "ninja,msvs"); - // 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")) 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"); - - // 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"); + buildArch ("Win32", "x86", "x86"); + buildArch ("x64", "x86_64", "x64"); }); // this builds the native C and C++ externals for Mac OS X Task ("externals-osx") From 31af03d6122e38feee8b438c9d7cd18029cdce5e Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 24 Feb 2016 22:40:48 +0200 Subject: [PATCH 2/3] Removing the gyp build changes as we are going to require VS2015 --- build.cake | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/build.cake b/build.cake index 3f6763b9..59af5d1d 100644 --- a/build.cake +++ b/build.cake @@ -222,7 +222,7 @@ Task ("externals-windows") !FileExists ("native-builds/lib/windows/x64/libskia_windows.dll")) .Does (() => { - var propsFixup = new Action (() => { + var fixup = new Action (() => { var props = SKIA_PATH.CombineWithFilePath ("out/gyp/libjpeg-turbo.props").FullPath; var xdoc = XDocument.Load (props); var ns = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003"; @@ -238,46 +238,18 @@ Task ("externals-windows") } }); - var gypVsVersionFixup = new Action ((solutionPlatform) => { - var ns = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003"; - var correctVsVersion = 2015; - var vsVersionVar = EnvironmentVariable ("GYP_MSVS_VERSION") ?? correctVsVersion.ToString (); - var vsVersion = correctVsVersion; - if (!int.TryParse (vsVersionVar, out vsVersion)) { - vsVersion = correctVsVersion; - } - if (vsVersion < correctVsVersion) { - Information ("Fixing VS project versions. Was {0}, now {1}", vsVersionVar, correctVsVersion); - var sln = ROOT_PATH.CombineWithFilePath ("native-builds/libskia_windows/libskia_windows_" + solutionPlatform + ".sln"); - ProcessSolutionProjects (sln, (projectName, projectPath) => { - if (projectName != "libskia_windows") { - var xproj = XDocument.Load (projectPath.FullPath); - var locals = xproj.Root - .Elements (ns + "PropertyGroup") - .Where (e => e.Attribute ("Label") != null && e.Attribute ("Label").Value == "Locals") - .Elements (ns + "PlatformToolset"); - foreach (var local in locals) { - local.Value = "v140"; - } - xproj.Save (projectPath.FullPath); - } - }); - } - }); - var buildArch = new Action ((platform, skiaArch, dir) => { SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='" + skiaArch + "'"); RunGyp (); - gypVsVersionFixup (dir); - propsFixup (); - DotNetBuild ("native-builds/libskia_windows/libskia_windows_" + dir + ".sln", c => { - c.Configuration = "Release"; - c.Properties ["Platform"] = new [] { platform }; - }); - if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir); - CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/" + dir); - CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/" + dir); - CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/" + dir); + fixup (); + // DotNetBuild ("native-builds/libskia_windows/libskia_windows_" + dir + ".sln", c => { + // c.Configuration = "Release"; + // c.Properties ["Platform"] = new [] { platform }; + // }); + // if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir); + // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/" + dir); + // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/" + dir); + // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/" + dir); }); // set up the gyp environment variables From fa9b9558d741959af4e9496203a83489d16de6a1 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 24 Feb 2016 22:43:48 +0200 Subject: [PATCH 3/3] This shouldn't have been commented out :) --- build.cake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.cake b/build.cake index 59af5d1d..96519e97 100644 --- a/build.cake +++ b/build.cake @@ -242,14 +242,14 @@ Task ("externals-windows") SetEnvironmentVariable ("GYP_DEFINES", "skia_arch_type='" + skiaArch + "'"); RunGyp (); fixup (); - // DotNetBuild ("native-builds/libskia_windows/libskia_windows_" + dir + ".sln", c => { - // c.Configuration = "Release"; - // c.Properties ["Platform"] = new [] { platform }; - // }); - // if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir); - // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/" + dir); - // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/" + dir); - // CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/" + dir); + DotNetBuild ("native-builds/libskia_windows/libskia_windows_" + dir + ".sln", c => { + c.Configuration = "Release"; + c.Properties ["Platform"] = new [] { platform }; + }); + if (!DirectoryExists ("native-builds/lib/windows/" + dir)) CreateDirectory ("native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.lib", "native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.dll", "native-builds/lib/windows/" + dir); + CopyFileToDirectory ("native-builds/libskia_windows/Release/libskia_windows.pdb", "native-builds/lib/windows/" + dir); }); // set up the gyp environment variables