Skip to content

Commit 324f340

Browse files
authored
zig : fix for updated c lib (#3259)
1 parent f56c418 commit 324f340

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

build.zig

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,20 @@ const Maker = struct {
3636
}
3737

3838
fn init(builder: *std.build.Builder) !Maker {
39-
const commit_hash = @embedFile(".git/refs/heads/master");
39+
// const commit_hash = @embedFile(".git/refs/heads/master");
40+
const target = builder.standardTargetOptions(.{});
4041
const config_header = builder.addConfigHeader(
4142
.{ .style = .blank, .include_path = "build-info.h" },
4243
.{
4344
.BUILD_NUMBER = 0,
44-
.BUILD_COMMIT = commit_hash[0 .. commit_hash.len - 1], // omit newline
45+
.BUILD_COMMIT = "12345", // omit newline
46+
.BUILD_COMPILER = "Zig 0.11.0",
47+
.BUILD_TARGET = try target.allocDescription(builder.allocator),
4548
},
4649
);
4750
var m = Maker{
4851
.builder = builder,
49-
.target = builder.standardTargetOptions(.{}),
52+
.target = target,
5053
.optimize = builder.standardOptimizeOption(.{}),
5154
.config_header = config_header,
5255
.enable_lto = false,
@@ -58,7 +61,7 @@ const Maker = struct {
5861
try m.addCFlag("-std=c11");
5962
try m.addCxxFlag("-std=c++11");
6063
try m.addProjectInclude(&.{});
61-
try m.addProjectInclude(&.{"examples"});
64+
try m.addProjectInclude(&.{"common"});
6265
return m;
6366
}
6467

@@ -71,6 +74,7 @@ const Maker = struct {
7174
o.addCSourceFiles(&.{src}, m.cxxflags.items);
7275
o.linkLibCpp();
7376
}
77+
o.addConfigHeader(m.config_header);
7478
for (m.include_dirs.items) |i| o.addIncludePath(.{ .path = i });
7579
o.want_lto = m.enable_lto;
7680
return o;
@@ -104,15 +108,15 @@ pub fn build(b: *std.build.Builder) !void {
104108
const ggml = make.obj("ggml", "ggml.c");
105109
const ggml_alloc = make.obj("ggml-alloc", "ggml-alloc.c");
106110
const llama = make.obj("llama", "llama.cpp");
107-
const common = make.obj("common", "examples/common.cpp");
108-
const console = make.obj("common", "examples/console.cpp");
109-
const grammar_parser = make.obj("grammar-parser", "examples/grammar-parser.cpp");
111+
const common = make.obj("common", "common/common.cpp");
112+
const console = make.obj("common", "common/console.cpp");
113+
const grammar_parser = make.obj("grammar-parser", "common/grammar-parser.cpp");
110114

111115
_ = make.exe("main", "examples/main/main.cpp", &.{ ggml, ggml_alloc, llama, common, console, grammar_parser });
112-
_ = make.exe("quantize", "examples/quantize/quantize.cpp", &.{ ggml, ggml_alloc, llama });
116+
_ = make.exe("quantize", "examples/quantize/quantize.cpp", &.{ ggml, ggml_alloc, llama, common });
113117
_ = make.exe("perplexity", "examples/perplexity/perplexity.cpp", &.{ ggml, ggml_alloc, llama, common });
114118
_ = make.exe("embedding", "examples/embedding/embedding.cpp", &.{ ggml, ggml_alloc, llama, common });
115-
_ = make.exe("train-text-from-scratch", "examples/train-text-from-scratch/train-text-from-scratch.cpp", &.{ ggml, ggml_alloc, llama });
119+
_ = make.exe("train-text-from-scratch", "examples/train-text-from-scratch/train-text-from-scratch.cpp", &.{ ggml, ggml_alloc, llama, common });
116120

117121
const server = make.exe("server", "examples/server/server.cpp", &.{ ggml, ggml_alloc, llama, common, grammar_parser });
118122
if (server.target.isWindows()) {

0 commit comments

Comments
 (0)