Skip to content

Commit

Permalink
refactor(build.zig): use switch instead of ifs for database dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed Nov 5, 2024
1 parent e2910ce commit 52d06dc
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ pub fn build(b: *Build) void {
sig_mod.addImport("httpz", httpz_mod);
sig_mod.addImport("zstd", zstd_mod);
sig_mod.addImport("curl", curl_mod);
if (blockstore_db == .rocksdb) sig_mod.addImport("rocksdb", rocksdb_mod);
if (blockstore_db == .lmdb) sig_mod.addImport("lmdb", lmdb_mod);
switch (blockstore_db) {
.rocksdb => sig_mod.addImport("rocksdb", rocksdb_mod),
.lmdb => sig_mod.addImport("lmdb", lmdb_mod),
.hashmap => {},
}
sig_mod.addOptions("build-options", build_options);

// main executable
Expand All @@ -78,8 +81,11 @@ pub fn build(b: *Build) void {
sig_exe.root_module.addImport("zig-cli", zig_cli_module);
sig_exe.root_module.addImport("zig-network", zig_network_module);
sig_exe.root_module.addImport("zstd", zstd_mod);
if (blockstore_db == .rocksdb) sig_exe.root_module.addImport("rocksdb", rocksdb_mod);
if (blockstore_db == .lmdb) sig_exe.root_module.addImport("lmdb", lmdb_mod);
switch (blockstore_db) {
.rocksdb => sig_exe.root_module.addImport("rocksdb", rocksdb_mod),
.lmdb => sig_exe.root_module.addImport("lmdb", lmdb_mod),
.hashmap => {},
}
sig_exe.root_module.addOptions("build-options", build_options);
sig_exe.linkLibC();

Expand Down Expand Up @@ -157,10 +163,11 @@ pub fn build(b: *Build) void {
benchmark_exe.root_module.addImport("zig-network", zig_network_module);
benchmark_exe.root_module.addImport("httpz", httpz_mod);
benchmark_exe.root_module.addImport("zstd", zstd_mod);
benchmark_exe.root_module.addImport("rocksdb", rocksdb_mod);
benchmark_exe.root_module.addImport("lmdb", lmdb_mod);
if (blockstore_db == .rocksdb) sig_exe.root_module.addImport("rocksdb", rocksdb_mod);
if (blockstore_db == .lmdb) sig_exe.root_module.addImport("lmdb", lmdb_mod);
switch (blockstore_db) {
.rocksdb => benchmark_exe.root_module.addImport("rocksdb", rocksdb_mod),
.lmdb => benchmark_exe.root_module.addImport("lmdb", lmdb_mod),
.hashmap => {},
}
benchmark_exe.root_module.addOptions("build-options", build_options);
benchmark_exe.linkLibC();

Expand Down

0 comments on commit 52d06dc

Please sign in to comment.