| ... | ... | @@ -550,17 +550,13 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *CompileStep { |
| 550 | 550 | return obj_step; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | | pub const AddModuleOptions = struct { |
| 554 | | name: []const u8, |
| 555 | | source_file: FileSource, |
| 556 | | dependencies: []const ModuleDependency = &.{}, |
| 557 | | }; |
| 558 | | |
| 559 | | pub fn addModule(b: *Build, options: AddModuleOptions) void { |
| 560 | | b.modules.put(b.dupe(options.name), b.createModule(.{ |
| 561 | | .source_file = options.source_file, |
| 562 | | .dependencies = options.dependencies, |
| 563 | | })) catch @panic("OOM"); |
| 553 | /// This function creates a module and adds it to the package's module set, making |
| 554 | /// it available to other packages which depend on this one. |
| 555 | /// `createModule` can be used instead to create a private module. |
| 556 | pub fn addModule(b: *Build, name: []const u8, options: CreateModuleOptions) *Module { |
| 557 | const module = b.createModule(options); |
| 558 | b.modules.put(b.dupe(name), module) catch @panic("OOM"); |
| 559 | return module; |
| 564 | 560 | } |
| 565 | 561 | |
| 566 | 562 | pub const ModuleDependency = struct { |
| ... | ... | @@ -573,8 +569,9 @@ pub const CreateModuleOptions = struct { |
| 573 | 569 | dependencies: []const ModuleDependency = &.{}, |
| 574 | 570 | }; |
| 575 | 571 | |
| 576 | | /// Prefer to use `addModule` which will make the module available to other |
| 577 | | /// packages which depend on this package. |
| 572 | /// This function creates a private module, to be used by the current package, |
| 573 | /// but not exposed to other packages depending on this one. |
| 574 | /// `addModule` can be used instead to create a public module. |
| 578 | 575 | pub fn createModule(b: *Build, options: CreateModuleOptions) *Module { |
| 579 | 576 | const module = b.allocator.create(Module) catch @panic("OOM"); |
| 580 | 577 | module.* = .{ |