Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Include missing assembly files #26

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ pub fn build(b: *std.Build) void {
module.linkFramework("AppKit", .{});
if (target.result.cpu.arch == .x86_64) {
module.addAssemblyFile(b.path("MACHAppDelegate_x86_64_apple_macos12.s"));
module.addAssemblyFile(b.path("MACHWindowDelegate_x86_64_apple_macos12.s"));
} else {
module.addAssemblyFile(b.path("MACHAppDelegate_arm64_apple_macos12.s"));
module.addAssemblyFile(b.path("MACHWindowDelegate_arm64_apple_macos12.s"));
}
} else {
module.linkFramework("UIKit", .{});
Expand Down
3 changes: 3 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"MACHAppDelegate_arm64_apple_macos12.s",
"MACHAppDelegate_x86_64_apple_macos12.s",
"MACHAppDelegate.m",
"MACHWindowDelegate_arm64_apple_macos12.s",
"MACHWindowDelegate_x86_64_apple_macos12.s",
"MACHWindowDelegate.m",
"metal_manual.zig",
"registry.zig",
"update.sh",
Expand Down
28 changes: 28 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,31 @@ done

mv MACHAppDelegate_aarch64-macos.s MACHAppDelegate_arm64_apple_macos12.s
mv MACHAppDelegate_x86_64-macos.s MACHAppDelegate_x86_64_apple_macos12.s

for pair in \
'MACHWindowDelegate_aarch64-macos.s aarch64-macos.12.0' \
'MACHWindowDelegate_x86_64-macos.s x86_64-macos.12.0'
do
dst=${pair%% *}
target=${pair#* }

zig cc -c MACHWindowDelegate.m \
-target "$target" \
-S -Os -fomit-frame-pointer -fobjc-arc -fno-objc-exceptions \
-o "$dst" \
-iframework ./xcode-frameworks/Frameworks \
-isystem ./xcode-frameworks/include

cat "$dst" |
sed 's/\x01/\\x01/g' |
sed 's/ *; .*//g' | # Strip comments at the end of lines
sed 's/ *## .*//g' |
sed '/^ \.build_version .*/d' | # Strip OS-specific version info
sed '/^; .*/d' | # Strip whole-line comments
sed '/^## .*/d' > "$dst.tmp"

mv "$dst.tmp" "$dst"
done

mv MACHWindowDelegate_aarch64-macos.s MACHWindowDelegate_arm64_apple_macos12.s
mv MACHWindowDelegate_x86_64-macos.s MACHWindowDelegate_x86_64_apple_macos12.s
Loading