#How to update package -> module for latest zig

1 messages · Page 1 of 1 (latest)

grave zodiac
#

I'm trying to update some existing code for the latest master. It tries to create a package, but am not sure what the new (module?) syntax should be?

https://github.com/ringtailsoftware/zig-embeddir/blob/main/build.zig#L22

   options.addOption([]const []const u8, "files", files.items);

    var pkg = std.build.Pkg{
        .name = "assets",
        .source = options.getSource(),
    };
    exe.addPackage(pkg);
GitHub

Example showing how to embed a directory of files in a zig executable - zig-embeddir/build.zig at main · ringtailsoftware/zig-embeddir

#

This runs

    options.addOption([]const []const u8, "files", files.items);
    exe.step.dependOn(&options.step);

    _ = b.addModule("assets", .{
        .source_file = .{ .path = options.getSource().getPath(b) },
    });

But, gives me: thread 10136 panic: getPath() was called on a GeneratedFile that wasn't build yet. Is there a missing Step dependency on step 'options'?

blazing leaf
#

.source_file = options.getSource()

#

I'm not sure why you're exposing that module though, isn't it an internal options module?

grave zodiac
#

Yes, I don't know what I'm doing

blazing leaf
#

You should probably use createModule instead

#

Actually, in this case it seems like you're not making a package so it doesn't hugely matter either way

#

But basically addModule will expose the module to anything that depends on the package, whereas createModule will only create an internal module that won't be exposed to other packages

grave zodiac
blazing leaf
#

(that's the new meaning of package, not the old one - ie. package manager package, not module)