commit e5d1a3ffd8166dec328855cae23af62a66e976e5 Author: copygirl Date: Sun Aug 20 09:56:29 2023 +0200 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c59891 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf + +indent_style = space +indent_size = 4 + +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d864d9e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/zig-cache/ +/zig-out/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..69cf0e2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "flecs"] + path = libs/flecs + url = https://github.com/SanderMertens/flecs.git diff --git a/UNLICENSE.txt b/UNLICENSE.txt new file mode 100644 index 0000000..7ac7a5d --- /dev/null +++ b/UNLICENSE.txt @@ -0,0 +1,19 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute +this software, either in source code form or as a compiled binary, for any +purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. + +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 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/build.zig b/build.zig new file mode 100644 index 0000000..c4353a6 --- /dev/null +++ b/build.zig @@ -0,0 +1,63 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) !void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const module = b.createModule(.{ + .source_file = .{ .path = "src/main.zig" }, + }); + + try b.modules.put(b.dupe("flecs-zig-ble"), module); + + const lib = b.addStaticLibrary(.{ + .name = "flecs-zig-ble", + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + lib.linkLibC(); + lib.addIncludePath(.{ .path = thisDir() ++ "/flecs" }); + lib.addCSourceFile(.{ + .file = .{ .path = thisDir() ++ "/flecs/flecs.c" }, + .flags = &.{"-fno-sanitize=undefined"}, + }); + lib.defineCMacro("FLECS_NO_CPP", null); + lib.defineCMacro("FLECS_USE_OS_ALLOC", null); + if (@import("builtin").mode == .Debug) + lib.defineCMacro("FLECS_SANITIZE", null); + + if (lib.target.isWindows()) + lib.linkSystemLibraryName("ws2_32"); + + b.installArtifact(lib); + + const main_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + main_tests.linkLibC(); + main_tests.addIncludePath(.{ .path = thisDir() ++ "/flecs" }); + main_tests.addCSourceFile(.{ + .file = .{ .path = thisDir() ++ "/flecs/flecs.c" }, + .flags = &.{"-fno-sanitize=undefined"}, + }); + main_tests.defineCMacro("FLECS_NO_CPP", null); + main_tests.defineCMacro("FLECS_USE_OS_ALLOC", null); + main_tests.defineCMacro("FLECS_SANITIZE", null); + + if (main_tests.target.isWindows()) + main_tests.linkSystemLibraryName("ws2_32"); + + const run_main_tests = b.addRunArtifact(main_tests); + + const test_step = b.step("test", "Run library tests"); + test_step.dependOn(&run_main_tests.step); +} + +inline fn thisDir() []const u8 { + return comptime std.fs.path.dirname(@src().file) orelse "."; +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..f0b2b56 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,4 @@ +.{ + .name = "flecs-zig-ble", + .version = "0.1.0", +} diff --git a/libs/flecs b/libs/flecs new file mode 160000 index 0000000..74a7f74 --- /dev/null +++ b/libs/flecs @@ -0,0 +1 @@ +Subproject commit 74a7f74a2835d3946f05502ef44ba1d5d8b48eff diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..e69de29