fix build.zig
This commit is contained in:
parent
43001ce077
commit
a7812d9c6e
1 changed files with 23 additions and 31 deletions
12
build.zig
12
build.zig
|
@ -5,12 +5,8 @@ const Compile = std.Build.Step.Compile;
|
|||
const ConfigHeader = std.Build.Step.ConfigHeader;
|
||||
const Mode = std.builtin.OptimizeMode;
|
||||
const Target = std.Build.ResolvedTarget;
|
||||
const Mode = std.builtin.OptimizeMode;
|
||||
const Target = std.Build.ResolvedTarget;
|
||||
|
||||
const Maker = struct {
|
||||
builder: *std.Build,
|
||||
target: Target,
|
||||
builder: *std.Build,
|
||||
target: Target,
|
||||
optimize: Mode,
|
||||
|
@ -39,11 +35,9 @@ const Maker = struct {
|
|||
try m.addCxxFlag(flag);
|
||||
}
|
||||
|
||||
fn init(builder: *std.Build) !Maker {
|
||||
fn init(builder: *std.Build) !Maker {
|
||||
const target = builder.standardTargetOptions(.{});
|
||||
const zig_version = @import("builtin").zig_version_string;
|
||||
const commit_hash = try std.ChildProcess.run(
|
||||
const commit_hash = try std.ChildProcess.run(
|
||||
.{ .allocator = builder.allocator, .argv = &.{ "git", "rev-parse", "HEAD" } },
|
||||
);
|
||||
|
@ -55,8 +49,6 @@ const Maker = struct {
|
|||
\\
|
||||
, .{ 0, commit_hash.stdout[0 .. commit_hash.stdout.len - 1], zig_version, try target.query.zigTriple(builder.allocator) }));
|
||||
|
||||
, .{ 0, commit_hash.stdout[0 .. commit_hash.stdout.len - 1], zig_version, try target.query.zigTriple(builder.allocator) }));
|
||||
|
||||
var m = Maker{
|
||||
.builder = builder,
|
||||
.target = target,
|
||||
|
@ -80,7 +72,6 @@ const Maker = struct {
|
|||
}
|
||||
try m.addFlag("-D_XOPEN_SOURCE=600");
|
||||
|
||||
|
||||
if (m.target.result.abi == .gnu) {
|
||||
try m.addFlag("-D_GNU_SOURCE");
|
||||
}
|
||||
|
@ -111,6 +102,7 @@ const Maker = struct {
|
|||
o.linkLibCpp();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (m.include_dirs.items) |i| o.addIncludePath(.{ .path = i });
|
||||
o.want_lto = m.enable_lto;
|
||||
if (m.install_libs) m.builder.installArtifact(o);
|
||||
|
@ -146,9 +138,9 @@ const Maker = struct {
|
|||
|
||||
return e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
pub fn build(b: *std.Build) !void {
|
||||
var make = try Maker.init(b);
|
||||
make.enable_lto = b.option(bool, "lto", "Enable LTO optimization, (default: false)") orelse false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue