diff options
Diffstat (limited to 'lib/std/Build/Step')
| -rw-r--r-- | lib/std/Build/Step/TranslateC.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/std/Build/Step/TranslateC.zig b/lib/std/Build/Step/TranslateC.zig index ced249b3f2..60e35e940b 100644 --- a/lib/std/Build/Step/TranslateC.zig +++ b/lib/std/Build/Step/TranslateC.zig @@ -65,6 +65,30 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com }); } +/// Creates a module from the translated source and adds it to the package's +/// module set making it available to other packages which depend on this one. +/// `createModule` can be used instead to create a private module. +pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module { + return self.step.owner.addModule(name, .{ + .source_file = .{ .generated = &self.output_file }, + }); +} + +/// Creates a private module from the translated source to be used by the +/// current package, but not exposed to other packages depending on this one. +/// `addModule` can be used instead to create a public module. +pub fn createModule(self: *TranslateC) *std.Build.Module { + const b = self.step.owner; + const module = b.allocator.create(std.Build.Module) catch @panic("OOM"); + + module.* = .{ + .builder = b, + .source_file = .{ .generated = &self.output_file }, + .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator), + }; + return module; +} + pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void { self.include_dirs.append(self.step.owner.dupePath(include_dir)) catch @panic("OOM"); } |
