| ... | @@ -1,48 +0,0 @@ |
| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub const requires_stage2 = true; |
| 4 | |
| 5 | pub fn build(b: *std.Build) void { |
| 6 | const test_step = b.step("test", "Test it"); |
| 7 | b.default_step = test_step; |
| 8 | |
| 9 | add(b, test_step, .Debug); |
| 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); |
| 12 | add(b, test_step, .ReleaseSafe); |
| 13 | } |
| 14 | |
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { |
| 16 | const lib = b.addExecutable(.{ |
| 17 | .name = "lib", |
| 18 | .root_module = b.createModule(.{ |
| 19 | .root_source_file = b.path("lib.zig"), |
| 20 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), |
| 21 | .optimize = optimize, |
| 22 | .strip = false, |
| 23 | }), |
| 24 | }); |
| 25 | lib.entry = .disabled; |
| 26 | lib.use_llvm = false; |
| 27 | lib.use_lld = false; |
| 28 | lib.link_gc_sections = false; // so data is not garbage collected and we can verify data section |
| 29 | b.installArtifact(lib); |
| 30 | |
| 31 | const check_lib = lib.checkObject(); |
| 32 | check_lib.checkInHeaders(); |
| 33 | check_lib.checkExact("Section data"); |
| 34 | check_lib.checkExact("entries 2"); // rodata & data, no bss because we're exporting memory |
| 35 | |
| 36 | check_lib.checkInHeaders(); |
| 37 | check_lib.checkExact("Section custom"); |
| 38 | check_lib.checkInHeaders(); |
| 39 | check_lib.checkExact("name name"); // names custom section |
| 40 | check_lib.checkInHeaders(); |
| 41 | check_lib.checkExact("type data_segment"); |
| 42 | check_lib.checkExact("names 2"); |
| 43 | check_lib.checkExact("index 0"); |
| 44 | check_lib.checkExact("name .rodata"); |
| 45 | check_lib.checkExact("index 1"); |
| 46 | check_lib.checkExact("name .data"); |
| 47 | test_step.dependOn(&check_lib.step); |
| 48 | } |