From d505f7db36202b7dab1f159114f7e3a8d813966e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 19 Aug 2023 00:42:57 +0200 Subject: Initial commit --- .gitignore | 2 ++ .gitmodules | 3 +++ LICENSE | 19 +++++++++++++++++++ README.md | 1 + build.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ depends/mgl | 1 + 6 files changed, 70 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build.zig create mode 160000 depends/mgl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e73c965 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +zig-cache/ +zig-out/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b6b69cf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "depends/mgl"] + path = depends/mgl + url = https://repo.dec05eba.com/mgl diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bc8b574 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) dec05eba + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..849a465 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +[mgl](https://git.dec05eba.com/mgl/about/) build for zig. See [mgl-zig-example](https://git.dec05eba.com/mgl-zig-example/about) for an example on how to use this. diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..3267700 --- /dev/null +++ b/build.zig @@ -0,0 +1,44 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const lib = b.addStaticLibrary(.{ + .name = "mgl-zig", + .target = target, + .optimize = optimize, + }); + + lib.addCSourceFiles(&[_][]const u8{ + "depends/mgl/src/graphics/texture.c", + "depends/mgl/src/graphics/sprite.c", + "depends/mgl/src/graphics/image.c", + "depends/mgl/src/graphics/font_char_map.c", + "depends/mgl/src/graphics/font.c", + "depends/mgl/src/graphics/vertex.c", + "depends/mgl/src/graphics/primitive_type.c", + "depends/mgl/src/graphics/vertex_buffer.c", + "depends/mgl/src/graphics/text.c", + "depends/mgl/src/graphics/shader.c", + "depends/mgl/src/graphics/rectangle.c", + "depends/mgl/src/system/fileutils.c", + "depends/mgl/src/system/utf8.c", + "depends/mgl/src/system/clock.c", + "depends/mgl/src/mgl.c", + "depends/mgl/src/window/window.c", + "depends/mgl/src/gl.c", + }, &[_][]const u8{ + "-Wall", + "-Wextra", + }); + lib.addIncludePath(.{ .path = "depends/mgl/include" }); + lib.linkSystemLibrary("x11"); + lib.linkSystemLibrary("xrender"); + lib.linkLibC(); + lib.strip = optimize != std.builtin.OptimizeMode.Debug; + lib.single_threaded = true; + lib.want_lto = optimize != std.builtin.OptimizeMode.Debug; + + b.installArtifact(lib); +} diff --git a/depends/mgl b/depends/mgl new file mode 160000 index 0000000..15cb00d --- /dev/null +++ b/depends/mgl @@ -0,0 +1 @@ +Subproject commit 15cb00dfffd777e97abf8732f84a3c3c3bd659e9 -- cgit v1.2.3