diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 22:49:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 23:38:31 -0300 |
| commit | d03b727cddfcec41b464ddf6178f17d0e831e529 (patch) | |
| tree | dee59f1590466c1a7b343be5cf873f4d1a27a7e1 /build.zig | |
| parent | 8704fa7662f40d70552daa917144987a46e14b51 (diff) | |
| download | pardes-d03b727cddfcec41b464ddf6178f17d0e831e529.tar.gz pardes-d03b727cddfcec41b464ddf6178f17d0e831e529.zip | |
kinds #50, macOS by pattern: off Linux every core module has the addons compiled in (Addon.zig's loader is a Linux memfd, now refused elsewhere at compile time), the native shell registers them at start as the tui and gui do, and `-Dmacos-sdk=<path>` hands SDL's build the SDK's paths, so `-Dplatform=gui -Dtarget=aarch64-macos` configures (and `zig build core-test -Dtarget=aarch64-macos` compiles its test binary, MuPDF and both kinds in, without running it)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -149,6 +149,7 @@ pub fn build(b: *std.Build) void { const c_optimize: std.lang.Optimize = if (optimize == .debug) .fast else optimize; const tree_sitter_grammars = b.option(TreeSitterGrammars, "tree-sitter", "tree-sitter grammar set: disabled, zig, minimal (c/c++/zig), full") orelse .full; const tracy = b.option([]const u8, "tracy", "enable Tracy profiling; supply the path to a Tracy source checkout"); + const macos_sdk = b.option([]const u8, "macos-sdk", "the macOS SDK a gui built for macOS from another system takes SDL's headers and frameworks from"); const macos_identity = b.option([]const u8, "macos-identity", "codesigning identity for pardes.app (default: ad-hoc)") orelse "-"; const prebuilt_shaders = b.option(bool, "prebuilt-shaders", "embed the committed shaders/prebuilt/*.spv instead of running glslc (default: on for a bare `zig build`, off when -Dplatform names a shell)") orelse also_gui; @@ -235,6 +236,10 @@ pub fn build(b: *std.Build) void { const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9"); for (core_mods) |mod| mod.addImport("cloud9", cloud9); const core_shells = core_shells_buf[0..core_mods_len]; + // The modules the addons are compiled into (Addon.zig reads their + // `pardes_addon`): the static step's, and every one for a system + // Addon.zig's loader, over a Linux memfd, does not run on. + const builtin_mods: []const *std.Build.Module = if (target.result.os.tag != .linux) core_mods else if (static_mod) |m| b.allocator.dupe(*std.Build.Module, &.{m}) catch @panic("OOM") else &.{}; // The conditional dependencies, hoisted so one `wireCore` call at the end // can name them all. The unconditional ones are ordinary consts below. @@ -513,9 +518,9 @@ pub fn build(b: *std.Build) void { const lib = b.addLibrary(.{ .name = "pdf", .linkage = .dynamic, .root_module = pdf_mod }); lib.setVersionScript(b.addWriteFiles().add("pdf.map", "{ global: pardes_addon; local: *; };\n")); pdf_addon = lib; - // ...and for a static pardes the same module compiled into it, - // which exports nothing there (Addon.zig reads its declaration). - if (static_mod) |m| m.addImport("pdf_addon", pdf_mod); + // ...and the same module compiled into a pardes, which exports + // nothing there (addon.exportLib). + for (builtin_mods) |m| m.addImport("pdf_addon", pdf_mod); mupdf_check.dependOn(mupdf_build.addProbe(b, mupdf, .{ .target = target, .pdf = b.path("docs/design.pdf"), @@ -849,7 +854,7 @@ pub fn build(b: *std.Build) void { image_mod.addIncludePath(zstbi_dep.path("libs/stbi")); image_mod.addCSourceFile(.{ .file = b.path("addons/image/stb.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror" } }); const image_addon = b.addLibrary(.{ .name = "image", .linkage = .dynamic, .root_module = image_mod }); - if (static_mod) |m| m.addImport("image_addon", image_mod); + for (builtin_mods) |m| m.addImport("image_addon", image_mod); for (core_mods) |m| wireCore(m, .{ .kind = kind_mod, .themes = themes_mod, @@ -880,7 +885,7 @@ pub fn build(b: *std.Build) void { mod.addOptions("doc_typ", doc_typ_opts); mod.addOptions("pardes_config", if (also_gui and shell == .gui) gui_opts.? else opts); mod.addOptions("pardes_isolation", if (isolated_mod == mod) iso_on else iso_off); - mod.addOptions("builtin_addons", if (static_mod == mod) builtin_on else builtin_off); + mod.addOptions("builtin_addons", if (std.mem.indexOfScalar(*std.Build.Module, builtin_mods, mod) != null) builtin_on else builtin_off); } // docs/typ/builtins-<platform>.json: every builtin, from the registry and the Help @@ -909,7 +914,9 @@ pub fn build(b: *std.Build) void { // The static step's gui module is a gui shell too. const gui_shell_mods: [2]?*std.Build.Module = .{ gui_shell_mod, if (platform == .gui) static_mod else null }; for (gui_shell_mods) |gui_shell_entry| if (gui_shell_entry) |gm| { - const sdl_dep = b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static }); + // SDL's build asks a cross build for macOS for the SDK's paths. + const sdk: ?std.Build.LazyPath = if (macos_sdk) |p| .{ .cwd_relative = p } else null; + const sdl_dep = b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static, .system_include_path = if (sdk) |p| p.path(b, "usr/include") else null, .system_framework_path = if (sdk) |p| p.path(b, "System/Library/Frameworks") else null, .library_path = if (sdk) |p| p.path(b, "usr/lib") else null }); if (sdl_dep) |dep| { const sdl_lib = dep.artifact("SDL3"); // SDL's own stb_image (SDL_stb.c, for SDL_LoadPNG and a camera's |
