mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-26 03:14:35 +00:00
zig : don't link examples/common.cpp for non-example (#814)
This commit is contained in:
parent
4953e9007f
commit
c1950c3431
@ -3,12 +3,14 @@ const std = @import("std");
|
|||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
const want_lto = b.option(bool, "lto", "Want -fLTO");
|
||||||
|
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "llama",
|
.name = "llama",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
lib.want_lto = want_lto;
|
||||||
lib.linkLibCpp();
|
lib.linkLibCpp();
|
||||||
lib.addIncludePath(".");
|
lib.addIncludePath(".");
|
||||||
lib.addIncludePath("examples");
|
lib.addIncludePath("examples");
|
||||||
@ -17,11 +19,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
}, &.{"-std=c11"});
|
}, &.{"-std=c11"});
|
||||||
lib.addCSourceFiles(&.{
|
lib.addCSourceFiles(&.{
|
||||||
"llama.cpp",
|
"llama.cpp",
|
||||||
"examples/common.cpp",
|
|
||||||
}, &.{"-std=c++11"});
|
}, &.{"-std=c++11"});
|
||||||
lib.install();
|
lib.install();
|
||||||
|
|
||||||
const build_args = .{ .b = b, .lib = lib, .target = target, .optimize = optimize };
|
const build_args = .{ .b = b, .lib = lib, .target = target, .optimize = optimize, .want_lto = want_lto };
|
||||||
|
|
||||||
const exe = build_example("main", build_args);
|
const exe = build_example("main", build_args);
|
||||||
_ = build_example("quantize", build_args);
|
_ = build_example("quantize", build_args);
|
||||||
_ = build_example("perplexity", build_args);
|
_ = build_example("perplexity", build_args);
|
||||||
@ -44,16 +46,19 @@ fn build_example(comptime name: []const u8, args: anytype) *std.build.LibExeObjS
|
|||||||
const lib = args.lib;
|
const lib = args.lib;
|
||||||
const target = args.target;
|
const target = args.target;
|
||||||
const optimize = args.optimize;
|
const optimize = args.optimize;
|
||||||
|
const want_lto = args.want_lto;
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = name,
|
.name = name,
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
exe.want_lto = want_lto;
|
||||||
exe.addIncludePath(".");
|
exe.addIncludePath(".");
|
||||||
exe.addIncludePath("examples");
|
exe.addIncludePath("examples");
|
||||||
exe.addCSourceFiles(&.{
|
exe.addCSourceFiles(&.{
|
||||||
std.fmt.comptimePrint("examples/{s}/{s}.cpp", .{name, name}),
|
std.fmt.comptimePrint("examples/{s}/{s}.cpp", .{name, name}),
|
||||||
|
"examples/common.cpp",
|
||||||
}, &.{"-std=c++11"});
|
}, &.{"-std=c++11"});
|
||||||
exe.linkLibrary(lib);
|
exe.linkLibrary(lib);
|
||||||
exe.install();
|
exe.install();
|
||||||
|
Loading…
Reference in New Issue
Block a user