1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Try to support both zig 0.11 and zig-master

This commit is contained in:
Frank Denis 2023-10-20 12:25:18 +02:00
parent 0e0e2c1640
commit cb4d121517

View File

@ -247,16 +247,18 @@ pub fn build(b: *std.build.Builder) !void {
const name = entry.basename;
if (mem.endsWith(u8, name, ".c")) {
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ src_path, entry.path });
lib.addCSourceFiles(.{
.files = &.{full_path},
.flags = &.{
const flags = &.{
"-fvisibility=hidden",
"-fno-strict-aliasing",
"-fno-strict-overflow",
"-fwrapv",
"-flax-vector-conversions",
},
});
};
if (@hasDecl(std.Build.Step.Compile, "AddCSourceFilesOptions")) {
lib.addCSourceFiles(.{ .files = &.{full_path}, .flags = flags });
} else {
lib.addCSourceFiles(&.{full_path}, flags);
}
} else if (mem.endsWith(u8, name, ".S")) {
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ src_path, entry.path });
lib.addAssemblyFile(.{ .path = full_path });
@ -294,8 +296,11 @@ pub fn build(b: *std.build.Builder) !void {
exe.addIncludePath(.{ .path = "src/libsodium/include" });
exe.addIncludePath(.{ .path = "test/quirks" });
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ test_path, entry.path });
if (@hasDecl(std.Build.Step.Compile, "AddCSourceFilesOptions")) {
exe.addCSourceFiles(.{ .files = &.{full_path} });
} else {
exe.addCSourceFiles(&.{full_path}, &.{});
}
if (enable_benchmarks) {
exe.defineCMacro("BENCHMARKS", "1");
var buf: [16]u8 = undefined;