feat(app): App.set_icon, so a game without a bundle still has an icon
`ludic bundle` builds an AppIcon.icns and macOS reads it out of the .app, so a shipped game has an icon. `ludic build` produces a bare executable: no bundle, no CFBundleIconFile, and so no icon at all - macOS draws the generic green "exec" tile. That is the build a developer runs every day, which is why "the game has no icon" can be true for months while the bundle is perfect. It was here: the .app's icns validated against iconutil, the plist was right, the signature was right, and NSWorkspace rendered the artwork - and the binary beside it still had the exec tile. App.set_icon(path) takes the bytes through lp_pak_open, so a packed path and a loose one both work and this does not repeat Audio.load's trick of taking a filesystem path only. NSData copies them, so the buffer goes straight back. A missing or undecodable image leaves the existing icon alone rather than clearing it; a bundled app is unaffected; headless links no AppKit and compiles it away. Verified the Cocoa sequence against an ObjC twin doing the same message sends: before, a bare binary's applicationIconImage is the generic 128x128 tile; after, it is the 1024x1024 artwork. Backend change, so selfhost/ludicc.seed.ll is reseeded: the bootstrap fixpoint and the C-free rebuild from the seed both pass.
This commit is contained in:
parent
925d133466
commit
38b6b81cd7
7 changed files with 34345 additions and 34143 deletions
|
|
@ -1455,6 +1455,49 @@ out:
|
|||
@.s_setbg = private unnamed_addr constant [20 x i8] c"setBackgroundColor:\00"
|
||||
@.s_finlau = private unnamed_addr constant [16 x i8] c"finishLaunching\00"
|
||||
|
||||
@.s_setappicon = private unnamed_addr constant [25 x i8] c"setApplicationIconImage:\00"
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; app_set_icon(bytes, len) - the Dock tile, the Cmd-Tab switcher, the About box.
|
||||
;
|
||||
; A BUNDLED app gets this from CFBundleIconFile and needs nothing here. A plain
|
||||
; binary - which is what `ludic build` produces and what a developer runs all day
|
||||
; - has no bundle and therefore no icon at all: macOS draws the generic green
|
||||
; "exec" tile for it. That is not a cosmetic difference to someone who only ever
|
||||
; sees the game that way.
|
||||
;
|
||||
; Bytes, not a path, for the same reason splash_show takes bytes: the caller has
|
||||
; already resolved it through the pack. NSData copies them, so the caller may free
|
||||
; its buffer immediately. Anything unreadable leaves the existing icon alone.
|
||||
define void @app_set_icon(ptr %bytes, i32 %len) {
|
||||
entry:
|
||||
%nodata = icmp eq ptr %bytes, null
|
||||
%empty = icmp sle i32 %len, 0
|
||||
%skip = or i1 %nodata, %empty
|
||||
br i1 %skip, label %out, label %go
|
||||
go:
|
||||
%appcls = call ptr @objc_getClass(ptr @.c_app)
|
||||
%sel_sh = call ptr @sel_registerName(ptr @.s_shared)
|
||||
%nsapp = call ptr @objc_msgSend(ptr %appcls, ptr %sel_sh)
|
||||
%datacls = call ptr @objc_getClass(ptr @.c_data)
|
||||
%sel_dwb = call ptr @sel_registerName(ptr @.s_datawb)
|
||||
%lz = zext i32 %len to i64
|
||||
%data = call ptr (ptr, ptr, ptr, i64) @objc_msgSend(ptr %datacls, ptr %sel_dwb, ptr %bytes, i64 %lz)
|
||||
%imgcls = call ptr @objc_getClass(ptr @.c_image)
|
||||
%sel_alloc = call ptr @sel_registerName(ptr @.s_alloc)
|
||||
%i0 = call ptr @objc_msgSend(ptr %imgcls, ptr %sel_alloc)
|
||||
%sel_iwd = call ptr @sel_registerName(ptr @.s_initdat)
|
||||
%img = call ptr (ptr, ptr, ptr) @objc_msgSend(ptr %i0, ptr %sel_iwd, ptr %data)
|
||||
%noimg = icmp eq ptr %img, null
|
||||
br i1 %noimg, label %out, label %set
|
||||
set:
|
||||
%sel_seti = call ptr @sel_registerName(ptr @.s_setappicon)
|
||||
%r = call ptr (ptr, ptr, ptr) @objc_msgSend(ptr %nsapp, ptr %sel_seti, ptr %img)
|
||||
br label %out
|
||||
out:
|
||||
ret void
|
||||
}
|
||||
|
||||
@W_splash = internal global ptr null
|
||||
|
||||
define void @splash_show(ptr %bytes, i32 %len, i32 %bg) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue