| ... | @@ -65,6 +65,30 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com | ... | @@ -65,6 +65,30 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com |
| 65 | }); | 65 | }); |
| 66 | } | 66 | } |
| 67 | | 67 | |
| | 68 | /// Creates a module from the translated source and adds it to the package's |
| | 69 | /// module set making it available to other packages which depend on this one. |
| | 70 | /// `createModule` can be used instead to create a private module. |
| | 71 | pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module { |
| | 72 | return self.step.owner.addModule(name, .{ |
| | 73 | .source_file = .{ .generated = &self.output_file }, |
| | 74 | }); |
| | 75 | } |
| | 76 | |
| | 77 | /// Creates a private module from the translated source to be used by the |
| | 78 | /// current package, but not exposed to other packages depending on this one. |
| | 79 | /// `addModule` can be used instead to create a public module. |
| | 80 | pub fn createModule(self: *TranslateC) *std.Build.Module { |
| | 81 | const b = self.step.owner; |
| | 82 | const module = b.allocator.create(std.Build.Module) catch @panic("OOM"); |
| | 83 | |
| | 84 | module.* = .{ |
| | 85 | .builder = b, |
| | 86 | .source_file = .{ .generated = &self.output_file }, |
| | 87 | .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator), |
| | 88 | }; |
| | 89 | return module; |
| | 90 | } |
| | 91 | |
| 68 | pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void { | 92 | pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void { |
| 69 | self.include_dirs.append(self.step.owner.dupePath(include_dir)) catch @panic("OOM"); | 93 | self.include_dirs.append(self.step.owner.dupePath(include_dir)) catch @panic("OOM"); |
| 70 | } | 94 | } |