From 66602d98bc553de1e59533d639d50682eadcee96 Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Sat, 17 Aug 2024 16:20:53 -0600 Subject: [PATCH] Simplify the directory structure --- appkit_manual.zig => app_kit_manual.zig | 14 +++++----- avf_audio_manual.zig | 6 ++-- core_midi_manual.zig | 6 ++-- mtl_manual.zig => metal_manual.zig | 6 ++-- src/{appkit/appkit.zig => app_kit.zig} | 14 +++++----- src/{avf_audio/avaudio.zig => avf_audio.zig} | 6 ++-- .../cf.zig => core_foundation.zig} | 0 .../cg.zig => core_graphics.zig} | 0 src/{core_midi/coremidi.zig => core_midi.zig} | 6 ++-- src/{foundation/ns.zig => foundation.zig} | 2 +- src/main.zig | 18 ++++++------ src/{metal/mtl.zig => metal.zig} | 6 ++-- src/{quartz_core/ca.zig => quartz_core.zig} | 8 +++--- update.sh | 28 ++++++++----------- 14 files changed, 59 insertions(+), 61 deletions(-) rename appkit_manual.zig => app_kit_manual.zig (85%) rename mtl_manual.zig => metal_manual.zig (98%) rename src/{appkit/appkit.zig => app_kit.zig} (99%) rename src/{avf_audio/avaudio.zig => avf_audio.zig} (99%) rename src/{core_foundation/cf.zig => core_foundation.zig} (100%) rename src/{core_graphics/cg.zig => core_graphics.zig} (100%) rename src/{core_midi/coremidi.zig => core_midi.zig} (51%) rename src/{foundation/ns.zig => foundation.zig} (99%) rename src/{metal/mtl.zig => metal.zig} (99%) rename src/{quartz_core/ca.zig => quartz_core.zig} (98%) diff --git a/appkit_manual.zig b/app_kit_manual.zig similarity index 85% rename from appkit_manual.zig rename to app_kit_manual.zig index a3a47a6c..0be95ed8 100644 --- a/appkit_manual.zig +++ b/app_kit_manual.zig @@ -1,12 +1,12 @@ -const c = @import("../c.zig"); -const ca = @import("../quartz_core/ca.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); -const cg = @import("../core_graphics/cg.zig"); -const objc = @import("../objc.zig"); +const c = @import("c.zig"); +const ca = @import("quartz_core.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); +const cg = @import("core_graphics.zig"); +const objc = @import("objc.zig"); pub const applicationMain = NSApplicationMain; -extern fn NSApplicationMain(argc: c_int, argv: **c_char) c_int; +extern fn NSApplicationMain(argc: c_int, argv: [*]*c_char) c_int; // ------------------------------------------------------------------------------------------------ // Shared diff --git a/avf_audio_manual.zig b/avf_audio_manual.zig index ab4c74df..1b3696c5 100644 --- a/avf_audio_manual.zig +++ b/avf_audio_manual.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Types diff --git a/core_midi_manual.zig b/core_midi_manual.zig index 4dc42b57..25b7a85f 100644 --- a/core_midi_manual.zig +++ b/core_midi_manual.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Types diff --git a/mtl_manual.zig b/metal_manual.zig similarity index 98% rename from mtl_manual.zig rename to metal_manual.zig index baa92379..a26bc71d 100644 --- a/mtl_manual.zig +++ b/metal_manual.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Opaque types diff --git a/src/appkit/appkit.zig b/src/app_kit.zig similarity index 99% rename from src/appkit/appkit.zig rename to src/app_kit.zig index 06ef5aef..694176a0 100644 --- a/src/appkit/appkit.zig +++ b/src/app_kit.zig @@ -1,12 +1,12 @@ -const c = @import("../c.zig"); -const ca = @import("../quartz_core/ca.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); -const cg = @import("../core_graphics/cg.zig"); -const objc = @import("../objc.zig"); +const c = @import("c.zig"); +const ca = @import("quartz_core.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); +const cg = @import("core_graphics.zig"); +const objc = @import("objc.zig"); pub const applicationMain = NSApplicationMain; -extern fn NSApplicationMain(argc: c_int, argv: **c_char) c_int; +extern fn NSApplicationMain(argc: c_int, argv: [*]*c_char) c_int; // ------------------------------------------------------------------------------------------------ // Shared diff --git a/src/avf_audio/avaudio.zig b/src/avf_audio.zig similarity index 99% rename from src/avf_audio/avaudio.zig rename to src/avf_audio.zig index 15311f6d..a4194e61 100644 --- a/src/avf_audio/avaudio.zig +++ b/src/avf_audio.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Types diff --git a/src/core_foundation/cf.zig b/src/core_foundation.zig similarity index 100% rename from src/core_foundation/cf.zig rename to src/core_foundation.zig diff --git a/src/core_graphics/cg.zig b/src/core_graphics.zig similarity index 100% rename from src/core_graphics/cg.zig rename to src/core_graphics.zig diff --git a/src/core_midi/coremidi.zig b/src/core_midi.zig similarity index 51% rename from src/core_midi/coremidi.zig rename to src/core_midi.zig index 1c463b19..be120f4c 100644 --- a/src/core_midi/coremidi.zig +++ b/src/core_midi.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Types diff --git a/src/foundation/ns.zig b/src/foundation.zig similarity index 99% rename from src/foundation/ns.zig rename to src/foundation.zig index a2366efd..5c6c7502 100644 --- a/src/foundation/ns.zig +++ b/src/foundation.zig @@ -1,4 +1,4 @@ -const c = @import("../c.zig"); +const c = @import("c.zig"); // ------------------------------------------------------------------------------------------------ // Types diff --git a/src/main.zig b/src/main.zig index 061977f4..135f01d3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,32 +3,34 @@ const c = @import("c.zig"); pub const objc = @import("objc.zig"); pub const avf_audio = struct { - pub const avaudio = @import("avf_audio/avaudio.zig"); + pub const avaudio = @import("avf_audio.zig"); }; pub const core_foundation = struct { - pub const cf = @import("core_foundation/cf.zig"); + pub const cf = @import("core_foundation.zig"); }; pub const core_graphics = struct { - pub const cg = @import("core_graphics/cg.zig"); + pub const cg = @import("core_graphics.zig"); }; pub const foundation = struct { - pub const ns = @import("foundation/ns.zig"); + pub const ns = @import("foundation.zig"); }; pub const metal = struct { - pub const mtl = @import("metal/mtl.zig"); + pub const mtl = @import("metal.zig"); }; pub const quartz_core = struct { - pub const ca = @import("quartz_core/ca.zig"); + pub const ca = @import("quartz_core.zig"); }; -pub const appkit = struct { - pub const ns = @import("appkit/appkit.zig"); +pub const app_kit = struct { + pub const ns = @import("app_kit.zig"); }; +// TODO: delete `appkit` once Mach is using `app_kit`. +pub const appkit = app_kit; pub const mach = struct { pub const AppDelegate = opaque { diff --git a/src/metal/mtl.zig b/src/metal.zig similarity index 99% rename from src/metal/mtl.zig rename to src/metal.zig index 0b36e32d..23246c08 100644 --- a/src/metal/mtl.zig +++ b/src/metal.zig @@ -1,6 +1,6 @@ -const c = @import("../c.zig"); -const cf = @import("../core_foundation/cf.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cf = @import("core_foundation.zig"); +const ns = @import("foundation.zig"); // ------------------------------------------------------------------------------------------------ // Opaque types diff --git a/src/quartz_core/ca.zig b/src/quartz_core.zig similarity index 98% rename from src/quartz_core/ca.zig rename to src/quartz_core.zig index fccee1e5..c23e2ec3 100644 --- a/src/quartz_core/ca.zig +++ b/src/quartz_core.zig @@ -1,7 +1,7 @@ -const c = @import("../c.zig"); -const cg = @import("../core_graphics/cg.zig"); -const mtl = @import("../metal/mtl.zig"); -const ns = @import("../foundation/ns.zig"); +const c = @import("c.zig"); +const cg = @import("core_graphics.zig"); +const mtl = @import("metal.zig"); +const ns = @import("foundation.zig"); pub const Layer = opaque { pub fn class() *c.objc_class { diff --git a/update.sh b/update.sh index 06f037fe..71984542 100755 --- a/update.sh +++ b/update.sh @@ -22,46 +22,42 @@ git_clone_rev https://github.com/hexops/xcode-frameworks 3d1d9613c39bfc2ebfa2551 zig build -Doptimize=ReleaseFast -rm -rf src/metal/mtl.zig +rm -f src/metal.zig echo "Generating Metal" echo " #include " > headers.m clang headers.m -F ./xcode-frameworks/Frameworks -Xclang -ast-dump=json -fsyntax-only -Wno-deprecated-declarations > headers.json -mkdir -p src/metal/ -cat mtl_manual.zig > src/metal/mtl.zig -./zig-out/bin/generator --framework Metal >> src/metal/mtl.zig +cat metal_manual.zig > src/metal.zig +./zig-out/bin/generator --framework Metal >> src/metal.zig rm headers.json headers.m -rm -rf src/avf_audio/avaudio.zig +rm -f src/avf_audio.zig echo "Generating AVFAudio" cp avf_audio_headers.m headers.m clang headers.m -F ./xcode-frameworks/Frameworks -Xclang -ast-dump=json -fsyntax-only -Wno-deprecated-declarations > headers.json -mkdir -p src/avf_audio/ -cat avf_audio_manual.zig > src/avf_audio/avaudio.zig -./zig-out/bin/generator --framework AVFAudio >> src/avf_audio/avaudio.zig +cat avf_audio_manual.zig > src/avf_audio.zig +./zig-out/bin/generator --framework AVFAudio >> src/avf_audio.zig rm headers.json headers.m -rm -rf src/core_midi/coremidi.zig +rm -f src/core_midi.zig echo "Generating CoreMIDI" echo " #include " > headers.m clang headers.m -F ./xcode-frameworks/Frameworks -Xclang -ast-dump=json -fsyntax-only -Wno-deprecated-declarations > headers.json -mkdir -p src/core_midi/ -cat core_midi_manual.zig > src/core_midi/coremidi.zig -./zig-out/bin/generator --framework CoreMIDI >> src/core_midi/coremidi.zig +cat core_midi_manual.zig > src/core_midi.zig +./zig-out/bin/generator --framework CoreMIDI >> src/core_midi.zig rm headers.json headers.m -rm -rf src/appkit/appkit.zig +rm -f src/app_kit.zig echo "Generating AppKit" echo " #include " > headers.m clang headers.m -F ./xcode-frameworks/Frameworks -Xclang -ast-dump=json -fsyntax-only -Wno-deprecated-declarations -Wno-availability > headers.json -mkdir -p src/appkit/ -cat appkit_manual.zig > src/appkit/appkit.zig -./zig-out/bin/generator --framework AppKit >> src/appkit/appkit.zig +cat app_kit_manual.zig > src/app_kit.zig +./zig-out/bin/generator --framework AppKit >> src/app_kit.zig rm headers.json headers.m zig fmt .