Skip to content

Commit c216895

Browse files
authored
Statically Link Windows Binaries (#662)
* Now building a static Windows binary. #136 * Add support for building a "feature" version
1 parent 83e0941 commit c216895

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

build.cake

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ DirectoryPath PACKAGE_CACHE_PATH = MakeAbsolute(ROOT_PATH.Combine("externals/pac
5151
DirectoryPath PROFILE_PATH = EnvironmentVariable ("USERPROFILE") ?? EnvironmentVariable ("HOME");
5252
DirectoryPath NUGET_PACKAGES = EnvironmentVariable ("NUGET_PACKAGES") ?? PROFILE_PATH.Combine (".nuget/packages");
5353

54+
var FEATURE_NAME = EnvironmentVariable ("FEATURE_NAME") ?? "";
5455
var BUILD_NUMBER = EnvironmentVariable ("BUILD_NUMBER") ?? "";
5556
if (string.IsNullOrEmpty (BUILD_NUMBER)) {
5657
BUILD_NUMBER = "0";
@@ -312,7 +313,7 @@ Task ("nuget-only")
312313
}
313314
nuspecPlatform.Remove ();
314315
}
315-
// copy the src arrtibute and set it for the target
316+
// copy the src attribute and set it for the target
316317
file.Add (new XAttribute ("target", file.Attribute ("src").Value));
317318
}
318319
});
@@ -360,14 +361,24 @@ Task ("nuget-only")
360361
dir = id.Substring(0, id.IndexOf(".NativeAssets"));
361362
}
362363

364+
var preview = "";
365+
if (!string.IsNullOrEmpty (FEATURE_NAME)) {
366+
preview += $"-{FEATURE_NAME}-featurepreview";
367+
} else {
368+
preview += $"-preview";
369+
}
370+
if (!string.IsNullOrEmpty (BUILD_NUMBER)) {
371+
preview += $"{BUILD_NUMBER}";
372+
}
373+
363374
removePlatforms (xdoc);
364375

365376
var outDir = $"./output/{dir}/nuget";
366377

367378
setVersion (xdoc, "");
368379
xdoc.Save ($"{outDir}/{id}.nuspec");
369380

370-
setVersion (xdoc, $"-preview{BUILD_NUMBER}");
381+
setVersion (xdoc, $"{preview}");
371382
xdoc.Save ($"{outDir}/{id}.prerelease.nuspec");
372383

373384
// the legal
@@ -505,7 +516,8 @@ var envVarsWhitelist = new [] {
505516
"path", "psmodulepath", "pwd", "shell", "processor_architecture",
506517
"processor_identifier", "node_name", "node_labels", "branch_name",
507518
"os", "build_url", "build_number", "number_of_processors",
508-
"node_label", "build_id", "git_sha"
519+
"node_label", "build_id", "git_sha", "git_branch_name",
520+
"feature_name"
509521
};
510522
var envVars = EnvironmentVariables ();
511523
var max = envVars.Max (v => v.Key.Length) + 2;

cake/BuildExternals.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Task ("externals-windows")
8888
$"target_os='win' target_cpu='{skiaArch}' " +
8989
$"skia_use_icu=false skia_use_sfntly=false skia_use_piex=true skia_use_dng_sdk=true " +
9090
$"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 " +
91-
$"extra_cflags=[ '-DSKIA_C_DLL', '/MD', '/EHsc', '/Z7' ] " +
91+
$"extra_cflags=[ '-DSKIA_C_DLL', '/MT', '/EHsc', '/Z7' ] " +
9292
$"extra_ldflags=[ '/DEBUG:FULL' ]");
9393

9494
// copy libSkiaSharp to output

native-builds/libHarfBuzzSharp_windows/libHarfBuzzSharp.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
223223
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
224224
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
225+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
225226
</ClCompile>
226227
<Link>
227228
<SubSystem>Windows</SubSystem>
@@ -236,6 +237,7 @@
236237
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
237238
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
238239
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
240+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
239241
</ClCompile>
240242
<Link>
241243
<SubSystem>Windows</SubSystem>
@@ -252,6 +254,7 @@
252254
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
253255
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
254256
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
257+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
255258
</ClCompile>
256259
<Link>
257260
<SubSystem>Windows</SubSystem>
@@ -270,6 +273,7 @@
270273
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
271274
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
272275
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
276+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
273277
</ClCompile>
274278
<Link>
275279
<SubSystem>Windows</SubSystem>

scripts/pipeline.groovy

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import groovy.transform.Field
22

3-
@Field def verbosity = "minimal"
3+
@Field def verbosity = "normal"
44
@Field def isPr = false
55
@Field def branchName = null
66
@Field def commitHash = null
77
@Field def githubStatusSha = null
8+
@Field def featureName = null
9+
10+
@Field def featureNamePrefix = "feature/"
811

912
@Field def minimalLinuxPackages = "curl mono-complete msbuild"
1013
@Field def nativeLinuxPackages = "python git libfontconfig1-dev"
@@ -42,13 +45,23 @@ node("ubuntu-1604-amd64") {
4245
isPr = env.ghprbPullId && !env.ghprbPullId.empty
4346
branchName = isPr ? "pr" : env.BRANCH_NAME
4447
githubStatusSha = isPr ? env.ghprbActualCommit : commitHash
48+
featureName = branchName.startsWith(featureNamePrefix)
49+
? branchName.substring(featureNamePrefix.length())
50+
: ""
4551

4652
echo "Building SHA1: ${commitHash}..."
4753
echo " - PR: ${isPr}"
4854
echo " - Branch Name: ${branchName}"
4955
echo " - GitHub Status SHA1: ${githubStatusSha}"
50-
51-
customEnv.each { platform, vars -> vars.push("GIT_SHA=${commitHash}") }
56+
echo " - Feature Name: ${featureName}"
57+
58+
def newVars = [
59+
"GIT_SHA=${commitHash}",
60+
"GIT_BRANCH_NAME=${branchName}",
61+
"BUILD_NUMBER=${env.BUILD_NUMBER}",
62+
"FEATURE_NAME=${featureName}",
63+
]
64+
customEnv.each { platform, vars -> vars.addAll(newVars) }
5265
}
5366
}
5467

@@ -242,7 +255,7 @@ def bootstrapper(args, host, pre, additionalPackages) {
242255
if (host == "linux") {
243256
chroot(
244257
chrootName: "${env.NODE_LABEL}-stable",
245-
command: "bash ${pre} ./bootstrapper.sh ${args}",
258+
command: " ${customEnv[host].join(" ")} bash ${pre} ./bootstrapper.sh ${args}",
246259
additionalPackages: "${minimalLinuxPackages} ${additionalPackages}")
247260
} else if (host == "macos") {
248261
sh("bash ${pre} ./bootstrapper.sh ${args}")

0 commit comments

Comments
 (0)