Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kassane/sokol-d into imgui-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Feb 3, 2024
2 parents e3e8813 + 348dd50 commit 280c927
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: (Zig) Build Native
run: zig build -DzigCC --summary all
- name: (Zig + emsdk) Build Wasm
run: zig build -DzigCC --summary all -Dtarget=wasm32-emscripten
run: zig build -DzigCC --summary all -Dtarget=wasm32-emscripten -Doptimize=ReleaseSmall
22 changes: 11 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ pub fn build(b: *Build) !void {
const enable_betterC = b.option(bool, "betterC", "Omit generating some runtime information and helper functions (default: false)") orelse false;
const enable_zigcc = b.option(bool, "zigCC", "Use zig cc as compiler and linker (default: false)") orelse false;

if (enable_zigcc) {
const zcc = buildZigCC(b);
const install = b.addInstallArtifact(zcc, .{ .dest_dir = .{ .override = .{ .custom = "tools" } } });
b.default_step.dependOn(&install.step);
}

// build examples
const examples = .{
"clear",
Expand Down Expand Up @@ -284,11 +278,6 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep {
// D compiler
try cmds.append(ldc);

if (options.zig_cc) {
try cmds.append(b.fmt("--gcc={s}", .{b.pathJoin(&.{ b.install_prefix, "tools", if (options.target.result.os.tag == .windows) "zcc.exe" else "zcc" })}));
try cmds.append(b.fmt("--linker={s}", .{b.pathJoin(&.{ b.install_prefix, "tools", if (options.target.result.os.tag == .windows) "zcc.exe" else "zcc" })}));
}

// set kind of build
switch (options.kind) {
.@"test" => {
Expand Down Expand Up @@ -541,6 +530,17 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep {
var ldc_exec = b.addSystemCommand(cmds.items);
ldc_exec.setName(options.name);

if (options.zig_cc) {
const zcc = buildZigCC(b);
const install = b.addInstallArtifact(zcc, .{ .dest_dir = .{ .override = .{ .custom = "tools" } } });
const zcc_path = b.pathJoin(&.{ b.install_prefix, "tools", if (options.target.result.os.tag == .windows) "zcc.exe" else "zcc" });
const zcc_exists = !std.meta.isError(std.fs.accessAbsolute(zcc_path, .{}));
if (!zcc_exists)
ldc_exec.step.dependOn(&install.step);
try cmds.append(b.fmt("--gcc={s}", .{zcc_path}));
try cmds.append(b.fmt("--linker={s}", .{zcc_path}));
}

if (options.artifact) |lib_sokol| {
ldc_exec.addArtifactArg(lib_sokol);
var it = lib_sokol.root_module.iterateDependencies(lib_sokol, false);
Expand Down
40 changes: 20 additions & 20 deletions src/sokol/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct Event {
}
extern(C)
struct Range {
const(void)* ptr;
const(void)* ptr = null;
size_t size = 0;
}
extern(C)
Expand All @@ -223,9 +223,9 @@ struct IconDesc {
}
extern(C)
struct Allocator {
extern(C) void* function(size_t, void*) alloc_fn;
extern(C) void function(void*, void*) free_fn;
void* user_data;
extern(C) void* function(size_t, void*) alloc_fn = null;
extern(C) void function(void*, void*) free_fn = null;
void* user_data = null;
}
enum LogItem {
Ok,
Expand Down Expand Up @@ -329,28 +329,28 @@ enum LogItem {
}
extern(C)
struct Logger {
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func;
void* user_data;
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func = null;
void* user_data = null;
}
extern(C)
struct Desc {
extern(C) void function() init_cb;
extern(C) void function() frame_cb;
extern(C) void function() cleanup_cb;
extern(C) void function(const Event *) event_cb;
void* user_data;
extern(C) void function(void*) init_userdata_cb;
extern(C) void function(void*) frame_userdata_cb;
extern(C) void function(void*) cleanup_userdata_cb;
extern(C) void function(const Event *, void*) event_userdata_cb;
extern(C) void function() init_cb = null;
extern(C) void function() frame_cb = null;
extern(C) void function() cleanup_cb = null;
extern(C) void function(const Event *) event_cb = null;
void* user_data = null;
extern(C) void function(void*) init_userdata_cb = null;
extern(C) void function(void*) frame_userdata_cb = null;
extern(C) void function(void*) cleanup_userdata_cb = null;
extern(C) void function(const Event *, void*) event_userdata_cb = null;
int width = 0;
int height = 0;
int sample_count = 0;
int swap_interval = 0;
bool high_dpi = false;
bool fullscreen = false;
bool alpha = false;
const(char)* window_title;
const(char)* window_title = null;
bool enable_clipboard = false;
int clipboard_size = 0;
bool enable_dragndrop = false;
Expand All @@ -364,7 +364,7 @@ struct Desc {
bool win32_console_utf8 = false;
bool win32_console_create = false;
bool win32_console_attach = false;
const(char)* html5_canvas_name;
const(char)* html5_canvas_name = null;
bool html5_canvas_resize = false;
bool html5_preserve_drawing_buffer = false;
bool html5_premultiplied_alpha = false;
Expand All @@ -388,14 +388,14 @@ struct Html5FetchResponse {
int file_index = 0;
Range data;
Range buffer;
void* user_data;
void* user_data = null;
}
extern(C)
struct Html5FetchRequest {
int dropped_file_index = 0;
extern(C) void function(const Html5FetchResponse *) callback;
extern(C) void function(const Html5FetchResponse *) callback = null;
Range buffer;
void* user_data;
void* user_data = null;
}
enum MouseCursor {
Default = 0,
Expand Down
16 changes: 8 additions & 8 deletions src/sokol/audio.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ enum LogItem {
}
extern(C)
struct Logger {
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func;
void* user_data;
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func = null;
void* user_data = null;
}
extern(C)
struct Allocator {
extern(C) void* function(size_t, void*) alloc_fn;
extern(C) void function(void*, void*) free_fn;
void* user_data;
extern(C) void* function(size_t, void*) alloc_fn = null;
extern(C) void function(void*, void*) free_fn = null;
void* user_data = null;
}
extern(C)
struct Desc {
Expand All @@ -58,9 +58,9 @@ struct Desc {
int buffer_frames = 0;
int packet_frames = 0;
int num_packets = 0;
extern(C) void function(float *, int, int) stream_cb;
extern(C) void function(float *, int, int, void*) stream_userdata_cb;
void* user_data;
extern(C) void function(float *, int, int) stream_cb = null;
extern(C) void function(float *, int, int, void*) stream_userdata_cb = null;
void* user_data = null;
Allocator allocator;
Logger logger;
}
Expand Down
12 changes: 6 additions & 6 deletions src/sokol/debugtext.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ enum LogItem {
}
extern(C)
struct Logger {
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func;
void* user_data;
extern(C) void function(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) func = null;
void* user_data = null;
}
extern(C)
struct Context {
uint id = 0;
}
extern(C)
struct Range {
const(void)* ptr;
const(void)* ptr = null;
size_t size = 0;
}
extern(C)
Expand All @@ -44,9 +44,9 @@ struct ContextDesc {
}
extern(C)
struct Allocator {
extern(C) void* function(size_t, void*) alloc_fn;
extern(C) void function(void*, void*) free_fn;
void* user_data;
extern(C) void* function(size_t, void*) alloc_fn = null;
extern(C) void function(void*, void*) free_fn = null;
void* user_data = null;
}
extern(C)
struct Desc {
Expand Down
Loading

0 comments on commit 280c927

Please sign in to comment.