@@ -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 }
@@ -393,26 +408,47 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
393408 mod .linkFramework ("CoreFoundation" , .{});
394409 mod .linkFramework ("SystemConfiguration" , .{});
395410 },
411+ .ios = > {
412+ const sdk_path = try std .process .getEnvVarOwned (mod .owner .allocator , "SDK" );
413+ const framework_path = try std .fmt .allocPrint (mod .owner .allocator , "{s}/System/Library/Frameworks" , .{sdk_path });
414+ mod .addSystemFrameworkPath (.{ .cwd_relative = framework_path });
415+ mod .linkFramework ("CoreFoundation" , .{});
416+ mod .linkFramework ("SystemConfiguration" , .{});
417+ },
396418 else = > {},
397419 }
398420 }
399421}
400422
401423fn moduleNetSurf (b : * Build , mod : * Build.Module ) ! void {
402424 const target = mod .resolved_target .? ;
403- const os = target .result .os .tag ;
404- const arch = target .result .cpu .arch ;
425+ const os = switch (target .result .os .tag ) {
426+ .linux = > "linux" ,
427+ .macos = > "macos" ,
428+ .ios = > switch (target .result .abi ) {
429+ .simulator = > "iphonesimulator" ,
430+ else = > return error .UnsupportedPlatform ,
431+ },
432+ else = > return error .UnsupportedPlatform ,
433+ };
434+ const arch = switch (target .result .os .tag ) {
435+ .ios = > switch (target .result .cpu .arch ) {
436+ .aarch64 = > "arm64" ,
437+ else = > @tagName (target .result .cpu .arch ),
438+ },
439+ else = > @tagName (target .result .cpu .arch ),
440+ };
405441
406442 // iconv
407443 const libiconv_lib_path = try std .fmt .allocPrint (
408444 b .allocator ,
409445 "vendor/libiconv/out/{s}-{s}/lib/libiconv.a" ,
410- .{ @tagName ( os ), @tagName ( arch ) },
446+ .{ os , arch },
411447 );
412448 const libiconv_include_path = try std .fmt .allocPrint (
413449 b .allocator ,
414450 "vendor/libiconv/out/{s}-{s}/lib/libiconv.a" ,
415- .{ @tagName ( os ), @tagName ( arch ) },
451+ .{ os , arch },
416452 );
417453 mod .addObjectFile (b .path (libiconv_lib_path ));
418454 mod .addIncludePath (b .path (libiconv_include_path ));
@@ -423,7 +459,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
423459 const lib_path = try std .fmt .allocPrint (
424460 b .allocator ,
425461 mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a" ,
426- .{ @tagName ( os ), @tagName ( arch ) },
462+ .{ os , arch },
427463 );
428464 mod .addObjectFile (b .path (lib_path ));
429465 mod .addIncludePath (b .path (mimalloc ++ "/include" ));
@@ -434,7 +470,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
434470 const ns_include_path = try std .fmt .allocPrint (
435471 b .allocator ,
436472 ns ++ "/out/{s}-{s}/include" ,
437- .{ @tagName ( os ), @tagName ( arch ) },
473+ .{ os , arch },
438474 );
439475 mod .addIncludePath (b .path (ns_include_path ));
440476
@@ -448,7 +484,7 @@ fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
448484 const ns_lib_path = try std .fmt .allocPrint (
449485 b .allocator ,
450486 ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a" ,
451- .{ @tagName ( os ), @tagName ( arch ) },
487+ .{ os , arch },
452488 );
453489 mod .addObjectFile (b .path (ns_lib_path ));
454490 mod .addIncludePath (b .path (ns ++ "/" ++ lib ++ "/src" ));
@@ -521,7 +557,7 @@ fn buildMbedtls(b: *Build, m: *Build.Module) !void {
521557 mbedtls .addIncludePath (b .path (root ++ "include" ));
522558 mbedtls .addIncludePath (b .path (root ++ "library" ));
523559
524- mbedtls .addCSourceFiles (.{ .flags = &.{}, .files = &.{
560+ mbedtls .addCSourceFiles (.{ .flags = &.{"-Wno-nullability-completeness" }, .files = &.{
525561 root ++ "library/aes.c" ,
526562 root ++ "library/aesni.c" ,
527563 root ++ "library/aesce.c" ,
@@ -675,6 +711,12 @@ fn buildNghttp2(b: *Build, m: *Build.Module) !void {
675711}
676712
677713fn buildCurl (b : * Build , m : * Build.Module ) ! void {
714+ if (m .resolved_target .? .result .os .tag == .ios ) {
715+ const sdk_path = try std .process .getEnvVarOwned (b .allocator , "SDK" );
716+ const include_path = try std .fmt .allocPrint (b .allocator , "{s}/usr/include" , .{sdk_path });
717+ m .addIncludePath (.{ .cwd_relative = include_path });
718+ }
719+
678720 const curl = b .addLibrary (.{
679721 .name = "curl" ,
680722 .root_module = m ,
0 commit comments