From a26de422ca69cb53d7a24018dca1161518dc0c39 Mon Sep 17 00:00:00 2001 From: superp00t Date: Fri, 28 Jun 2024 04:30:37 -0400 Subject: [PATCH] feat(build): add zig build script --- build.zig | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ build.zig.zon | 15 ++++++++++ 2 files changed, 93 insertions(+) create mode 100644 build.zig create mode 100644 build.zig.zon diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..8cc03d0 --- /dev/null +++ b/build.zig @@ -0,0 +1,78 @@ +const std = @import("std"); +const system = @import("system"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + // Typhoon library + const tempest = b.addStaticLibrary(.{ + .name = "tempest", + .target = target, + .optimize = optimize + }); + // Link C++ standard library + tempest.linkLibCpp(); + // Add system detection defines + system.add_defines(tempest); + + // Get dependencies + const squall = b.dependency("squall", .{}); + // Link storm + tempest.addIncludePath(squall.path(".")); + tempest.linkLibrary(squall.artifact("storm")); + + // Include Typhoon project directory + tempest.addIncludePath(b.path(".")); + + const tempest_compiler_flags = [_][]const u8 { + "-std=c++11", + }; + + const tempest_sources = [_][]const u8 { + "tempest/matrix/C44Matrix.cpp", + + "tempest/quaternion/C4Quaternion.cpp", + + "tempest/rect/CRect.cpp", + + "tempest/vector/C2Vector.cpp", + "tempest/vector/C3Vector.cpp", + "tempest/vector/CImVector.cpp" + }; + + tempest.addCSourceFiles(.{ + .files = &tempest_sources, + .flags = &tempest_compiler_flags + }); + + // TempestTest executable + const tempest_test_exe = b.addExecutable(.{ + .name = "TempestTest", + .target = target, + .optimize = optimize + }); + // Link C++ standard library + tempest_test_exe.linkLibCpp(); + // Add system detection defines + system.add_defines(tempest_test_exe); + + tempest_test_exe.linkLibrary(tempest); + tempest_test_exe.addIncludePath(squall.path(".")); + tempest_test_exe.addIncludePath(b.path(".")); + + tempest_test_exe.addCSourceFiles(.{ + .files = &.{ + "test/Math.cpp", + "test/Matrix.cpp", + "test/Rect.cpp", + "test/Test.cpp", + "test/Vector.cpp" + }, + + .flags = &tempest_compiler_flags + }); + + b.installArtifact(tempest_test_exe); + b.installArtifact(tempest); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..48b50d4 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,15 @@ +.{ + .name = "typhoon", + .version = "1.0.0", + .paths = .{ "LICENSE", "README.md", "build.zig", "build.zig.zon" }, + .dependencies = .{ + .system = .{ + .url = "https://github.com/thunderbrewhq/system/archive/refs/heads/master.zip", + .hash = "1220d6a6e4e2f836c1c22eb128e6c74c773ea191bfbaac02601dcb5238c2b0874182", + }, + .squall = .{ + .url = "https://github.com/thunderbrewhq/squall/archive/refs/heads/master.zip", + .hash = "1220295d6cc1e9256ef548850ae3a0d3e550c10eb6e8a251d9492979bf7286e5a264", + }, + }, +}