fix: made the macos app smaller

This commit is contained in:
2026-07-18 10:20:54 +02:00
parent c77450d497
commit 593f1646a1
8 changed files with 166 additions and 32 deletions

View File

@@ -436,6 +436,8 @@ defmodule BDS.MacBundleTest do
File.write!(Path.join(release, "bin/bds"), "#!/bin/sh\necho fake release\n")
File.mkdir_p!(Path.join(release, "lib/wx-2.4/priv"))
File.write!(Path.join(release, "lib/wx-2.4/priv/wxe_driver.so"), "fake-nif")
File.mkdir_p!(Path.join(release, "releases/0.1.0"))
File.write!(Path.join(release, "releases/0.1.0/env.sh"), "# env")
icns = Path.join(tmp, "AppIcon.icns")
File.write!(icns, "fake-icns")
@@ -489,5 +491,28 @@ defmodule BDS.MacBundleTest do
assert File.exists?(Path.join(app, "Contents/Resources/rel/bin/bds"))
assert File.exists?(Path.join(app, "Contents/Resources/AppIcon.icns"))
end
test "refuses a half-assembled release and keeps the previous bundle", %{app: app} do
# A failed `mix release` leaves lib/ but no releases/<version>/env.sh.
tmp = Path.join(System.tmp_dir!(), "bds-macbundle-broken-#{System.unique_integer([:positive])}")
broken = Path.join(tmp, "rel")
File.mkdir_p!(Path.join(broken, "bin"))
File.mkdir_p!(Path.join(broken, "lib/wx-2.4/priv"))
on_exit(fn -> File.rm_rf!(tmp) end)
assert {:error, {:incomplete_release, message}} =
MacBundle.assemble(
release_dir: broken,
output_dir: Path.dirname(app),
icns_path: Path.join(tmp, "missing.icns"),
version: "0.1.0",
skip_dylibs: true,
skip_codesign: true
)
assert message =~ "mix release"
# the refused build must not have wiped the existing bundle
assert File.exists?(Path.join(app, "Contents/Resources/rel/bin/bds"))
end
end
end