build: fix build on macos

This commit is contained in:
CJ van den Berg 2024-02-28 21:01:11 +01:00
parent 9fe4bc0c1f
commit 3b80a36537
5 changed files with 34 additions and 13 deletions

View file

@ -8,6 +8,8 @@ const cppflags = [_][]const u8{
"-Wall", "-Wall",
"-Wextra", "-Wextra",
"-Werror", "-Werror",
"-Wpedantic",
"-Wno-deprecated-declarations",
"-Wno-unqualified-std-cast-call", "-Wno-unqualified-std-cast-call",
"-Wno-bitwise-instead-of-logical", //for notcurses "-Wno-bitwise-instead-of-logical", //for notcurses
"-fno-sanitize=undefined", "-fno-sanitize=undefined",
@ -24,12 +26,7 @@ pub fn build(b: *std.Build) void {
const options_mod = options.createModule(); const options_mod = options.createModule();
const target = b.standardTargetOptions(.{ const target = b.standardTargetOptions(.{});
.default_target = if (tracy_enabled)
CrossTarget.parse(.{ .arch_os_abi = "native-native-gnu" }) catch unreachable
else
CrossTarget.parse(.{ .arch_os_abi = "native-native-musl" }) catch unreachable,
});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const mode = .{ .target = target, .optimize = optimize }; const mode = .{ .target = target, .optimize = optimize };

View file

@ -4,7 +4,7 @@
.dependencies = .{ .dependencies = .{
.asio = .{ .asio = .{
.url = "https://github.com/kassane/asio/archive/5fc70d29f458f5b596a20bdf3d638294eef91478.tar.gz", .url = "https://github.com/kassane/asio/archive/cfec4608112abd44462afbad427d0f2ca3e30199.tar.gz",
.hash = "1220926d7e934fcb9e4e55f25e24d17613fbe9b145798581e0ae7ea3679b37f4e44d", .hash = "1220926d7e934fcb9e4e55f25e24d17613fbe9b145798581e0ae7ea3679b37f4e44d",
}, },
.tracy = .{ .tracy = .{

View file

@ -1,3 +1,5 @@
#ifndef __APPLE__
#include <csignal> #include <csignal>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
@ -100,3 +102,11 @@ extern "C" void install_jitdebugger() {
else else
install_backtrace(); install_backtrace();
} }
#else
extern "C" void install_debugger() {}
extern "C" void install_backtrace() {}
extern "C" void install_jitdebugger() {}
#endif

View file

@ -1,4 +1,5 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const c = @cImport({ const c = @cImport({
@cInclude("tests.h"); @cInclude("tests.h");
}); });
@ -17,8 +18,10 @@ test "debug" {
} }
test "endpoint_unx" { test "endpoint_unx" {
if (builtin.os.tag == .linux) {
try testcase("endpoint_unx"); try testcase("endpoint_unx");
} }
}
test "endpoint_tcp" { test "endpoint_tcp" {
try testcase("endpoint_tcp"); try testcase("endpoint_tcp");

17
zig
View file

@ -6,7 +6,17 @@ ARCH=$(uname -m)
BASEDIR="$(cd "$(dirname "$0")" && pwd)" BASEDIR="$(cd "$(dirname "$0")" && pwd)"
ZIGDIR=$BASEDIR/.cache/zig ZIGDIR=$BASEDIR/.cache/zig
VERSION=$(< build.zig.version) VERSION=$(< build.zig.version)
ZIGVER="zig-linux-$ARCH-$VERSION"
OS=$(uname)
if [ "$OS" == "Linux" ] ; then
OS=linux
elif [ "$OS" == "Darwin" ] ; then
OS=macos
fi
ZIGVER="zig-$OS-$ARCH-$VERSION"
ZIG=$ZIGDIR/$ZIGVER/zig ZIG=$ZIGDIR/$ZIGVER/zig
if [ "$1" == "update" ] ; then if [ "$1" == "update" ] ; then
@ -14,8 +24,10 @@ if [ "$1" == "update" ] ; then
NEWVERSION=$(< build.zig.version) NEWVERSION=$(< build.zig.version)
if [ "$VERSION" != "$NEWVERSION" ] ; then if [ "$VERSION" != "$NEWVERSION" ] ; then
echo zig version updated from $VERSION to $NEWVERSION
echo rebuilding to update cdb...
$0 cdb $0 cdb
exec $0 exit 0
fi fi
echo zig version $VERSION is up-to-date echo zig version $VERSION is up-to-date
exit 0 exit 0
@ -36,7 +48,6 @@ get_zig
if [ "$1" == "cdb" ] ; then if [ "$1" == "cdb" ] ; then
rm -rf zig-cache rm -rf zig-cache
rm -rf zig-bin
rm -rf .cache/cdb rm -rf .cache/cdb
$ZIG build $ZIG build