Skip to content

Commit

Permalink
Merge pull request #1 from tazend/update-for-latest-zig-master
Browse files Browse the repository at this point in the history
update build.zig for zig 0.12.0-dev.3635+786876c05
  • Loading branch information
Hanaasagi authored Apr 22, 2024
2 parents f5c7a82 + e87bfb7 commit 1cdfca7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const std = @import("std");
const Module = std.build.Module;
const Builder = std.build.Builder;
const Module = std.Build.Module;
const Mode = std.builtin.Mode;
const CrossTarget = std.zig.CrossTarget;
const FileSource = std.build.FileSource;
const ResolvedTarget = std.Build.ResolvedTarget;

// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
Expand All @@ -20,6 +18,10 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const module = b.addModule("prettytable", .{
.root_source_file = .{ .path = "src/lib.zig" },
});

const lib = b.addStaticLibrary(.{
.name = "prettytable-zig",
// In this case the main source file is merely a path, however, in more
Expand Down Expand Up @@ -99,13 +101,13 @@ pub fn build(b: *std.Build) void {
test_step.dependOn(&run_table_tests.step);
test_step.dependOn(&run_style_tests.step);

buildExample(b, optimize, target, &.{ "basic", "format", "multiline", "align", "read", "style" });
buildExample(b, optimize, target, module, &.{ "basic", "format", "multiline", "align", "read", "style" });
}

// 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 buildExample(b: *std.Build, optimize: Mode, target: CrossTarget, comptime source: []const []const u8) void {
pub fn buildExample(b: *std.Build, optimize: Mode, target: ResolvedTarget, module: *Module, comptime source: []const []const u8) void {
inline for (source) |s| {
const exe = b.addExecutable(.{
.name = s,
Expand All @@ -116,9 +118,7 @@ pub fn buildExample(b: *std.Build, optimize: Mode, target: CrossTarget, comptime
.optimize = optimize,
});

const pkg_prettytable = b.createModule(.{ .source_file = FileSource{ .path = "src/lib.zig" } });

exe.addModule("prettytable", pkg_prettytable);
exe.root_module.addImport("prettytable", module);

// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
Expand Down

0 comments on commit 1cdfca7

Please sign in to comment.