Skip to content

Build for Linux ARM32 (armhf) and ARM64 (aarch64) #1382

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 48 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ae77476
Build for armhf
mattleibow Jul 3, 2020
104b629
Add to yaml
mattleibow Jul 3, 2020
789d05a
diff
mattleibow Jul 3, 2020
e4ec30d
gonna be a few tries
mattleibow Jul 3, 2020
54d9fec
we need to go faster
mattleibow Jul 3, 2020
bf65662
Slap a new one on
mattleibow Jul 3, 2020
a7f2d3e
This?
mattleibow Jul 3, 2020
e0f0346
I think I got it...
mattleibow Jul 3, 2020
43c1e61
Nope!
mattleibow Jul 3, 2020
0cecbd8
try everything
mattleibow Jul 3, 2020
d7ecf46
Add arm to the nugets
mattleibow Jul 4, 2020
e73698a
aarch64
mattleibow Jul 4, 2020
e1fd947
Add arm64 to the nuspec
mattleibow Jul 4, 2020
546c36b
Update scripts/azure-templates-bootstrapper.yml
mattleibow Jul 4, 2020
a90d688
readelf
mattleibow Jul 4, 2020
388f7b6
things
mattleibow Jul 4, 2020
d7981a9
maybe
mattleibow Jul 4, 2020
84e9d1b
oopsie
mattleibow Jul 4, 2020
5811891
cvcx
mattleibow Jul 4, 2020
f92a8d3
asdf
mattleibow Jul 4, 2020
260aa8b
dsfasdf
mattleibow Jul 4, 2020
2fbc17f
alt
mattleibow Jul 4, 2020
8b1add9
dfasdfasd
mattleibow Jul 4, 2020
1817310
vvv
mattleibow Jul 4, 2020
c14db64
deps
mattleibow Jul 4, 2020
703d6d1
sadfasdf
mattleibow Jul 4, 2020
cf0c14a
sdfasdf
mattleibow Jul 4, 2020
0d7143c
sfdasf
mattleibow Jul 4, 2020
dd717c1
dasdf
mattleibow Jul 4, 2020
cd3eb29
sadfd
mattleibow Jul 4, 2020
ec5fc28
dsdf
mattleibow Jul 4, 2020
7ece7bf
sadfasdf
mattleibow Jul 4, 2020
64fa40c
sadfsadfsadf
mattleibow Jul 5, 2020
201f609
dsfadf
mattleibow Jul 5, 2020
9b97057
sadfasdf
mattleibow Jul 5, 2020
59a2ae6
sdfasdf
mattleibow Jul 5, 2020
e183573
sadfasdf
mattleibow Jul 5, 2020
8473d5f
asdfasd
mattleibow Jul 5, 2020
92e0511
asdfasdf
mattleibow Jul 5, 2020
30408de
asdfasdfasdfdsfasdfdf
mattleibow Jul 5, 2020
add4a3a
asdasdf
mattleibow Jul 5, 2020
6df1c51
sadfasdf
mattleibow Jul 5, 2020
9a77b52
asdfsadfasdf
mattleibow Jul 5, 2020
1ac1413
saddfasdf
mattleibow Jul 5, 2020
46ba09f
dafasdf
mattleibow Jul 5, 2020
50c1231
minitest
mattleibow Jul 5, 2020
1a25cbb
ssadf
mattleibow Jul 5, 2020
b35d6ff
uodates
mattleibow Jul 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ var TRACKED_NUGETS = new Dictionary<string, Version> {
{ "SkiaSharp.Vulkan.SharpVk", new Version (1, 57, 0) },
};

Information("Arguments:");
foreach (var arg in CAKE_ARGUMENTS) {
Information($" {arg.Key.PadRight(30)} {{0}}", arg.Value);
}

#load "cake/msbuild.cake"
#load "cake/UtilsManaged.cake"
#load "cake/externals.cake"
Expand Down
10 changes: 2 additions & 8 deletions cake/native-shared.cake
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#load "shared.cake"

var BUILD_ARCH = Argument("arch", Argument("buildarch", EnvironmentVariable("BUILD_ARCH") ?? ""))
.ToLower().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

var BUILD_VARIANT = Argument("variant", EnvironmentVariable("BUILD_VARIANT"));
var ADDITIONAL_GN_ARGS = Argument("gnArgs", EnvironmentVariable("ADDITIONAL_GN_ARGS"));

var PYTHON_EXE = Argument("python", EnvironmentVariable("PYTHON_EXE") ?? "python");

if (!string.IsNullOrEmpty(PYTHON_EXE) && FileExists(PYTHON_EXE)) {
Expand Down Expand Up @@ -85,7 +79,7 @@ void GnNinja(DirectoryPath outDir, string target, string skiaArgs)
void StripSign(FilePath target)
{
if (!IsRunningOnMac())
throw new InvalidOperationException("lipo is only available on Unix.");
throw new InvalidOperationException("lipo is only available on macOS.");

target = MakeAbsolute(target);
var archive = target;
Expand All @@ -107,7 +101,7 @@ void StripSign(FilePath target)
void RunLipo(DirectoryPath directory, FilePath output, FilePath[] inputs)
{
if (!IsRunningOnMac())
throw new InvalidOperationException("lipo is only available on Unix.");
throw new InvalidOperationException("lipo is only available on macOS.");

EnsureDirectoryExists(directory.CombineWithFilePath(output).GetDirectory());

Expand Down
6 changes: 6 additions & 0 deletions cake/shared.cake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ var CAKE_ARGUMENTS = (IReadOnlyDictionary<string, string>)Context.Arguments
.GetProperty("Arguments")
.GetValue(Context.Arguments);

var BUILD_ARCH = Argument("arch", Argument("buildarch", EnvironmentVariable("BUILD_ARCH") ?? ""))
.ToLower().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

var BUILD_VARIANT = Argument("variant", EnvironmentVariable("BUILD_VARIANT"));
var ADDITIONAL_GN_ARGS = Argument("gnArgs", EnvironmentVariable("ADDITIONAL_GN_ARGS"));

DirectoryPath PROFILE_PATH = EnvironmentVariable("USERPROFILE") ?? EnvironmentVariable("HOME");

void RunCake(FilePath cake, string target = null, Dictionary<string, string> arguments = null)
Expand Down
2 changes: 1 addition & 1 deletion externals/skia
Submodule skia updated 3 files
+105 −30 BUILD.gn
+1 −1 DEPS
+8 −4 gn/BUILD.gn
61 changes: 61 additions & 0 deletions native/linux-clang-cross/build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));

#load "../../cake/shared.cake"

if (BUILD_ARCH.Length == 0)
BUILD_ARCH = new [] { "arm" };

string GetGnArgs(string arch)
{
var toolchainArch = arch == "arm"
? "arm-linux-gnueabihf"
: "aarch64-linux-gnu";
var targetArch = arch == "arm"
? "armv7a-linux-gnueabihf"
: "aarch64-linux-gnu";

var sysroot = $"/usr/{toolchainArch}";
var init = $"'--sysroot={sysroot}', '--target={targetArch}'";
var bin = $"'-B{sysroot}/bin/' ";
var libs = $"'-L{sysroot}/lib/' ";
var includes =
$"'-I{sysroot}/include', " +
$"'-I{sysroot}/include/c++/current', " +
$"'-I{sysroot}/include/c++/current/{toolchainArch}' ";

return
$"extra_asmflags+=[ {init}, '-no-integrated-as', {bin}, {includes} ] " +
$"extra_cflags+=[ {init}, {bin}, {includes} ] " +
$"extra_ldflags+=[ {init}, {bin}, {libs} ] " +
ADDITIONAL_GN_ARGS;
}

Task("libSkiaSharp")
.WithCriteria(IsRunningOnLinux())
.Does(() =>
{
foreach (var arch in BUILD_ARCH) {
RunCake("../linux/build.cake", "libSkiaSharp", new Dictionary<string, string> {
{ "arch", arch },
{ "gnArgs", GetGnArgs(arch) },
});
}
});

Task("libHarfBuzzSharp")
.WithCriteria(IsRunningOnLinux())
.Does(() =>
{
foreach (var arch in BUILD_ARCH) {
RunCake("../linux/build.cake", "libHarfBuzzSharp", new Dictionary<string, string> {
{ "arch", arch },
{ "gnArgs", GetGnArgs(arch) },
});
}
});

Task("Default")
.IsDependentOn("libSkiaSharp")
.IsDependentOn("libHarfBuzzSharp");

RunTarget(TARGET);
84 changes: 51 additions & 33 deletions native/linux/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,35 @@ DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native"));
string SUPPORT_GPU_VAR = Argument("supportGpu", EnvironmentVariable("SUPPORT_GPU") ?? "true").ToLower();
bool SUPPORT_GPU = SUPPORT_GPU_VAR == "1" || SUPPORT_GPU_VAR == "true";

string SUPPORT_VULKAN_VAR = Argument ("supportVulkan", EnvironmentVariable ("SUPPORT_VULKAN") ?? "true");
bool SUPPORT_VULKAN = SUPPORT_VULKAN_VAR == "1" || SUPPORT_VULKAN_VAR.ToLower () == "true";
string SUPPORT_VULKAN_VAR = Argument("supportVulkan", EnvironmentVariable("SUPPORT_VULKAN") ?? "true");
bool SUPPORT_VULKAN = SUPPORT_VULKAN_VAR == "1" || SUPPORT_VULKAN_VAR.ToLower() == "true";

var VERIFY_EXCLUDED = Argument("verifyExcluded", "")
.ToLower().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

string CC = Argument("cc", EnvironmentVariable("CC"));
string CXX = Argument("cxx", EnvironmentVariable("CXX"));
string AR = Argument("ar", EnvironmentVariable("AR"));

string VARIANT = BUILD_VARIANT ?? "linux";
string VARIANT = string.IsNullOrEmpty(BUILD_VARIANT) ? "linux" : BUILD_VARIANT?.Trim();

if (BUILD_ARCH.Length == 0)
BUILD_ARCH = new [] { "x64" };

var COMPILERS = "";
if (!string.IsNullOrEmpty(CC))
COMPILERS += $"cc='{CC}' ";
if (!string.IsNullOrEmpty(CXX))
COMPILERS += $"cxx='{CXX}' ";
if (!string.IsNullOrEmpty(AR))
COMPILERS += $"ar='{AR}' ";

Task("libSkiaSharp")
.IsDependentOn("git-sync-deps")
.WithCriteria(IsRunningOnLinux())
.Does(() =>
{
var COMPILERS = "";
if (!string.IsNullOrEmpty(CC))
COMPILERS += $"cc='{CC}' ";
if (!string.IsNullOrEmpty(CXX))
COMPILERS += $"cxx='{CXX}' ";
if (!string.IsNullOrEmpty(AR))
COMPILERS += $"ar='{AR}' ";

Build("x64", "x64", "x64");

void Build(string arch, string skiaArch, string dir)
{
foreach (var arch in BUILD_ARCH) {
if (Skip(arch)) return;

var soname = GetVersion("libSkiaSharp", "soname");
Expand All @@ -52,49 +55,64 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower () +
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower() +
$"extra_asmflags=[] " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_SYSCALL_GETRANDOM', '-DXML_DEV_URANDOM' ] " +
$"extra_ldflags=[ '-static-libstdc++', '-static-libgcc', '-Wl,--version-script={map}' ] " +
COMPILERS +
$"linux_soname_version='{soname}' " +
ADDITIONAL_GN_ARGS);

var outDir = OUTPUT_PATH.Combine($"{VARIANT}/{dir}");
var outDir = OUTPUT_PATH.Combine($"{VARIANT}/{arch}");
EnsureDirectoryExists(outDir);
var so = SKIA_PATH.CombineWithFilePath($"out/{VARIANT}/{arch}/libSkiaSharp.so.{soname}");
CopyFileToDirectory(so, outDir);
CopyFile(so, outDir.CombineWithFilePath("libSkiaSharp.so"));

foreach (var exclude in VERIFY_EXCLUDED) {
RunProcess("readelf", $"-d {so}", out var stdout);

if (stdout.Any(o => o.Contains($"[{exclude}.")))
throw new Exception($"libSkiaSharp.so contained a dependency on {exclude}.");
}
}
});

Task("libHarfBuzzSharp")
.IsDependentOn("git-sync-deps")
.WithCriteria(IsRunningOnLinux())
.Does(() =>
{
var COMPILERS = "";
if (!string.IsNullOrEmpty(CC))
COMPILERS += $"CC='{CC}' ";
if (!string.IsNullOrEmpty(CXX))
COMPILERS += $"CXX='{CXX}' ";

Build("x64", "x64");

void Build(string arch, string dir)
{
foreach (var arch in BUILD_ARCH) {
if (Skip(arch)) return;

var soname = GetVersion("HarfBuzz", "soname");
var map = MakeAbsolute((FilePath)"libHarfBuzzSharp/libHarfBuzzSharp.map");

RunProcess("make", new ProcessSettings {
Arguments = $"{COMPILERS} ARCH={arch} SONAME_VERSION={soname} VARIANT={VARIANT} LDFLAGS=-static-libstdc++",
WorkingDirectory = "libHarfBuzzSharp",
});
GnNinja($"{VARIANT}/{arch}", "HarfBuzzSharp",
$"target_os='linux' " +
$"target_cpu='{arch}' " +
$"is_official_build=true " +
$"visibility_hidden=false " +
$"extra_asmflags=[] " +
$"extra_cflags=[] " +
$"extra_ldflags=[ '-static-libstdc++', '-static-libgcc', '-Wl,--version-script={map}' ] " +
COMPILERS +
$"linux_soname_version='{soname}' " +
ADDITIONAL_GN_ARGS);

var outDir = OUTPUT_PATH.Combine($"{VARIANT}/{dir}");
var outDir = OUTPUT_PATH.Combine($"{VARIANT}/{arch}");
EnsureDirectoryExists(outDir);
var so = $"libHarfBuzzSharp/bin/{VARIANT}/{arch}/libHarfBuzzSharp.so.{soname}";
var so = SKIA_PATH.CombineWithFilePath($"out/{VARIANT}/{arch}/libHarfBuzzSharp.so.{soname}");
CopyFileToDirectory(so, outDir);
CopyFile(so, outDir.CombineWithFilePath("libHarfBuzzSharp.so"));

foreach (var exclude in VERIFY_EXCLUDED) {
RunProcess("readelf", $"-d {so}", out var stdout);

if (stdout.Any(o => o.Contains($"[{exclude}.")))
throw new Exception($"libHarfBuzzSharp.so contained a dependency on {exclude}.");
}
}
});

Expand Down
125 changes: 0 additions & 125 deletions native/linux/libHarfBuzzSharp/Makefile

This file was deleted.

Loading