const std = @import("std"); pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const wasm = b.addExecutable(.{ .name = "paper-editor", .root_module = b.createModule(.{ .root_source_file = b.path("core/wasm.zig"), .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding, }), .optimize = optimize, }), }); wasm.entry = .disabled; wasm.root_module.export_symbol_names = &.{ "alloc", "free", "abi_version", "init", "block_count", "block_id", "block_kind", "block_text_ptr", "block_text_len", "inline_prepare", "inline_resolve", "inline_step", "inline_replace", "inline_runs_ptr", "inline_runs_len", "set_selection", "selection_anchor_block", "selection_anchor_offset", "selection_focus_block", "selection_focus_offset", "replace_selection", "replace_range", "type_text", "set_kind", "backspace_boundary", "undo", "redo", "revision", "markdown_ptr", "markdown_len", "shape_changed", "changed_block_count", "changed_block_id", "import_markdown", "source_ptr", "source_len", "block_depth", "block_ordinal", }; wasm.export_memory = true; b.installArtifact(wasm); const tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("core/markdown.zig"), .target = b.graph.host, .optimize = optimize, }), }); const core_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("core/editor.zig"), .target = b.graph.host, .optimize = optimize, }), }); const fixture_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("core/editor_fixture_test.zig"), .target = b.graph.host, .optimize = optimize, }), }); const test_step = b.step("test", "Run editor fixtures and existing suites, and compile WASM"); test_step.dependOn(&b.addRunArtifact(fixture_tests).step); test_step.dependOn(&b.addRunArtifact(core_tests).step); test_step.dependOn(&b.addRunArtifact(tests).step); test_step.dependOn(&wasm.step); }