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 66e6b0e commit eaac69f
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 @@ -63,8 +63,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 @@ -82,8 +85,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 @@ -164,11 +170,12 @@ 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);
benchmark_exe.root_module.addImport("prettytable", pretty_table_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 eaac69f

Please sign in to comment.