Changes
7 changed files (+142/-47)
-
-
@@ -39,6 +39,8 @@ const dep = b.dependency("plac_core", .{.target = target, .optimize = optimize, .freelog = freelog, .@"extension-id" = @as([]const u8, "jp.pocka.plac.cli"), .@"extension-name" = @as([]const u8, "Plac CLI"), }); break :core dep.module("core");
-
-
-
@@ -22,31 +22,29 @@ //! https://ziglang.org/learn/build-system/const std = @import("std"); const RoonExtension = struct { id: []const u8, name: []const u8, version: []const u8, }; const ModuleOptions = struct { freelog: bool, extension: RoonExtension, }; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const freelog = b.option(bool, "freelog", "Enable logging memory releases") orelse false; const sood = sood: { const dep = b.dependency("sood", .{}); break :sood dep.module("sood"); }; const moo = moo: { const dep = b.dependency("libmoo", .{}); break :moo dep.module("moo"); }; const websocket = websocket: { const dep = b.dependency("websocket", .{}); break :websocket dep.module("websocket"); const opts = ModuleOptions{ .freelog = b.option(bool, "freelog", "Enable logging memory releases") orelse false, .extension = .{ .id = b.option([]const u8, "extension-id", "Roon extension ID") orelse "jp.pocka.plac", .name = b.option([]const u8, "extension-name", "Roon extension name") orelse "Plac", .version = b.option([]const u8, "extension-version", "Roon extension version") orelse "0.0.0-dev", }, }; const options = b.addOptions(); options.addOption(bool, "freelog", freelog); // Zig module {
-
@@ -54,11 +52,7 @@ const mod = b.addModule("core", .{.root_source_file = b.path("src/main.zig"), }); mod.addImport("sood", sood); mod.addImport("moo", moo); mod.addImport("websocket", websocket); mod.addOptions("config", options); setupModule(b, mod, opts); } // Test
-
@@ -89,15 +83,11 @@ .linkage = linkage,.root_module = b.createModule(.{ .root_source_file = b.path("src/main.glib.zig"), .target = target, // FIXME: Debug build on macOS crashes on WebSocket client creation for some reason. .optimize = if (optimize == .Debug and target.result.os.tag.isDarwin()) .ReleaseSafe else optimize, .optimize = optimize, }), }); lib.root_module.addImport("sood", sood); lib.root_module.addImport("moo", moo); lib.root_module.addImport("websocket", websocket); lib.root_module.addOptions("config", options); setupModule(b, lib.root_module, opts); lib.linkLibC(); lib.linkSystemLibrary2("glib-2.0", .{ .preferred_link_mode = .dynamic });
-
@@ -117,9 +107,6 @@// XCFramework // https://mitchellh.com/writing/zig-and-swiftui if (target.result.os.tag.isDarwin()) { // FIXME: Debug build on macOS crashes on WebSocket client creation for some reason. const o = if (optimize == .Debug and target.result.os.tag.isDarwin()) .ReleaseSafe else optimize; const arm = b.addLibrary(.{ .name = "plac_apple_arm", .linkage = .static,
-
@@ -129,7 +116,7 @@ .target = b.resolveTargetQuery(.{.os_tag = .macos, .cpu_arch = .aarch64, }), .optimize = o, .optimize = optimize, }), });
-
@@ -146,7 +133,7 @@ .target = b.resolveTargetQuery(.{.os_tag = .macos, .cpu_arch = .x86_64, }), .optimize = o, .optimize = optimize, }), });
-
@@ -157,10 +144,7 @@ // Without bundling those, XCode is unable to resolve symbols.compile.bundle_compiler_rt = true; compile.bundle_ubsan_rt = true; compile.root_module.addImport("sood", sood); compile.root_module.addImport("moo", moo); compile.root_module.addImport("websocket", websocket); compile.root_module.addOptions("config", options); setupModule(b, compile.root_module, opts); } const universal_lib = universal: {
-
@@ -192,6 +176,8 @@ xcodebuild.addArg("-output");break :xcframework xcodebuild.addOutputDirectoryArg("PlacCore.xcframework"); }; b.addNamedLazyPath("xcframeworks", xcframework); const step = b.step("apple", "Build xcframework file for Apple platforms"); step.dependOn(&b.addInstallDirectory(.{ .source_dir = xcframework,
-
@@ -202,3 +188,33 @@b.default_step.dependOn(step); } } fn setupModule(b: *std.Build, mod: *std.Build.Module, opts: ModuleOptions) void { const sood = sood: { const dep = b.dependency("sood", .{}); break :sood dep.module("sood"); }; const moo = moo: { const dep = b.dependency("libmoo", .{}); break :moo dep.module("moo"); }; const websocket = websocket: { const dep = b.dependency("websocket", .{}); break :websocket dep.module("websocket"); }; mod.addImport("sood", sood); mod.addImport("moo", moo); mod.addImport("websocket", websocket); const options = b.addOptions(); options.addOption(bool, "freelog", opts.freelog); options.addOption(RoonExtension, "extension", opts.extension); mod.addOptions("config", options); }
-
-
-
@@ -14,6 +14,8 @@ // limitations under the License.// // SPDX-License-Identifier: Apache-2.0 const config = @import("config"); const Extension = @import("./services/registry.zig").Extension; const BrowseService = @import("./services/BrowseService.zig"); const ImageService = @import("./services/ImageService.zig");
-
@@ -21,9 +23,9 @@ const PingService = @import("./services/PingService.zig");const TransportService = @import("./services/TransportService.zig"); pub const extension = Extension{ .id = "jp.pocka.plac", .display_name = "Plac", .version = "0.0.0-dev", .id = config.extension.id, .display_name = config.extension.name, .version = config.extension.version, .publisher = "Shota FUJI", .email = "pockawoooh@gmail.com", .required_services = &.{ TransportService.id, BrowseService.id, ImageService.id },
-
-
-
@@ -42,6 +42,8 @@ const dep = b.dependency("core", .{.target = target, .optimize = optimize, .freelog = freelog, .@"extension-id" = @as([]const u8, "jp.pocka.plac.gtk-adwaita"), .@"extension-name" = @as([]const u8, "Plac GTK"), }); break :core dep.artifact("plac_glib");
-
-
macos/build.zig (new)
-
@@ -0,0 +1,43 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 const std = @import("std"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.option(std.builtin.OptimizeMode, "optimize", "Optimization mode") orelse .ReleaseSafe; const freelog = b.option(bool, "freelog", "Enable logging memory releases") orelse false; // FIXME: Debug build for macOS crashes on WebSocket client creation for some reason. if (optimize == .Debug) { std.log.err("Debug build is unavailable as third-party library triggers runtime panic in that build mode", .{}); return error.BrokenOptimizeMode; } const core = b.dependency("core", .{ .target = target, .optimize = optimize, .freelog = freelog, .@"extension-id" = @as([]const u8, "jp.pocka.plac.macos"), .@"extension-name" = @as([]const u8, "Plac macOS"), }); b.installDirectory(.{ .source_dir = core.namedLazyPath("xcframeworks"), .install_dir = .{ .custom = "xcframeworks" }, .install_subdir = "PlacCore.xcframework", }); }
-
-
macos/build.zig.zon (new)
-
@@ -0,0 +1,30 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 .{ .name = .plac_macos, .version = "0.0.0", .fingerprint = 0x7793d22cd47816ab, .minimum_zig_version = "0.14.0", .dependencies = .{ .core = .{ .path = "../core", }, }, .paths = .{ "build.zig", "build.zig.zon", }, }
-
-
-
@@ -7,7 +7,7 @@ objectVersion = 77;objects = { /* Begin PBXBuildFile section */ C3490F972DB36DC40030476A /* PlacCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3490F962DB36DC40030476A /* PlacCore.xcframework */; }; C328BE522E497E7A006A8C07 /* PlacCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C328BE512E497E7A006A8C07 /* PlacCore.xcframework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */
-
@@ -28,7 +28,7 @@ };/* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ C3490F962DB36DC40030476A /* PlacCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = PlacCore.xcframework; path = "../core/zig-out/xcframeworks/PlacCore.xcframework"; sourceTree = "<group>"; }; C328BE512E497E7A006A8C07 /* PlacCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = PlacCore.xcframework; path = "zig-out/xcframeworks/PlacCore.xcframework"; sourceTree = "<group>"; }; C3EABC712DB1170400F786D6 /* plac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = plac.app; sourceTree = BUILT_PRODUCTS_DIR; }; C3EABC7F2DB1170700F786D6 /* placTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = placTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C3EABC892DB1170700F786D6 /* placUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = placUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
-
@@ -57,7 +57,7 @@ C3EABC6E2DB1170400F786D6 /* Frameworks */ = {isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( C3490F972DB36DC40030476A /* PlacCore.xcframework in Frameworks */, C328BE522E497E7A006A8C07 /* PlacCore.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; };
-
@@ -81,7 +81,7 @@ /* Begin PBXGroup section */C3490F952DB36DC30030476A /* Frameworks */ = { isa = PBXGroup; children = ( C3490F962DB36DC40030476A /* PlacCore.xcframework */, C328BE512E497E7A006A8C07 /* PlacCore.xcframework */, ); name = Frameworks; sourceTree = "<group>";
-