factor/basis/tools/deploy/windows/windows.factor

43 lines
1.5 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators io.directories io.encodings.binary io.files
2015-07-19 20:53:09 -04:00
io.files.windows io.pathnames kernel locals namespaces splitting
sequences system tools.deploy.backend tools.deploy.config
tools.deploy.config.editor tools.deploy.windows.ico
vocabs.loader vocabs.metadata windows.shell32 windows.user32 ;
IN: tools.deploy.windows
CONSTANT: app-icon-resource-id "APPICON"
:: copy-vm ( executable bundle-name extension -- vm-path )
vm-path "." split1-last drop extension append
bundle-name executable ".exe" append append-path
[ copy-file ] keep ;
: create-exe-dir ( vocab bundle-name -- vm-path )
deploy-console? get ".com" ".exe" ? copy-vm ;
: open-in-explorer ( dir -- )
[ f "open" ] dip absolute-path normalize-separators
f f SW_SHOWNORMAL ShellExecute drop ;
: embed-ico ( vm-path vocab -- )
dup vocab-windows-icon-path vocab-append-path dup exists?
[ binary file-contents app-icon-resource-id embed-icon-resource ]
[ 2drop ] if ;
M: windows deploy*
deploy-directory get [
2008-11-09 18:27:51 -05:00
dup deploy-config [
deploy-name get
{
[ create-exe-dir dup ]
[ drop embed-ico ]
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
[ nip open-in-explorer ]
} 2cleave
] with-variables
] with-directory ;