factor/extra/tools/deploy/macosx/macosx.factor

85 lines
2.4 KiB
Factor
Raw Normal View History

2008-01-05 19:37:13 -05:00
! Copyright (C) 2007, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files io.launcher kernel namespaces sequences
2008-01-05 19:37:13 -05:00
system tools.deploy.backend tools.deploy.config assocs
hashtables prettyprint io.unix.backend cocoa
2008-01-10 22:05:43 -05:00
cocoa.application cocoa.classes cocoa.plists qualified ;
2007-11-24 19:40:43 -05:00
QUALIFIED: unix
IN: tools.deploy.macosx
2007-09-20 18:09:08 -04:00
: touch ( path -- )
2007-11-24 16:39:16 -05:00
{ "touch" } swap add run-process ;
2007-09-20 18:09:08 -04:00
: rm ( path -- )
2007-11-24 16:39:16 -05:00
{ "rm" "-rf" } swap add run-process ;
2007-11-05 01:08:19 -05:00
: bundle-dir ( -- dir )
vm parent-directory parent-directory ;
2007-09-20 18:09:08 -04:00
: copy-bundle-dir ( name dir -- )
bundle-dir over path+ -rot
>r "Contents" path+ r> path+ copy-directory ;
2007-09-20 18:09:08 -04:00
2007-11-24 19:40:43 -05:00
: chmod ( path perms -- )
unix:chmod io-error ;
2007-09-20 18:09:08 -04:00
: copy-vm ( executable bundle-name -- vm )
2007-11-05 01:08:19 -05:00
"Contents/MacOS/" path+ swap path+ vm swap
[ copy-file ] keep
2007-11-24 19:40:43 -05:00
[ OCT: 755 chmod ] keep ;
2007-09-20 18:09:08 -04:00
: copy-fonts ( name -- )
"fonts/" resource-path
swap "Contents/Resources/fonts/" path+ copy-directory ;
2007-09-20 18:09:08 -04:00
: print-app-plist ( executable bundle-name -- )
[
namespace {
{ "CFBundleInfoDictionaryVersion" "6.0" }
{ "CFBundlePackageType" "APPL" }
} update
file-name "CFBundleName" set
dup "CFBundleExecutable" set
"org.factor." swap append "CFBundleIdentifier" set
2008-01-10 22:05:43 -05:00
] H{ } make-assoc print-plist ;
2007-09-20 18:09:08 -04:00
: create-app-plist ( vocab bundle-name -- )
dup "Contents/Info.plist" path+ <file-writer>
[ print-app-plist ] with-stream ;
: create-app-dir ( vocab bundle-name -- vm )
dup "Frameworks" copy-bundle-dir
dup "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
dup copy-fonts
2dup create-app-plist copy-vm ;
: deploy.app-image ( vocab bundle-name -- str )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: bundle-name ( -- string )
deploy-name get ".app" append ;
TUPLE: macosx-deploy-implementation ;
T{ macosx-deploy-implementation } deploy-implementation set-global
2007-09-20 18:09:08 -04:00
2007-11-24 16:39:16 -05:00
: show-in-finder ( path -- )
NSWorkspace
-> sharedWorkspace
over <NSString> rot parent-directory <NSString>
-> selectFile:inFileViewerRootedAtPath: drop ;
2008-01-05 19:37:13 -05:00
M: macosx-deploy-implementation deploy* ( vocab -- )
stage1
2007-09-20 18:09:08 -04:00
".app deploy tool" assert.app
"." resource-path cd
dup deploy-config [
bundle-name rm
[ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep
2008-01-05 19:37:13 -05:00
namespace stage2
2007-11-24 16:39:16 -05:00
bundle-name show-in-finder
] bind ;