diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1201ba6..a55cedb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,8 +24,8 @@ jobs: - name: Build run: | - zig build debugtext_print -DZigCC --summary all - zig build clear -DZigCC --summary all - zig build sgl_context -DZigCC --summary all + zig build debugtext_print -DZigCC -DBetterC --summary all + zig build clear -DZigCC -DBetterC --summary all + zig build sgl_context -DBetterC -DZigCC --summary all zig build cube -DZigCC --summary all zig build blend -DZigCC --summary all diff --git a/build.zig b/build.zig index 1ddde90..f857d63 100644 --- a/build.zig +++ b/build.zig @@ -186,7 +186,7 @@ pub fn build(b: *Builder) !void { // ldc2 w/ druntime + phobos2 works on MSVC if (builtin.os.tag == .windows and target.query.isNative()) - target.query.abi = .msvc; + target.result.abi = .msvc; const optimize = b.standardOptimizeOption(.{}); const sokol = buildSokol(b, target, optimize, config, ""); @@ -397,6 +397,7 @@ fn buildLDC(b: *Builder, lib: *CompileStep, config: ldcConfig) !*RunStep { "shape", "time", "debugtext", + "utils", }; try cmds.append("-i"); inline for (srcs) |src| { diff --git a/src/sokol/app.d b/src/sokol/app.d index 41c9484..5ff2e92 100644 --- a/src/sokol/app.d +++ b/src/sokol/app.d @@ -2,11 +2,9 @@ module sokol.app; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + enum max_touchpoints = 8; enum max_mousebuttons = 3; enum max_keycodes = 512; diff --git a/src/sokol/audio.d b/src/sokol/audio.d index c683e1a..260adcf 100644 --- a/src/sokol/audio.d +++ b/src/sokol/audio.d @@ -2,11 +2,9 @@ module sokol.audio; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + enum LogItem { Ok, Malloc_failed, diff --git a/src/sokol/debugtext.d b/src/sokol/debugtext.d index a1ab579..c34fe95 100644 --- a/src/sokol/debugtext.d +++ b/src/sokol/debugtext.d @@ -3,11 +3,9 @@ module sokol.debugtext; import sg = sokol.gfx; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + // WIP: helper function to convert "anything" to a Range struct Range asRange(T)(T val) @trusted { diff --git a/src/sokol/gfx.d b/src/sokol/gfx.d index 3be34cd..fcda653 100644 --- a/src/sokol/gfx.d +++ b/src/sokol/gfx.d @@ -2,11 +2,9 @@ module sokol.gfx; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + // WIP: helper function to convert "anything" to a Range struct Range asRange(T)(T val) @trusted { diff --git a/src/sokol/gl.d b/src/sokol/gl.d index 811a282..c6f2f04 100644 --- a/src/sokol/gl.d +++ b/src/sokol/gl.d @@ -3,11 +3,9 @@ module sokol.gl; import sg = sokol.gfx; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + enum LogItem { Ok, Malloc_failed, diff --git a/src/sokol/glue.d b/src/sokol/glue.d index 955ae3e..4b735ce 100644 --- a/src/sokol/glue.d +++ b/src/sokol/glue.d @@ -3,11 +3,9 @@ module sokol.glue; import sg = sokol.gfx; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + extern(C) sg.ContextDesc sapp_sgcontext() @system @nogc nothrow; sg.ContextDesc context() @trusted nothrow { return sapp_sgcontext(); diff --git a/src/sokol/log.d b/src/sokol/log.d index 6f0b01d..408cb2b 100644 --- a/src/sokol/log.d +++ b/src/sokol/log.d @@ -2,10 +2,8 @@ module sokol.log; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + extern(C) void slog_func(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) @system @nogc nothrow; alias func = slog_func; diff --git a/src/sokol/shape.d b/src/sokol/shape.d index d389402..3df2ea9 100644 --- a/src/sokol/shape.d +++ b/src/sokol/shape.d @@ -3,11 +3,9 @@ module sokol.shape; import sg = sokol.gfx; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + // WIP: helper function to convert "anything" to a Range struct Range asRange(T)(T val) @trusted { diff --git a/src/sokol/time.d b/src/sokol/time.d index c2bf1cb..229f667 100644 --- a/src/sokol/time.d +++ b/src/sokol/time.d @@ -2,11 +2,9 @@ module sokol.time; -// helper function to convert a C string to a D string -string cStrTod(T)(scope T c_str) nothrow { - import std.conv: to; - return c_str.to!string; -} +// helper functions +import sokol.utils: cStrTod; + extern(C) void stm_setup() @system @nogc nothrow; void setup() @trusted nothrow { stm_setup(); diff --git a/src/sokol/utils.d b/src/sokol/utils.d new file mode 100644 index 0000000..6d97330 --- /dev/null +++ b/src/sokol/utils.d @@ -0,0 +1,9 @@ +module sokol.utils; + +// helper function to convert a C string to a D string +string cStrTod(inout(char)* c_str) nothrow { + auto start = c_str; + auto end = cast(char*) c_str; + for (; *end; end++){} + return cast(string) c_str[0 .. end - start]; +} \ No newline at end of file