mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(build): add zig build script
This commit is contained in:
parent
25b12dee7b
commit
fa11d11f46
3 changed files with 187 additions and 1 deletions
158
build.zig
Normal file
158
build.zig
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const system = @import("system");
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) void {
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const t = target.result;
|
||||||
|
|
||||||
|
// Squall library
|
||||||
|
const storm = b.addStaticLibrary(.{
|
||||||
|
.name = "storm",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize
|
||||||
|
});
|
||||||
|
// Link C++ standard library
|
||||||
|
storm.linkLibCpp();
|
||||||
|
// Add system detection defines
|
||||||
|
system.add_defines(storm);
|
||||||
|
|
||||||
|
// Get dependencies
|
||||||
|
const mem = b.dependency("mem", .{});
|
||||||
|
const bc = b.dependency("bc", .{});
|
||||||
|
// Publicly link mem
|
||||||
|
storm.addIncludePath(mem.path("."));
|
||||||
|
storm.linkLibrary(mem.artifact("mem"));
|
||||||
|
// Link bc
|
||||||
|
storm.addIncludePath(bc.path("."));
|
||||||
|
storm.linkLibrary(bc.artifact("bc"));
|
||||||
|
|
||||||
|
// Include squall project directory
|
||||||
|
storm.addIncludePath(b.path("."));
|
||||||
|
|
||||||
|
const storm_compiler_flags = [_][]const u8 {
|
||||||
|
"-std=c++11",
|
||||||
|
"-Wno-invalid-offsetof"
|
||||||
|
};
|
||||||
|
|
||||||
|
const storm_sources = [_][]const u8 {
|
||||||
|
"storm/big/BigBuffer.cpp",
|
||||||
|
"storm/big/BigData.cpp",
|
||||||
|
"storm/big/BigStack.cpp",
|
||||||
|
"storm/big/Ops.cpp",
|
||||||
|
|
||||||
|
"storm/hash/HashKey.cpp",
|
||||||
|
|
||||||
|
"storm/queue/CSBasePriority.cpp",
|
||||||
|
"storm/queue/CSBasePriorityQueue.cpp",
|
||||||
|
|
||||||
|
"storm/string/bjhash.cpp",
|
||||||
|
|
||||||
|
"storm/thread/CCritSect.cpp",
|
||||||
|
"storm/thread/CSRWLock.cpp",
|
||||||
|
"storm/thread/S_Thread.cpp",
|
||||||
|
"storm/thread/SCritSect.cpp",
|
||||||
|
"storm/thread/SEvent.cpp",
|
||||||
|
"storm/thread/SSemaphore.cpp",
|
||||||
|
"storm/thread/SSyncObject.cpp",
|
||||||
|
"storm/thread/SThread.cpp",
|
||||||
|
|
||||||
|
"storm/Atomic.cpp",
|
||||||
|
"storm/Big.cpp",
|
||||||
|
"storm/Command.cpp",
|
||||||
|
"storm/Crypto.cpp",
|
||||||
|
"storm/Error.cpp",
|
||||||
|
"storm/Log.cpp",
|
||||||
|
"storm/Region.cpp",
|
||||||
|
"storm/String.cpp",
|
||||||
|
"storm/Thread.cpp",
|
||||||
|
"storm/Unicode.cpp"
|
||||||
|
};
|
||||||
|
|
||||||
|
const storm_windows_sources = [_][]const u8{
|
||||||
|
"storm/error/win/Display.cpp",
|
||||||
|
"storm/error/win/Error.cpp",
|
||||||
|
"storm/thread/win/S_Thread.cpp",
|
||||||
|
"storm/thread/win/SRWLock.cpp",
|
||||||
|
"storm/thread/win/Thread.cpp"
|
||||||
|
};
|
||||||
|
|
||||||
|
const storm_macos_sources = [_][]const u8{
|
||||||
|
"storm/thread/mac/S_Thread.mm",
|
||||||
|
"storm/thread/mac/SThreadRunner.mm",
|
||||||
|
"storm/thread/mac/Thread.mm"
|
||||||
|
};
|
||||||
|
|
||||||
|
const storm_linux_sources = [_][]const u8{
|
||||||
|
"storm/thread/linux/S_Thread.cpp",
|
||||||
|
"storm/thread/linux/Thread.cpp"
|
||||||
|
};
|
||||||
|
|
||||||
|
storm.addCSourceFiles(.{
|
||||||
|
.files = &storm_sources,
|
||||||
|
.flags = &storm_compiler_flags
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (t.os.tag) {
|
||||||
|
.windows => {
|
||||||
|
storm.addCSourceFiles(.{
|
||||||
|
.files = &storm_windows_sources,
|
||||||
|
.flags = &storm_compiler_flags
|
||||||
|
});
|
||||||
|
},
|
||||||
|
.macos => {
|
||||||
|
storm.addCSourceFiles(.{
|
||||||
|
.files = &storm_macos_sources,
|
||||||
|
.flags = &storm_compiler_flags
|
||||||
|
});
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
storm.addCSourceFiles(.{
|
||||||
|
.files = &storm_linux_sources,
|
||||||
|
.flags = &storm_compiler_flags
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StormTest executable
|
||||||
|
const storm_test_exe = b.addExecutable(.{
|
||||||
|
.name = "StormTest",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize
|
||||||
|
});
|
||||||
|
// Link C++ standard library
|
||||||
|
storm_test_exe.linkLibCpp();
|
||||||
|
// Add system detection defines
|
||||||
|
system.add_defines(storm_test_exe);
|
||||||
|
|
||||||
|
storm_test_exe.linkLibrary(storm);
|
||||||
|
|
||||||
|
storm_test_exe.addIncludePath(mem.path("."));
|
||||||
|
storm_test_exe.addIncludePath(b.path("."));
|
||||||
|
|
||||||
|
storm_test_exe.addCSourceFiles(.{
|
||||||
|
.files = &.{
|
||||||
|
"test/big/Ops.cpp",
|
||||||
|
"test/Array.cpp",
|
||||||
|
"test/Atomic.cpp",
|
||||||
|
"test/Big.cpp",
|
||||||
|
"test/Crypto.cpp",
|
||||||
|
"test/Hash.cpp",
|
||||||
|
"test/List.cpp",
|
||||||
|
"test/Log.cpp",
|
||||||
|
"test/Memory.cpp",
|
||||||
|
"test/Queue.cpp",
|
||||||
|
"test/Region.cpp",
|
||||||
|
"test/String.cpp",
|
||||||
|
"test/Test.cpp",
|
||||||
|
"test/Thread.cpp",
|
||||||
|
"test/Unicode.cpp",
|
||||||
|
},
|
||||||
|
|
||||||
|
.flags = &storm_compiler_flags
|
||||||
|
});
|
||||||
|
|
||||||
|
b.installArtifact(storm_test_exe);
|
||||||
|
b.installArtifact(storm);
|
||||||
|
}
|
||||||
19
build.zig.zon
Normal file
19
build.zig.zon
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.{
|
||||||
|
.name = "squall",
|
||||||
|
.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",
|
||||||
|
},
|
||||||
|
.bc = .{
|
||||||
|
.url = "https://github.com/thunderbrewhq/bc/archive/refs/heads/master.zip",
|
||||||
|
.hash = "12202ac82de86543714d79a8c055b7357fd8c4c6ba3bf73ec4f1cdd5771885c728ad",
|
||||||
|
},
|
||||||
|
.mem = .{
|
||||||
|
.url = "https://github.com/thunderbrewhq/mem/archive/refs/heads/master.zip",
|
||||||
|
.hash = "122037f90f957dec643fe16e0092c8b971b7dd0a0f8096d00fa134e254053fbced87",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
#ifndef STORM_MEMORY_HPP
|
#ifndef STORM_MEMORY_HPP
|
||||||
#define STORM_MEMORY_HPP
|
#define STORM_MEMORY_HPP
|
||||||
|
|
||||||
#include <mem/Memory.hpp>
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags);
|
||||||
|
|
||||||
|
void SMemFree(void* ptr);
|
||||||
|
|
||||||
|
void SMemFree(void* ptr, const char* filename, int32_t linenumber, uint32_t flags);
|
||||||
|
|
||||||
|
void* SMemReAlloc(void* ptr, size_t bytes, const char* filename, int32_t linenumber, uint32_t flags);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue