mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +00:00
Add support for building on iOS
This commit is contained in:
committed by
Pierre Tachoire
parent
3f2f56d603
commit
8568c821fa
96
build.zig
96
build.zig
@@ -62,28 +62,36 @@ pub fn build(b: *Build) !void {
|
||||
try addDependencies(b, lightpanda_module, opts);
|
||||
|
||||
{
|
||||
// browser
|
||||
// -------
|
||||
// static lib
|
||||
// ----------
|
||||
|
||||
// compile and install
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "lightpanda",
|
||||
.use_llvm = true,
|
||||
.root_module = lightpanda_module,
|
||||
});
|
||||
b.installArtifact(exe);
|
||||
|
||||
// run
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
// step
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
const lib = b.addLibrary(.{ .name = "lightpanda", .root_module = lightpanda_module, .use_llvm = true, .linkage = .static });
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
// {
|
||||
// // browser
|
||||
// // -------
|
||||
|
||||
// // compile and install
|
||||
// const exe = b.addExecutable(.{
|
||||
// .name = "lightpanda",
|
||||
// .use_llvm = true,
|
||||
// .root_module = lightpanda_module,
|
||||
// });
|
||||
// b.installArtifact(exe);
|
||||
|
||||
// // run
|
||||
// const run_cmd = b.addRunArtifact(exe);
|
||||
// if (b.args) |args| {
|
||||
// run_cmd.addArgs(args);
|
||||
// }
|
||||
|
||||
// // step
|
||||
// const run_step = b.step("run", "Run the app");
|
||||
// run_step.dependOn(&run_cmd.step);
|
||||
// }
|
||||
|
||||
{
|
||||
// tests
|
||||
// ----
|
||||
@@ -176,6 +184,7 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
|
||||
const os = switch (target.result.os.tag) {
|
||||
.linux => "linux",
|
||||
.macos => "macos",
|
||||
.ios => "ios",
|
||||
else => return error.UnsupportedPlatform,
|
||||
};
|
||||
var lib_path = try std.fmt.allocPrint(
|
||||
@@ -199,6 +208,12 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
|
||||
mod.addSystemFrameworkPath(.{ .cwd_relative = "/System/Library/Frameworks" });
|
||||
mod.linkFramework("CoreFoundation", .{});
|
||||
},
|
||||
.ios => {
|
||||
const sdk_path = try std.process.getEnvVarOwned(mod.owner.allocator, "SDK");
|
||||
const framework_path = try std.fmt.allocPrint(mod.owner.allocator, "{s}/System/Library/Frameworks", .{sdk_path});
|
||||
mod.addSystemFrameworkPath(.{ .cwd_relative = framework_path });
|
||||
mod.linkFramework("CoreFoundation", .{});
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
@@ -393,6 +408,13 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
|
||||
mod.linkFramework("CoreFoundation", .{});
|
||||
mod.linkFramework("SystemConfiguration", .{});
|
||||
},
|
||||
.ios => {
|
||||
const sdk_path = try std.process.getEnvVarOwned(mod.owner.allocator, "SDK");
|
||||
const framework_path = try std.fmt.allocPrint(mod.owner.allocator, "{s}/System/Library/Frameworks", .{sdk_path});
|
||||
mod.addSystemFrameworkPath(.{ .cwd_relative = framework_path });
|
||||
mod.linkFramework("CoreFoundation", .{});
|
||||
mod.linkFramework("SystemConfiguration", .{});
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
@@ -400,19 +422,33 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
|
||||
|
||||
fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
|
||||
const target = mod.resolved_target.?;
|
||||
const os = target.result.os.tag;
|
||||
const arch = target.result.cpu.arch;
|
||||
const os = switch (target.result.os.tag) {
|
||||
.linux => "linux",
|
||||
.macos => "macos",
|
||||
.ios => switch (target.result.abi) {
|
||||
.simulator => "iphonesimulator",
|
||||
else => return error.UnsupportedPlatform,
|
||||
},
|
||||
else => return error.UnsupportedPlatform,
|
||||
};
|
||||
const arch = switch (target.result.os.tag) {
|
||||
.ios => switch (target.result.cpu.arch) {
|
||||
.aarch64 => "arm64",
|
||||
else => @tagName(target.result.cpu.arch),
|
||||
},
|
||||
else => @tagName(target.result.cpu.arch),
|
||||
};
|
||||
|
||||
// iconv
|
||||
const libiconv_lib_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
.{ os, arch },
|
||||
);
|
||||
const libiconv_include_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
.{ os, arch },
|
||||
);
|
||||
mod.addObjectFile(b.path(libiconv_lib_path));
|
||||
mod.addIncludePath(b.path(libiconv_include_path));
|
||||
@@ -423,7 +459,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
|
||||
const lib_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
.{ os, arch },
|
||||
);
|
||||
mod.addObjectFile(b.path(lib_path));
|
||||
mod.addIncludePath(b.path(mimalloc ++ "/include"));
|
||||
@@ -434,7 +470,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
|
||||
const ns_include_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
ns ++ "/out/{s}-{s}/include",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
.{ os, arch },
|
||||
);
|
||||
mod.addIncludePath(b.path(ns_include_path));
|
||||
|
||||
@@ -448,7 +484,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
|
||||
const ns_lib_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
.{ os, arch },
|
||||
);
|
||||
mod.addObjectFile(b.path(ns_lib_path));
|
||||
mod.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
|
||||
@@ -521,7 +557,7 @@ fn buildMbedtls(b: *Build, m: *Build.Module) !void {
|
||||
mbedtls.addIncludePath(b.path(root ++ "include"));
|
||||
mbedtls.addIncludePath(b.path(root ++ "library"));
|
||||
|
||||
mbedtls.addCSourceFiles(.{ .flags = &.{}, .files = &.{
|
||||
mbedtls.addCSourceFiles(.{ .flags = &.{"-Wno-nullability-completeness"}, .files = &.{
|
||||
root ++ "library/aes.c",
|
||||
root ++ "library/aesni.c",
|
||||
root ++ "library/aesce.c",
|
||||
@@ -675,6 +711,12 @@ fn buildNghttp2(b: *Build, m: *Build.Module) !void {
|
||||
}
|
||||
|
||||
fn buildCurl(b: *Build, m: *Build.Module) !void {
|
||||
if (m.resolved_target.?.result.os.tag == .ios) {
|
||||
const sdk_path = try std.process.getEnvVarOwned(b.allocator, "SDK");
|
||||
const include_path = try std.fmt.allocPrint(b.allocator, "{s}/usr/include", .{sdk_path});
|
||||
m.addIncludePath(.{ .cwd_relative = include_path });
|
||||
}
|
||||
|
||||
const curl = b.addLibrary(.{
|
||||
.name = "curl",
|
||||
.root_module = m,
|
||||
|
||||
Reference in New Issue
Block a user