From c21689555759d37cbf0326423f7e4ebccdbaaf21 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Mon, 29 Oct 2018 23:56:35 +0200 Subject: [PATCH] Statically Link Windows Binaries (#662) * Now building a static Windows binary. #136 * Add support for building a "feature" version --- build.cake | 18 +++++++++++++--- cake/BuildExternals.cake | 2 +- .../libHarfBuzzSharp.vcxproj | 4 ++++ scripts/pipeline.groovy | 21 +++++++++++++++---- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/build.cake b/build.cake index f964131fe2..0c733af9cf 100644 --- a/build.cake +++ b/build.cake @@ -51,6 +51,7 @@ DirectoryPath PACKAGE_CACHE_PATH = MakeAbsolute(ROOT_PATH.Combine("externals/pac DirectoryPath PROFILE_PATH = EnvironmentVariable ("USERPROFILE") ?? EnvironmentVariable ("HOME"); DirectoryPath NUGET_PACKAGES = EnvironmentVariable ("NUGET_PACKAGES") ?? PROFILE_PATH.Combine (".nuget/packages"); +var FEATURE_NAME = EnvironmentVariable ("FEATURE_NAME") ?? ""; var BUILD_NUMBER = EnvironmentVariable ("BUILD_NUMBER") ?? ""; if (string.IsNullOrEmpty (BUILD_NUMBER)) { BUILD_NUMBER = "0"; @@ -312,7 +313,7 @@ Task ("nuget-only") } nuspecPlatform.Remove (); } - // copy the src arrtibute and set it for the target + // copy the src attribute and set it for the target file.Add (new XAttribute ("target", file.Attribute ("src").Value)); } }); @@ -360,6 +361,16 @@ Task ("nuget-only") dir = id.Substring(0, id.IndexOf(".NativeAssets")); } + var preview = ""; + if (!string.IsNullOrEmpty (FEATURE_NAME)) { + preview += $"-{FEATURE_NAME}-featurepreview"; + } else { + preview += $"-preview"; + } + if (!string.IsNullOrEmpty (BUILD_NUMBER)) { + preview += $"{BUILD_NUMBER}"; + } + removePlatforms (xdoc); var outDir = $"./output/{dir}/nuget"; @@ -367,7 +378,7 @@ Task ("nuget-only") setVersion (xdoc, ""); xdoc.Save ($"{outDir}/{id}.nuspec"); - setVersion (xdoc, $"-preview{BUILD_NUMBER}"); + setVersion (xdoc, $"{preview}"); xdoc.Save ($"{outDir}/{id}.prerelease.nuspec"); // the legal @@ -505,7 +516,8 @@ var envVarsWhitelist = new [] { "path", "psmodulepath", "pwd", "shell", "processor_architecture", "processor_identifier", "node_name", "node_labels", "branch_name", "os", "build_url", "build_number", "number_of_processors", - "node_label", "build_id", "git_sha" + "node_label", "build_id", "git_sha", "git_branch_name", + "feature_name" }; var envVars = EnvironmentVariables (); var max = envVars.Max (v => v.Key.Length) + 2; diff --git a/cake/BuildExternals.cake b/cake/BuildExternals.cake index a0d9e6a249..47ae94b72d 100644 --- a/cake/BuildExternals.cake +++ b/cake/BuildExternals.cake @@ -88,7 +88,7 @@ Task ("externals-windows") $"target_os='win' target_cpu='{skiaArch}' " + $"skia_use_icu=false skia_use_sfntly=false skia_use_piex=true skia_use_dng_sdk=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', '/MD', '/EHsc', '/Z7' ] " + + $"extra_cflags=[ '-DSKIA_C_DLL', '/MT', '/EHsc', '/Z7' ] " + $"extra_ldflags=[ '/DEBUG:FULL' ]"); // copy libSkiaSharp to output diff --git a/native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.vcxproj b/native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.vcxproj index c7e1e709a2..c3e5389054 100644 --- a/native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.vcxproj +++ b/native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.vcxproj @@ -222,6 +222,7 @@ HAVE_UCDN=1;HAVE_CONFIG_H;HB_EXTERN=__declspec (dllexport) extern;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;HARFBUZZ_EXPORTS;%(PreprocessorDefinitions) ..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) 4267;4244 + MultiThreadedDebug Windows @@ -236,6 +237,7 @@ HAVE_UCDN=1;HAVE_CONFIG_H;HB_EXTERN=__declspec (dllexport) extern;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;HARFBUZZ_EXPORTS;%(PreprocessorDefinitions) ..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) 4267;4244 + MultiThreadedDebug Windows @@ -252,6 +254,7 @@ HAVE_UCDN=1;HAVE_CONFIG_H;HB_EXTERN=__declspec (dllexport) extern;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;HARFBUZZ_EXPORTS;%(PreprocessorDefinitions) ..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) 4267;4244 + MultiThreaded Windows @@ -270,6 +273,7 @@ HAVE_UCDN=1;HAVE_CONFIG_H;HB_EXTERN=__declspec (dllexport) extern;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;HARFBUZZ_EXPORTS;%(PreprocessorDefinitions) ..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) 4267;4244 + MultiThreaded Windows diff --git a/scripts/pipeline.groovy b/scripts/pipeline.groovy index 917bb4713e..a5e0539db0 100644 --- a/scripts/pipeline.groovy +++ b/scripts/pipeline.groovy @@ -1,10 +1,13 @@ import groovy.transform.Field -@Field def verbosity = "minimal" +@Field def verbosity = "normal" @Field def isPr = false @Field def branchName = null @Field def commitHash = null @Field def githubStatusSha = null +@Field def featureName = null + +@Field def featureNamePrefix = "feature/" @Field def minimalLinuxPackages = "curl mono-complete msbuild" @Field def nativeLinuxPackages = "python git libfontconfig1-dev" @@ -42,13 +45,23 @@ node("ubuntu-1604-amd64") { isPr = env.ghprbPullId && !env.ghprbPullId.empty branchName = isPr ? "pr" : env.BRANCH_NAME githubStatusSha = isPr ? env.ghprbActualCommit : commitHash + featureName = branchName.startsWith(featureNamePrefix) + ? branchName.substring(featureNamePrefix.length()) + : "" echo "Building SHA1: ${commitHash}..." echo " - PR: ${isPr}" echo " - Branch Name: ${branchName}" echo " - GitHub Status SHA1: ${githubStatusSha}" - - customEnv.each { platform, vars -> vars.push("GIT_SHA=${commitHash}") } + echo " - Feature Name: ${featureName}" + + def newVars = [ + "GIT_SHA=${commitHash}", + "GIT_BRANCH_NAME=${branchName}", + "BUILD_NUMBER=${env.BUILD_NUMBER}", + "FEATURE_NAME=${featureName}", + ] + customEnv.each { platform, vars -> vars.addAll(newVars) } } } @@ -242,7 +255,7 @@ def bootstrapper(args, host, pre, additionalPackages) { if (host == "linux") { chroot( chrootName: "${env.NODE_LABEL}-stable", - command: "bash ${pre} ./bootstrapper.sh ${args}", + command: " ${customEnv[host].join(" ")} bash ${pre} ./bootstrapper.sh ${args}", additionalPackages: "${minimalLinuxPackages} ${additionalPackages}") } else if (host == "macos") { sh("bash ${pre} ./bootstrapper.sh ${args}")