diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 102 |
1 files changed, 3 insertions, 99 deletions
@@ -30,19 +30,6 @@ const PerfBuild = struct { pub const macos_min_version: std.SemanticVersion = .{ .major = 13, .minor = 0, .patch = 0 }; -const zls_version = "0.16.1-dev+3e0d0820"; - -comptime { - const plus = std.mem.indexOfScalar(u8, zls_version, '+') orelse - @compileError("zls_version must end in +<short commit>"); - const short = zls_version[plus + 1 ..]; - const url = zon.dependencies.zls.url; - const hash = std.mem.indexOfScalar(u8, url, '#') orelse - @compileError("the zls dependency url must pin a commit with #<sha>"); - if (!std.mem.startsWith(u8, url[hash + 1 ..], short)) @compileError( - "zls_version pins commit " ++ short ++ ", build.zig.zon pins " ++ url[hash + 1 ..], - ); -} pub const TreeSitterGrammars = enum { disabled, zig, minimal, full }; const gui_shaders = [_][]const u8{ @@ -168,14 +155,10 @@ pub fn build(b: *std.Build) void { if (!enable_mupdf) pdf_pointer_bench_step.dependOn(&b.addFail("pdf-pointer-bench is unavailable with -Dmupdf=false").step); - const shaders_step = b.step("shaders", "refresh paired shaders/prebuilt/*.spv + *.glsl snapshots (glslc)"); + const shaders_step = b.step("shaders", "refresh the committed shaders/prebuilt/*.spv (glslc)"); const update_shaders = b.addUpdateSourceFiles(); for (gui_shaders) |name| { update_shaders.addCopyFileToSource(compileGlsl(b, name), b.fmt("shaders/prebuilt/{s}.spv", .{name})); - update_shaders.addCopyFileToSource( - shaderSource(b, name), - b.fmt("shaders/prebuilt/{s}.glsl", .{name}), - ); } shaders_step.dependOn(&update_shaders.step); @@ -284,7 +267,6 @@ pub fn build(b: *std.Build) void { // The conditional dependencies, hoisted so one `wireCore` call at the end // can name them all. The unconditional ones are ordinary consts below. - var zls_mod: ?*std.Build.Module = null; var ts_mod: ?*std.Build.Module = null; var ts_queries_opts: ?*std.Build.Step.Options = null; var mupdf_core_mod: ?*std.Build.Module = null; @@ -312,8 +294,6 @@ pub fn build(b: *std.Build) void { if (target.result.os.tag == .freebsd or target.result.os.tag == .netbsd or target.result.os.tag == .openbsd) root_mod.linkSystemLibrary("util", .{}); - const zls_backend = !freestanding_core; - const esp32p4_cols = b.option(u16, "esp32p4-cols", "the board's grid width in cells (-Dplatform=esp32p4 only)") orelse 56; const esp32p4_rows = b.option(u16, "esp32p4-rows", "the board's grid height in cells (-Dplatform=esp32p4 only)") orelse 14; const theme_animation = b.option(bool, "theme-animation", "animate chrome colors across a theme change (default: off for esp32p4)"); @@ -333,7 +313,6 @@ pub fn build(b: *std.Build) void { const shell_cfg: ShellConfig = .{ .tree_sitter_grammars = tree_sitter_grammars, .tracy = tracy != null, - .zls_backend = zls_backend, .mupdf = enable_mupdf, .esp32p4_cols = esp32p4_cols, .esp32p4_rows = esp32p4_rows, @@ -341,21 +320,11 @@ pub fn build(b: *std.Build) void { .workspace_tag = workspace_tag, .prebuilt_shaders = prebuilt_shaders, .embed_sources = embed_sources, - .zig_lib_dir = b.graph.zig_lib_directory.path orelse "", .commit = if (stamp_commit) gitCommit(b) else null, }; const opts = shellOptions(b, shell_cfg, platform); const gui_opts: ?*std.Build.Step.Options = if (also_gui) shellOptions(b, shell_cfg, .gui) else null; - if (zls_backend) { - const zls_dep = b.dependency("zls", .{ - .target = target, - .optimize = optimize, - .@"version-string" = @as([]const u8, zls_version), - }); - zls_mod = zls_dep.module("zls"); - } - if (tracy) |tracy_path| { for ([_]*std.Build.Module{ root_mod, core_module }) |mod| { mod.addIncludePath(.{ .cwd_relative = tracy_path }); @@ -943,7 +912,6 @@ pub fn build(b: *std.Build) void { // BEFORE the fold below, which reads what these imports put in the table. for (core_mods) |m| wireCore(m, .{ .themes = themes_mod, - .zls = zls_mod, .tree_sitter = ts_mod, .ts_libs = ts_libs.items, .ts_queries = ts_queries_opts, @@ -956,58 +924,18 @@ pub fn build(b: *std.Build) void { .uucode = uucode_mod, }); - var module_count: usize = 0; - { - var it = root_mod.import_table.iterator(); - while (it.next()) |e| { - const lp = e.value_ptr.*.root_source_file orelse continue; - switch (lp) { - .src_path, .cwd_relative => module_count += 1, - else => continue, - } - } - } - const mod_names = b.allocator.alloc([]const u8, module_count) catch @panic("OOM"); - const mod_roots = b.allocator.alloc([]const u8, module_count) catch @panic("OOM"); - var module_index: usize = 0; - { - var it = root_mod.import_table.iterator(); - while (it.next()) |e| { - const lp = e.value_ptr.*.root_source_file orelse continue; - // `generated` is a build artifact (the options modules): it has no - // path until make() runs, and pointing an editor at one is useless - const abs = switch (lp) { - .src_path => |sp| sp.owner.pathFromRoot(sp.sub_path), - .cwd_relative => |cr| cr, - else => continue, - }; - mod_names[module_index] = e.key_ptr.*; - mod_roots[module_index] = abs; - module_index += 1; - } - } - std.debug.assert(module_index == module_count); - for ([_]?*std.Build.Step.Options{ opts, gui_opts }) |maybe| if (maybe) |o| { - o.addOption([]const []const u8, "module_names", mod_names); - o.addOption([]const []const u8, "module_roots", mod_roots); - // Whose imports those are: a .zig file outside this tree has none of them. - o.addOption([]const u8, "project_root", b.build_root.path orelse ""); - }; const iso_off = b.addOptions(); iso_off.addOption(bool, "isolated", false); const iso_on = b.addOptions(); iso_on.addOption(bool, "isolated", true); - // Consulted only for a gui shell, so `-Dprebuilt-shaders` alone decides it - // here; the platform half of that condition is the branch it sits in. - const gui_effect_source_dir = if (prebuilt_shaders) "shaders/prebuilt" else "shaders"; for (core_mods, core_shells) |mod, shell| { 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); if (shell == .gui) for (gui_shaders) |name| mod.addAnonymousImport( b.fmt("effect-source-{s}.glsl", .{name}), - .{ .root_source_file = if (prebuilt_shaders) b.path(b.fmt("{s}/{s}.glsl", .{ gui_effect_source_dir, name })) else shaderSource(b, name) }, + .{ .root_source_file = shaderSource(b, name) }, ); if (shell == .macos) mod.addAnonymousImport("effect-source-crt.ci.metal", .{ .root_source_file = b.path("shaders/crt.ci.metal"), @@ -1442,7 +1370,7 @@ pub fn build(b: *std.Build) void { if (b.args) |args| run_lspbench.addArgs(args); run_lspbench.setCwd(b.path(".")); run_lspbench.has_side_effects = true; - const lspbench_step = b.step("lspbench", "language-backend latency + feature matrix (-- [--json] [--check] [repo-root])"); + const lspbench_step = b.step("lspbench", "language-backend latency + feature matrix (-- [--json] [--check] [repo-root]), or one query (-- probe <kind> <file> <line>:<col> [arg] [--reps N])"); lspbench_step.dependOn(&run_lspbench.step); const run_lspbench_check = b.addRunArtifact(lspbench); run_lspbench_check.addArg("--check"); @@ -1452,20 +1380,6 @@ pub fn build(b: *std.Build) void { const lspbench_check_step = b.step("lspbench-check", "require every configured language probe to complete correctly"); lspbench_check_step.dependOn(&run_lspbench_check.step); - const lspprobe = b.addExecutable(.{ - .name = "pardes-lspprobe", - .root_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .root_source_file = b.path("tools/lspprobe.zig"), - .link_libc = true, - }), - }); - lspprobe.root_module.addImport("pardes", core_module); - const run_lspprobe = b.addRunArtifact(lspprobe); - if (b.args) |args| run_lspprobe.addArgs(args); - const lspprobe_step = b.step("lspprobe", "one language query against the real seam (-- <kind> <file> <line>:<col> [arg] [--reps N])"); - lspprobe_step.dependOn(&run_lspprobe.step); const locations_bench_step = b.step("locations-bench", "measure cold/warm result formatting (-Doptimize=ReleaseFast; CSV on stderr)"); if (optimize != .ReleaseFast) { @@ -1918,7 +1832,6 @@ fn gitCommit(b: *std.Build) ?[]const u8 { const ShellConfig = struct { tree_sitter_grammars: TreeSitterGrammars, tracy: bool, - zls_backend: bool, mupdf: bool, esp32p4_cols: u16, esp32p4_rows: u16, @@ -1930,7 +1843,6 @@ const ShellConfig = struct { workspace_tag: ?bool, prebuilt_shaders: bool, embed_sources: bool, - zig_lib_dir: []const u8, commit: ?[]const u8, }; @@ -1942,22 +1854,16 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build. o.addOption(bool, "syntax_minimal_grammars", cfg.tree_sitter_grammars == .minimal or cfg.tree_sitter_grammars == .full); o.addOption(bool, "syntax_full_grammars", cfg.tree_sitter_grammars == .full); o.addOption(bool, "enable_tracy", cfg.tracy); - o.addOption(bool, "zls_backend", cfg.zls_backend); o.addOption(bool, "mupdf", cfg.mupdf); o.addOption(u16, "esp32p4_cols", cfg.esp32p4_cols); o.addOption(u16, "esp32p4_rows", cfg.esp32p4_rows); o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos)); o.addOption(bool, "theme_animation", cfg.theme_animation orelse (platform != .esp32p4)); - // Meaningful only for the SDL shell. Keeping the platform condition here - // prevents Config/EffectCode from describing tty/macOS/web as "prebuilt". - o.addOption(bool, "gui_shader_sources_prebuilt", platform == .gui and cfg.prebuilt_shaders); - o.addOption([]const u8, "zls_version", if (cfg.zls_backend) zls_version else "none"); o.addOption(bool, "embed_sources", cfg.embed_sources); o.addOption([]const u8, "version", zon.version); // ...and the commit it was built from, when there is one and the build // is stamped at all (see `stamp_commit`). Read at configure time. o.addOption(?[]const u8, "commit", cfg.commit); - o.addOption([]const u8, "zig_lib_dir", cfg.zig_lib_dir); return o; } @@ -2042,7 +1948,6 @@ fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { fn wireCore(m: *std.Build.Module, d: struct { themes: ?*std.Build.Module = null, - zls: ?*std.Build.Module = null, tree_sitter: ?*std.Build.Module = null, ts_libs: []const *std.Build.Step.Compile = &.{}, ts_queries: ?*std.Build.Step.Options = null, @@ -2055,7 +1960,6 @@ fn wireCore(m: *std.Build.Module, d: struct { uucode: ?*std.Build.Module = null, }) void { if (d.themes) |x| m.addImport("generated_themes", x); - if (d.zls) |x| m.addImport("zls", x); if (d.tree_sitter) |x| m.addImport("tree-sitter", x); for (d.ts_libs) |lib| m.linkLibrary(lib); if (d.ts_queries) |x| m.addOptions("ts_queries", x); |
