diff --git a/build.zig b/build.zig index f0acd3b..5c15b20 100644 --- a/build.zig +++ b/build.zig @@ -1,15 +1,26 @@ const std = @import("std"); -pub fn build(b: *std.Build) void { +pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const zboxer = b.dependency("zBoxer", .{ + .target = target, + .optimize = optimize, + }); + const zboxer_lib = zboxer.artifact("boxer"); + const exe = b.addExecutable(.{ .name = "FreshPresence", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); + if (target.getOsTag() == .macos) { + @import("xcode_frameworks").addPaths(b, exe); + } + exe.linkLibrary(zboxer_lib); + try exe.include_dirs.appendSlice(zboxer_lib.include_dirs.items); exe.linkLibC(); exe.addModule("rpc", b.dependency("zig-discord", .{}).module("rpc")); b.installArtifact(exe); diff --git a/build.zig.zon b/build.zig.zon index 0d09b49..cf4157d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -6,5 +6,13 @@ .url = "https://github.com/Beyley/zig-discord/archive/d5af305592f5712a0731554e2afd10afbea293cc.tar.gz", .hash = "1220af3afee845035705462f357f7ca70b964787a94ff3ae39a6ee779f3cca452880", }, + .zBoxer = .{ + .url = "https://github.com/Beyley/zBoxer/archive/8ba46a2fe50d658f1406c9681b8b931df24edf37.tar.gz", + .hash = "1220f0d56067829895dfbedbae59cc9579a484f7fee8f93a7db5a1d2eadcfcbf97d9", + }, + .xcode_frameworks = .{ + .url = "https://github.com/hexops/xcode-frameworks-pkg/archive/d486474a6af7fafd89e8314e0bf7eca4709f811b.tar.gz", + .hash = "1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb", + }, }, } diff --git a/src/main.zig b/src/main.zig index ebccbd1..edf129d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -12,6 +12,10 @@ const Config = struct { } }; +const c = @cImport({ + @cInclude("boxer/boxer.h"); +}); + /// Checks for an existing config, returns `true` if there is a config, `false` if not /// Writes a default config if missing pub fn getConfig(allocator: std.mem.Allocator) !Config { @@ -33,7 +37,14 @@ pub fn getConfig(allocator: std.mem.Allocator) !Config { try std.json.stringify(default_config, .{}, buffered_writer.writer()); try buffered_writer.flush(); - return error.ConfigWrittenPleaseUpdate; + if (c.boxerShow( + "Config created at " ++ config_path ++ "! Please check your config!", + "Update Config!", + c.kBoxerDefaultStyle, + c.kBoxerDefaultStyle, + ) == c.BoxerSelectionError) {} + + std.os.exit(0); } else { return err; }