ikskuh/SDL.zig

cannot use getWrapperModuleVulkan

Opened this issue · 0 comments

AT14C commented

I cannot use the wrapper w/vulkan-zig without getting an error for the vulkan binding existing in both modules

this is my build.zig

const std = @import("std");
const sdl = @import("lib/SDL.zig/build.zig");
const vkgen = @import("lib/vulkan-zig/generator/index.zig");

pub fn build(b: *std.build.Builder) !void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});


    const exe = b.addExecutable(.{
        .name = "test",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    const sdk = sdl.init(b, null);
    sdl.link(sdk, exe, .dynamic);
    const gen = vkgen.VkGenerateStep.create(b, "vk.xml");
    
    exe.addModule("sdl2", sdl.getWrapperModuleVulkan(sdk, gen.getModule()));
    exe.addModule("vulkan", gen.getModule());

    const shaders = vkgen.ShaderCompileStep.create(
        b,
        &[_][]const u8{ "glslc", "--target-env=vulkan1.2" },
        "-o",
    );
    shaders.add("triangle_vert", "shaders/triangle.vert", .{});
    shaders.add("triangle_frag", "shaders/triangle.frag", .{});
    exe.addModule("shaders", shaders.getModule());
    
    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);
    run_cmd.step.dependOn(b.getInstallStep());
    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    const run_step = b.step("run", "Run test");
    run_step.dependOn(&run_cmd.step);
}

and this is the error i get

zig-cache/o/ac2f9342bd342b23d954a92e2875a499/vk.zig:1:1: error: file exists in multiple modules
zig-cache/o/ac2f9342bd342b23d954a92e2875a499/vk.zig:1:1: note: root of module vulkan0
zig-cache/o/ac2f9342bd342b23d954a92e2875a499/vk.zig:1:1: note: root of module vulkan

removing the vulkan module and leaving just the sdl2 module does not fix the problem because then I cannot use vulkan at all in my code