Skip to content

Commit 2fe7535

Browse files
committed
build.zig: pulled out the options to its own structs
1 parent 67f606a commit 2fe7535

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

build.zig

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ pub fn activateEmsdkStep(b: *std.Build) *std.Build.Step {
105105

106106
pub const EmccFlags = std.StringHashMap(void);
107107

108-
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: struct {
108+
pub const EmccDefaultFlagsOverrides = struct {
109109
optimize: std.builtin.OptimizeMode,
110110
fsanitize: bool,
111-
}) EmccFlags {
111+
};
112+
113+
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: EmccDefaultFlagsOverrides) EmccFlags {
112114
var args = EmccFlags.init(allocator);
113115
switch (options.optimize) {
114116
.Debug => {
@@ -136,22 +138,23 @@ pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: struct {
136138

137139
pub const EmccSettings = std.StringHashMap([]const u8);
138140

139-
pub fn emccDefaultSettings(
140-
allocator: std.mem.Allocator,
141-
options: struct {
142-
optimize: std.builtin.OptimizeMode,
143-
emsdk_allocator: enum {
144-
none,
145-
dlmalloc,
146-
emmalloc,
147-
@"emmalloc-debug",
148-
@"emmalloc-memvalidate",
149-
@"emmalloc-verbose",
150-
mimalloc,
151-
} = .emmalloc,
152-
shell_file: ?[]const u8 = null,
153-
},
154-
) EmccSettings {
141+
pub const EmsdkAllocator = enum {
142+
none,
143+
dlmalloc,
144+
emmalloc,
145+
@"emmalloc-debug",
146+
@"emmalloc-memvalidate",
147+
@"emmalloc-verbose",
148+
mimalloc,
149+
};
150+
151+
pub const EmccDefaultSettingsOverrides = struct {
152+
optimize: std.builtin.OptimizeMode,
153+
emsdk_allocator: EmsdkAllocator = .emmalloc,
154+
shell_file: ?[]const u8 = null,
155+
};
156+
157+
pub fn emccDefaultSettings(allocator: std.mem.Allocator, options: EmccDefaultSettingsOverrides) EmccSettings {
155158
var settings = EmccSettings.init(allocator);
156159
switch (options.optimize) {
157160
.Debug, .ReleaseSafe => {
@@ -171,9 +174,21 @@ pub const EmccFilePath = struct {
171174
virtual_path: ?[]const u8 = null,
172175
};
173176

177+
pub const StepOptions = struct {
178+
optimize: std.builtin.OptimizeMode,
179+
flags: EmccFlags,
180+
settings: EmccSettings,
181+
use_preload_plugins: bool = false,
182+
embed_paths: ?[]const EmccFilePath = null,
183+
preload_paths: ?[]const EmccFilePath = null,
184+
shell_file_path: ?std.Build.LazyPath = null,
185+
install_dir: std.Build.InstallDir,
186+
};
187+
174188
pub fn emccStep(
175189
b: *std.Build,
176190
wasm: *std.Build.Step.Compile,
191+
<<<<<<< HEAD
177192
options: struct {
178193
optimize: std.builtin.OptimizeMode,
179194
flags: EmccFlags,
@@ -184,6 +199,9 @@ pub fn emccStep(
184199
shell_file_path: ?std.Build.LazyPath = null,
185200
install_dir: std.Build.InstallDir,
186201
},
202+
=======
203+
options: StepOptions,
204+
>>>>>>> c0b8b70 (build.zig: pulled out the options to its own structs)
187205
) *std.Build.Step {
188206
var emcc = b.addSystemCommand(&.{emccPath(b)});
189207

0 commit comments

Comments
 (0)