Skip to content

Commit

Permalink
use module instead of static lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgrakkurt committed Oct 28, 2024
1 parent 19bb313 commit 1f5bc2e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
23 changes: 2 additions & 21 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
const std = @import("std");

// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});

// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const lib = b.addStaticLibrary(.{
.name = "huge_alloc",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
const huge_alloc_mod = b.addModule("huge_alloc", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});

// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);

const bench = b.addExecutable(.{
.name = "bench",
.root_source_file = b.path("src/bench.zig"),
Expand All @@ -41,8 +23,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
bench.linkLibrary(zstd_dependency.artifact("zstd"));

b.installArtifact(bench);
bench.root_module.addImport("huge_alloc", huge_alloc_mod);

const run_bench = b.addRunArtifact(bench);

Expand Down
2 changes: 1 addition & 1 deletion src/bench.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const zstd = @cImport(@cInclude("zstd.h"));
const huge_alloc = @import("root.zig");
const huge_alloc = @import("huge_alloc");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Timer = std.time.Timer;
Expand Down

0 comments on commit 1f5bc2e

Please sign in to comment.