fix: proper mac bundling with code signing

This commit is contained in:
2026-05-30 21:47:03 +02:00
parent 1d17b6e884
commit c1b7ceae6c
7 changed files with 119 additions and 15864 deletions

View File

@@ -174,6 +174,31 @@ defmodule BDS.MacBundleTest do
end
end
describe "MacBundle.macho_files/1" do
test "finds Mach-O binaries anywhere in the tree by magic number, ignoring other files" do
tmp = Path.join(System.tmp_dir!(), "bds-macho-#{System.unique_integer([:positive])}")
on_exit(fn -> File.rm_rf!(tmp) end)
# Little-endian 64-bit Mach-O magic (0xFEEDFACF) as stored on disk.
macho = <<0xCF, 0xFA, 0xED, 0xFE>>
beam = Path.join(tmp, "Contents/Resources/rel/erts-16/bin/beam.smp")
nif = Path.join(tmp, "Contents/Resources/rel/lib/foo-1.0/priv/foo.so")
dylib = Path.join(tmp, "Contents/Frameworks/libbar.dylib")
for path <- [beam, nif, dylib] do
File.mkdir_p!(Path.dirname(path))
File.write!(path, macho <> "machine code")
end
# Non-Mach-O files (plist, shell scripts) must be excluded.
File.write!(Path.join(tmp, "Contents/Info.plist"), ~s(<?xml version="1.0"?>))
File.write!(Path.join(tmp, "Contents/Resources/rel/erts-16/bin/erl"), "#!/bin/sh\n")
assert Enum.sort(MacBundle.macho_files(tmp)) == Enum.sort([beam, nif, dylib])
end
end
describe "MacBundle.assemble/1" do
setup do
tmp = Path.join(System.tmp_dir!(), "bds-macbundle-#{System.unique_integer([:positive])}")