zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

blob 46b80dbf (1426B) - Raw


      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 exe = b.addExecutable(.{
     17         .name = "lib",
     18         .root_source_file = b.path("lib.zig"),
     19         .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
     20         .optimize = optimize,
     21         .strip = false,
     22     });
     23     exe.entry = .disabled;
     24     exe.use_llvm = false;
     25     exe.use_lld = false;
     26     exe.root_module.export_symbol_names = &.{"foo"};
     27     b.installArtifact(exe);
     28 
     29     const check_exe = exe.checkObject();
     30     check_exe.checkInHeaders();
     31     check_exe.checkExact("Section type");
     32     // only 2 entries, although we have more functions.
     33     // This is to test functions with the same function signature
     34     // have their types deduplicated.
     35     check_exe.checkExact("entries 2");
     36     check_exe.checkExact("params 1");
     37     check_exe.checkExact("type i32");
     38     check_exe.checkExact("returns 1");
     39     check_exe.checkExact("type i64");
     40     check_exe.checkExact("params 0");
     41     check_exe.checkExact("returns 0");
     42 
     43     test_step.dependOn(&check_exe.step);
     44 }