-
Notifications
You must be signed in to change notification settings - Fork 7
build.zig: pulled out the options to its own structs #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -120,10 +120,12 @@ pub fn activateEmsdkStep(b: *std.Build) *std.Build.Step { | |||||||
|
||||||||
pub const EmccFlags = std.StringHashMap(void); | ||||||||
|
||||||||
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: struct { | ||||||||
pub const FlagsOptions = struct { | ||||||||
optimize: std.builtin.OptimizeMode, | ||||||||
fsanitize: bool, | ||||||||
}) EmccFlags { | ||||||||
}; | ||||||||
|
||||||||
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: FlagsOptions) EmccFlags { | ||||||||
var args = EmccFlags.init(allocator); | ||||||||
switch (options.optimize) { | ||||||||
.Debug => { | ||||||||
|
@@ -151,22 +153,22 @@ pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: struct { | |||||||
|
||||||||
pub const EmccSettings = std.StringHashMap([]const u8); | ||||||||
|
||||||||
pub fn emccDefaultSettings( | ||||||||
allocator: std.mem.Allocator, | ||||||||
options: struct { | ||||||||
optimize: std.builtin.OptimizeMode, | ||||||||
emsdk_allocator: enum { | ||||||||
none, | ||||||||
dlmalloc, | ||||||||
emmalloc, | ||||||||
@"emmalloc-debug", | ||||||||
@"emmalloc-memvalidate", | ||||||||
@"emmalloc-verbose", | ||||||||
mimalloc, | ||||||||
} = .emmalloc, | ||||||||
shell_file: ?[]const u8 = null, | ||||||||
}, | ||||||||
) EmccSettings { | ||||||||
pub const EmsdkAllocator = enum { | ||||||||
none, | ||||||||
dlmalloc, | ||||||||
emmalloc, | ||||||||
@"emmalloc-debug", | ||||||||
@"emmalloc-memvalidate", | ||||||||
@"emmalloc-verbose", | ||||||||
mimalloc, | ||||||||
}; | ||||||||
|
||||||||
pub const SettingsOptions = struct { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again for clarity and consistency let's name this |
||||||||
optimize: std.builtin.OptimizeMode, | ||||||||
emsdk_allocator: EmsdkAllocator = .emmalloc, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SettingsOptions struct is missing the shell_file field that was present in the original anonymous struct. This removes functionality that was previously available in the emccDefaultSettings function.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
}; | ||||||||
|
||||||||
pub fn emccDefaultSettings(allocator: std.mem.Allocator, options: SettingsOptions) EmccSettings { | ||||||||
var settings = EmccSettings.init(allocator); | ||||||||
switch (options.optimize) { | ||||||||
.Debug, .ReleaseSafe => { | ||||||||
|
@@ -186,19 +188,21 @@ pub const EmccFilePath = struct { | |||||||
virtual_path: ?[]const u8 = null, | ||||||||
}; | ||||||||
|
||||||||
pub const StepOptions = struct { | ||||||||
optimize: std.builtin.OptimizeMode, | ||||||||
flags: EmccFlags, | ||||||||
settings: EmccSettings, | ||||||||
use_preload_plugins: bool = false, | ||||||||
embed_paths: ?[]const EmccFilePath = null, | ||||||||
preload_paths: ?[]const EmccFilePath = null, | ||||||||
shell_file_path: ?[]const u8 = null, | ||||||||
install_dir: std.Build.InstallDir, | ||||||||
}; | ||||||||
|
||||||||
pub fn emccStep( | ||||||||
b: *std.Build, | ||||||||
wasm: *std.Build.Step.Compile, | ||||||||
options: struct { | ||||||||
optimize: std.builtin.OptimizeMode, | ||||||||
flags: EmccFlags, | ||||||||
settings: EmccSettings, | ||||||||
use_preload_plugins: bool = false, | ||||||||
embed_paths: ?[]const EmccFilePath = null, | ||||||||
preload_paths: ?[]const EmccFilePath = null, | ||||||||
shell_file_path: ?[]const u8 = null, | ||||||||
install_dir: std.Build.InstallDir, | ||||||||
}, | ||||||||
options: StepOptions, | ||||||||
) *std.Build.Step { | ||||||||
var emcc = b.addSystemCommand(&.{emccPath(b)}); | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other zig-gamedev libs, and for more clarity, let's name this
EmccDefaultFlagsOverrides
.