Skip to content

Commit 4b08df1

Browse files
committed
fix broken merge
1 parent e063bce commit 4b08df1

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

build.zig

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const Maker = struct {
1111
target: Target,
1212
optimize: Mode,
1313
enable_lto: bool,
14-
build_all: bool,
15-
install_libs: bool,
1614

1715
include_dirs: ArrayList([]const u8),
1816
cflags: ArrayList([]const u8),
@@ -54,8 +52,6 @@ const Maker = struct {
5452
.target = target,
5553
.optimize = builder.standardOptimizeOption(.{}),
5654
.enable_lto = false,
57-
.build_all = false,
58-
.install_libs = false,
5955
.include_dirs = ArrayList([]const u8).init(builder.allocator),
6056
.cflags = ArrayList([]const u8).init(builder.allocator),
6157
.cxxflags = ArrayList([]const u8).init(builder.allocator),
@@ -94,50 +90,42 @@ const Maker = struct {
9490
} else {
9591
o.addCSourceFiles(.{ .files = &.{src}, .flags = m.cxxflags.items });
9692
if (m.target.result.abi == .msvc) {
97-
o.addCSourceFiles(.{ .files = &.{src}, .flags = m.cxxflags.items });
98-
if (m.target.result.abi == .msvc) {
99-
o.linkLibC(); // need winsdk + crt
100-
} else {
101-
// linkLibCpp already add (libc++ + libunwind + libc)
102-
o.linkLibCpp();
103-
}
93+
o.linkLibC(); // need winsdk + crt
94+
} else {
95+
// linkLibCpp already add (libc++ + libunwind + libc)
96+
o.linkLibCpp();
10497
}
10598
}
10699
for (m.include_dirs.items) |i| o.addIncludePath(.{ .path = i });
107100
o.want_lto = m.enable_lto;
108-
if (m.install_libs) m.builder.installArtifact(o);
109101
return o;
110102
}
111103

112-
fn exe(m: *const Maker, name: []const u8, src: []const u8, deps: []const *Compile) ?*Compile {
113-
const opt = m.builder.option(bool, name, std.fmt.allocPrint(m.builder.allocator, "Build and install the {s} executable", .{name}) catch @panic("OOM")) orelse false;
114-
if (!opt and !m.build_all) return null;
115-
104+
fn exe(m: *const Maker, name: []const u8, src: []const u8, deps: []const *Compile) *Compile {
116105
const e = m.builder.addExecutable(.{ .name = name, .target = m.target, .optimize = m.optimize });
117106
e.addCSourceFiles(.{ .files = &.{src}, .flags = m.cxxflags.items });
118107
for (deps) |d| e.addObject(d);
119108
for (m.include_dirs.items) |i| e.addIncludePath(.{ .path = i });
120109

121110
// https://github.com/ziglang/zig/issues/15448
122111
if (m.target.result.abi == .msvc) {
123-
if (m.target.result.abi == .msvc) {
124-
e.linkLibC(); // need winsdk + crt
125-
} else {
126-
// linkLibCpp already add (libc++ + libunwind + libc)
127-
e.linkLibCpp();
128-
}
129-
m.builder.installArtifact(e);
130-
e.want_lto = m.enable_lto;
131-
132-
const run = m.builder.addRunArtifact(e);
133-
if (m.builder.args) |args| {
134-
run.addArgs(args);
135-
}
136-
const step = m.builder.step(name, std.fmt.allocPrint(m.builder.allocator, "Run the {s} example", .{name}) catch @panic("OOM"));
137-
step.dependOn(&run.step);
112+
e.linkLibC(); // need winsdk + crt
113+
} else {
114+
// linkLibCpp already add (libc++ + libunwind + libc)
115+
e.linkLibCpp();
116+
}
117+
m.builder.installArtifact(e);
118+
e.want_lto = m.enable_lto;
138119

139-
return e;
120+
const run = m.builder.addRunArtifact(e);
121+
run.step.dependOn(m.builder.getInstallStep());
122+
if (m.builder.args) |args| {
123+
run.addArgs(args);
140124
}
125+
const step = m.builder.step(name, m.builder.fmt("Run the {s} example", .{name}));
126+
step.dependOn(&run.step);
127+
128+
return e;
141129
}
142130
};
143131

@@ -195,6 +183,7 @@ pub fn build(b: *std.Build) !void {
195183

196184
const exes = [_]*Compile{
197185
make.exe("main", "examples/main/main.cpp", &.{ ggml, ggml_alloc, ggml_backend, ggml_quants, llama, common, buildinfo, sampling, console, grammar_parser, clip }),
186+
make.exe("simple", "examples/simple/simple.cpp", &.{ ggml, ggml_alloc, ggml_backend, ggml_quants, llama, common, buildinfo, sampling, console, grammar_parser, clip }),
198187
make.exe("quantize", "examples/quantize/quantize.cpp", &.{ ggml, ggml_alloc, ggml_backend, ggml_quants, llama, common, buildinfo }),
199188
make.exe("perplexity", "examples/perplexity/perplexity.cpp", &.{ ggml, ggml_alloc, ggml_backend, ggml_quants, llama, common, buildinfo }),
200189
make.exe("embedding", "examples/embedding/embedding.cpp", &.{ ggml, ggml_alloc, ggml_backend, ggml_quants, llama, common, buildinfo }),

0 commit comments

Comments
 (0)