zig-webgpu-gen

git clone git://git.electrosoup.com/zig-webgpu-gen
Log | Files | Refs

build.zig (1303B)


      1 const std = @import("std");
      2 
      3 pub fn build(b: *std.Build) void {
      4     const target = b.standardTargetOptions(.{});
      5     const optimize = b.standardOptimizeOption(.{});
      6     const exe_mod = b.createModule(.{
      7         .root_source_file = b.path("src/main.zig"),
      8         .target = target,
      9         .optimize = optimize,
     10     });
     11     const exe = b.addExecutable(.{
     12         .name = "webgpu-gen",
     13         .root_module = exe_mod,
     14     });
     15     const run_cmd = b.addRunArtifact(exe);
     16     const gen_file = run_cmd.addOutputFileArg("webgpu.zig");
     17 
     18     const install_raw = b.addInstallFile(gen_file, "webgpu-raw.zig");
     19     install_raw.step.dependOn(&run_cmd.step);
     20     b.getInstallStep().dependOn(&install_raw.step);
     21 
     22     const fmt_cmd = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt" });
     23     fmt_cmd.addFileArg(gen_file);
     24 
     25     const install_fmt = b.addInstallFile(gen_file, "webgpu.zig");
     26     install_fmt.step.dependOn(&fmt_cmd.step);
     27     b.getInstallStep().dependOn(&install_fmt.step);
     28 
     29     const lib_mod = b.createModule(.{
     30         .root_source_file = gen_file,
     31         .target = target,
     32         .optimize = optimize,
     33     });
     34     const lib = b.addLibrary(.{
     35         .linkage = .static,
     36         .name = "webgpu",
     37         .root_module = lib_mod,
     38     });
     39     lib.step.dependOn(&fmt_cmd.step);
     40 
     41     b.installArtifact(lib);
     42 }