Skip to content

Commit

Permalink
Statically Link Windows Binaries (#662)
Browse files Browse the repository at this point in the history
* Now building a static Windows binary. #136
* Add support for building a "feature" version
  • Loading branch information
mattleibow authored Oct 29, 2018
1 parent 83e0941 commit c216895
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
18 changes: 15 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
}
});
Expand Down Expand Up @@ -360,14 +361,24 @@ 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";

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

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

// the legal
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cake/BuildExternals.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<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>
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -236,6 +237,7 @@
<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>
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -252,6 +254,7 @@
<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>
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -270,6 +273,7 @@
<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>
<AdditionalIncludeDirectories>..\..\externals\harfbuzz\harfbuzz\src\hb-ucdn;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
21 changes: 17 additions & 4 deletions scripts/pipeline.groovy
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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) }
}
}

Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit c216895

Please sign in to comment.