@@ -62,28 +62,36 @@ pub fn build(b: *Build) !void {
6262 try addDependencies (b , lightpanda_module , opts );
6363
6464 {
65- // browser
66- // -------
67-
68- // compile and install
69- const exe = b .addExecutable (.{
70- .name = "lightpanda" ,
71- .use_llvm = true ,
72- .root_module = lightpanda_module ,
73- });
74- b .installArtifact (exe );
65+ // static lib
66+ // ----------
7567
76- // run
77- const run_cmd = b .addRunArtifact (exe );
78- if (b .args ) | args | {
79- run_cmd .addArgs (args );
80- }
81-
82- // step
83- const run_step = b .step ("run" , "Run the app" );
84- run_step .dependOn (& run_cmd .step );
68+ const lib = b .addLibrary (.{ .name = "lightpanda" , .root_module = lightpanda_module , .use_llvm = true , .linkage = .static });
69+ b .installArtifact (lib );
8570 }
8671
72+ // {
73+ // // browser
74+ // // -------
75+
76+ // // compile and install
77+ // const exe = b.addExecutable(.{
78+ // .name = "lightpanda",
79+ // .use_llvm = true,
80+ // .root_module = lightpanda_module,
81+ // });
82+ // b.installArtifact(exe);
83+
84+ // // run
85+ // const run_cmd = b.addRunArtifact(exe);
86+ // if (b.args) |args| {
87+ // run_cmd.addArgs(args);
88+ // }
89+
90+ // // step
91+ // const run_step = b.step("run", "Run the app");
92+ // run_step.dependOn(&run_cmd.step);
93+ // }
94+
8795 {
8896 // tests
8997 // ----
@@ -176,6 +184,7 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
176184 const os = switch (target .result .os .tag ) {
177185 .linux = > "linux" ,
178186 .macos = > "macos" ,
187+ .ios = > "ios" ,
179188 else = > return error .UnsupportedPlatform ,
180189 };
181190 var lib_path = try std .fmt .allocPrint (
@@ -199,6 +208,12 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
199208 mod .addSystemFrameworkPath (.{ .cwd_relative = "/System/Library/Frameworks" });
200209 mod .linkFramework ("CoreFoundation" , .{});
201210 },
211+ .ios = > {
212+ const sdk_path = try std .process .getEnvVarOwned (mod .owner .allocator , "SDK" );
213+ const framework_path = try std .fmt .allocPrint (mod .owner .allocator , "{s}/System/Library/Frameworks" , .{sdk_path });
214+ mod .addSystemFrameworkPath (.{ .cwd_relative = framework_path });
215+ mod .linkFramework ("CoreFoundation" , .{});
216+ },
202217 else = > {},
203218 }
204219 }
@@ -390,26 +405,47 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
390405 mod .linkFramework ("CoreFoundation" , .{});
391406 mod .linkFramework ("SystemConfiguration" , .{});
392407 },
408+ .ios = > {
409+ const sdk_path = try std .process .getEnvVarOwned (mod .owner .allocator , "SDK" );
410+ const framework_path = try std .fmt .allocPrint (mod .owner .allocator , "{s}/System/Library/Frameworks" , .{sdk_path });
411+ mod .addSystemFrameworkPath (.{ .cwd_relative = framework_path });
412+ mod .linkFramework ("CoreFoundation" , .{});
413+ mod .linkFramework ("SystemConfiguration" , .{});
414+ },
393415 else = > {},
394416 }
395417 }
396418}
397419
398420fn moduleNetSurf (b : * Build , mod : * Build.Module ) ! void {
399421 const target = mod .resolved_target .? ;
400- const os = target .result .os .tag ;
401- const arch = target .result .cpu .arch ;
422+ const os = switch (target .result .os .tag ) {
423+ .linux = > "linux" ,
424+ .macos = > "macos" ,
425+ .ios = > switch (target .result .abi ) {
426+ .simulator = > "iphonesimulator" ,
427+ else = > return error .UnsupportedPlatform ,
428+ },
429+ else = > return error .UnsupportedPlatform ,
430+ };
431+ const arch = switch (target .result .os .tag ) {
432+ .ios = > switch (target .result .cpu .arch ) {
433+ .aarch64 = > "arm64" ,
434+ else = > @tagName (target .result .cpu .arch ),
435+ },
436+ else = > @tagName (target .result .cpu .arch ),
437+ };
402438
403439 // iconv
404440 const libiconv_lib_path = try std .fmt .allocPrint (
405441 b .allocator ,
406442 "vendor/libiconv/out/{s}-{s}/lib/libiconv.a" ,
407- .{ @tagName ( os ), @tagName ( arch ) },
443+ .{ os , arch },
408444 );
409445 const libiconv_include_path = try std .fmt .allocPrint (
410446 b .allocator ,
411447 "vendor/libiconv/out/{s}-{s}/lib/libiconv.a" ,
412- .{ @tagName ( os ), @tagName ( arch ) },
448+ .{ os , arch },
413449 );
414450 mod .addObjectFile (b .path (libiconv_lib_path ));
415451 mod .addIncludePath (b .path (libiconv_include_path ));
@@ -420,7 +456,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
420456 const lib_path = try std .fmt .allocPrint (
421457 b .allocator ,
422458 mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a" ,
423- .{ @tagName ( os ), @tagName ( arch ) },
459+ .{ os , arch },
424460 );
425461 mod .addObjectFile (b .path (lib_path ));
426462 mod .addIncludePath (b .path (mimalloc ++ "/include" ));
@@ -431,7 +467,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
431467 const ns_include_path = try std .fmt .allocPrint (
432468 b .allocator ,
433469 ns ++ "/out/{s}-{s}/include" ,
434- .{ @tagName ( os ), @tagName ( arch ) },
470+ .{ os , arch },
435471 );
436472 mod .addIncludePath (b .path (ns_include_path ));
437473
@@ -445,7 +481,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
445481 const ns_lib_path = try std .fmt .allocPrint (
446482 b .allocator ,
447483 ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a" ,
448- .{ @tagName ( os ), @tagName ( arch ) },
484+ .{ os , arch },
449485 );
450486 mod .addObjectFile (b .path (ns_lib_path ));
451487 mod .addIncludePath (b .path (ns ++ "/" ++ lib ++ "/src" ));
@@ -494,7 +530,7 @@ fn buildMbedtls(b: *Build, m: *Build.Module) !void {
494530 mbedtls .addIncludePath (b .path (root ++ "include" ));
495531 mbedtls .addIncludePath (b .path (root ++ "library" ));
496532
497- mbedtls .addCSourceFiles (.{ .flags = &.{}, .files = &.{
533+ mbedtls .addCSourceFiles (.{ .flags = &.{"-Wno-nullability-completeness" }, .files = &.{
498534 root ++ "library/aes.c" ,
499535 root ++ "library/aesni.c" ,
500536 root ++ "library/aesce.c" ,
@@ -648,6 +684,12 @@ fn buildNghttp2(b: *Build, m: *Build.Module) !void {
648684}
649685
650686fn buildCurl (b : * Build , m : * Build.Module ) ! void {
687+ if (m .resolved_target .? .result .os .tag == .ios ) {
688+ const sdk_path = try std .process .getEnvVarOwned (b .allocator , "SDK" );
689+ const include_path = try std .fmt .allocPrint (b .allocator , "{s}/usr/include" , .{sdk_path });
690+ m .addIncludePath (.{ .cwd_relative = include_path });
691+ }
692+
651693 const curl = b .addLibrary (.{
652694 .name = "curl" ,
653695 .root_module = m ,
0 commit comments