2023-04-05 15:06:02 +00:00
|
|
|
const std = @import("std");
|
|
|
|
|
2023-06-25 05:45:44 +00:00
|
|
|
// Zig Version: 0.11.0-dev.3379+629f0d23b
|
2023-04-13 13:43:22 +00:00
|
|
|
pub fn build(b: *std.build.Builder) void {
|
2023-04-05 15:06:02 +00:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2023-06-25 05:45:44 +00:00
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const lib = b.addStaticLibrary(.{
|
|
|
|
.name = "llama",
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
lib.linkLibC();
|
2023-04-05 15:06:02 +00:00
|
|
|
lib.linkLibCpp();
|
|
|
|
lib.addIncludePath(".");
|
2023-06-25 05:45:44 +00:00
|
|
|
lib.addIncludePath("./examples");
|
2023-04-05 15:06:02 +00:00
|
|
|
lib.addCSourceFiles(&.{
|
|
|
|
"ggml.c",
|
|
|
|
}, &.{"-std=c11"});
|
|
|
|
lib.addCSourceFiles(&.{
|
|
|
|
"llama.cpp",
|
|
|
|
}, &.{"-std=c++11"});
|
2023-06-25 05:45:44 +00:00
|
|
|
b.installArtifact(lib);
|
|
|
|
|
|
|
|
const examples = .{
|
|
|
|
"main",
|
|
|
|
"baby-llama",
|
|
|
|
"embedding",
|
|
|
|
// "metal",
|
|
|
|
"perplexity",
|
|
|
|
"quantize",
|
|
|
|
"quantize-stats",
|
|
|
|
"save-load-state",
|
|
|
|
// "server",
|
|
|
|
"simple",
|
|
|
|
"train-text-from-scratch",
|
|
|
|
};
|
|
|
|
|
|
|
|
inline for (examples) |example_name| {
|
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = example_name,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
exe.addIncludePath(".");
|
|
|
|
exe.addIncludePath("./examples");
|
|
|
|
exe.addCSourceFiles(&.{
|
|
|
|
std.fmt.comptimePrint("examples/{s}/{s}.cpp", .{example_name, example_name}),
|
|
|
|
"examples/common.cpp",
|
|
|
|
}, &.{"-std=c++11"});
|
|
|
|
exe.linkLibrary(lib);
|
|
|
|
b.installArtifact(exe);
|
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
|
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
if (b.args) |args| run_cmd.addArgs(args);
|
|
|
|
const run_step = b.step("run_" ++ example_name, "Run the app");
|
|
|
|
run_step.dependOn(&run_cmd.step);
|
2023-04-05 15:06:02 +00:00
|
|
|
}
|
|
|
|
}
|