its kind of working now
This commit is contained in:
131
build.zig
Normal file
131
build.zig
Normal file
@@ -0,0 +1,131 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// === Main Executable ===
|
||||
const exe_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zynamodb",
|
||||
.root_module = exe_module,
|
||||
});
|
||||
|
||||
// Link RocksDB (C library)
|
||||
exe.linkLibC();
|
||||
exe.linkSystemLibrary("rocksdb");
|
||||
|
||||
// Compression libraries that RocksDB depends on
|
||||
exe.linkSystemLibrary("snappy");
|
||||
exe.linkSystemLibrary("lz4");
|
||||
exe.linkSystemLibrary("zstd");
|
||||
exe.linkSystemLibrary("z");
|
||||
exe.linkSystemLibrary("bz2");
|
||||
exe.linkSystemLibrary("stdc++");
|
||||
|
||||
// Add include path for RocksDB headers
|
||||
exe.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
|
||||
exe.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
// === Run Command ===
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run the DynamoDB-compatible server");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
// === Unit Tests ===
|
||||
const unit_tests_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_module = unit_tests_module,
|
||||
});
|
||||
|
||||
unit_tests.linkLibC();
|
||||
unit_tests.linkSystemLibrary("rocksdb");
|
||||
unit_tests.linkSystemLibrary("snappy");
|
||||
unit_tests.linkSystemLibrary("lz4");
|
||||
unit_tests.linkSystemLibrary("zstd");
|
||||
unit_tests.linkSystemLibrary("z");
|
||||
unit_tests.linkSystemLibrary("bz2");
|
||||
unit_tests.linkSystemLibrary("stdc++");
|
||||
unit_tests.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
|
||||
unit_tests.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
|
||||
|
||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_unit_tests.step);
|
||||
|
||||
// === Integration Tests ===
|
||||
const integration_tests_module = b.createModule(.{
|
||||
.root_source_file = b.path("tests/integration.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const integration_tests = b.addTest(.{
|
||||
.root_module = integration_tests_module,
|
||||
});
|
||||
|
||||
integration_tests.linkLibC();
|
||||
integration_tests.linkSystemLibrary("rocksdb");
|
||||
integration_tests.linkSystemLibrary("snappy");
|
||||
integration_tests.linkSystemLibrary("lz4");
|
||||
integration_tests.linkSystemLibrary("zstd");
|
||||
integration_tests.linkSystemLibrary("z");
|
||||
integration_tests.linkSystemLibrary("bz2");
|
||||
integration_tests.linkSystemLibrary("stdc++");
|
||||
integration_tests.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
|
||||
integration_tests.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
|
||||
|
||||
const run_integration_tests = b.addRunArtifact(integration_tests);
|
||||
const integration_step = b.step("test-integration", "Run integration tests");
|
||||
integration_step.dependOn(&run_integration_tests.step);
|
||||
|
||||
// === Benchmarks ===
|
||||
const bench_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/bench.zig"),
|
||||
.target = target,
|
||||
.optimize = .ReleaseFast,
|
||||
});
|
||||
|
||||
const bench = b.addExecutable(.{
|
||||
.name = "bench",
|
||||
.root_module = bench_module,
|
||||
});
|
||||
|
||||
bench.linkLibC();
|
||||
bench.linkSystemLibrary("rocksdb");
|
||||
bench.linkSystemLibrary("snappy");
|
||||
bench.linkSystemLibrary("lz4");
|
||||
bench.linkSystemLibrary("zstd");
|
||||
bench.linkSystemLibrary("z");
|
||||
bench.linkSystemLibrary("bz2");
|
||||
bench.linkSystemLibrary("stdc++");
|
||||
bench.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
|
||||
bench.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
|
||||
|
||||
const run_bench = b.addRunArtifact(bench);
|
||||
const bench_step = b.step("bench", "Run benchmarks");
|
||||
bench_step.dependOn(&run_bench.step);
|
||||
|
||||
// === Clean ===
|
||||
const clean_step = b.step("clean", "Remove build artifacts");
|
||||
clean_step.dependOn(&b.addRemoveDirTree(b.path("zig-out")).step);
|
||||
clean_step.dependOn(&b.addRemoveDirTree(b.path(".zig-cache")).step);
|
||||
}
|
||||
Reference in New Issue
Block a user