| 
									
										
										
										
											2009-01-20 15:31:09 -05:00
										 |  |  | ! Copyright (C) 2007, 2009 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2008-12-15 01:01:06 -05:00
										 |  |  | USING: io io.files io.files.info.unix io.pathnames | 
					
						
							|  |  |  | io.directories io.directories.hierarchy kernel namespaces make | 
					
						
							|  |  |  | sequences system tools.deploy.backend tools.deploy.config | 
					
						
							| 
									
										
										
										
											2008-12-08 17:02:31 -05:00
										 |  |  | tools.deploy.config.editor assocs hashtables prettyprint | 
					
						
							| 
									
										
										
										
											2008-12-14 21:03:00 -05:00
										 |  |  | io.backend.unix cocoa io.encodings.utf8 io.backend | 
					
						
							| 
									
										
										
										
											2008-12-17 19:10:01 -05:00
										 |  |  | cocoa.application cocoa.classes cocoa.plists | 
					
						
							| 
									
										
										
										
											2008-12-08 17:02:31 -05:00
										 |  |  | combinators ;
 | 
					
						
							| 
									
										
										
										
											2007-11-05 00:45:02 -05:00
										 |  |  | IN: tools.deploy.macosx | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-05 00:45:02 -05:00
										 |  |  | : bundle-dir ( -- dir )
 | 
					
						
							|  |  |  |     vm parent-directory parent-directory ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-07 22:28:51 -05:00
										 |  |  | : copy-bundle-dir ( bundle-name dir -- )
 | 
					
						
							| 
									
										
										
										
											2008-12-22 06:41:01 -05:00
										 |  |  |     [ bundle-dir prepend-path swap ] keep
 | 
					
						
							| 
									
										
										
										
											2008-03-19 20:15:32 -04:00
										 |  |  |     "Contents" prepend-path append-path copy-tree ;
 | 
					
						
							| 
									
										
										
										
											2007-11-24 19:40:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-05 09:30:02 -04:00
										 |  |  | : app-plist ( executable bundle-name -- assoc )
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |     [ | 
					
						
							| 
									
										
										
										
											2008-04-05 09:30:02 -04:00
										 |  |  |         "6.0" "CFBundleInfoDictionaryVersion" set
 | 
					
						
							|  |  |  |         "APPL" "CFBundlePackageType" set
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         file-name "CFBundleName" set
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-05 09:30:02 -04:00
										 |  |  |         [ "CFBundleExecutable" set ] | 
					
						
							|  |  |  |         [ "org.factor." prepend "CFBundleIdentifier" set ] bi
 | 
					
						
							|  |  |  |     ] H{ } make-assoc ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-05 09:30:02 -04:00
										 |  |  | : create-app-plist ( executable bundle-name -- )
 | 
					
						
							| 
									
										
										
										
											2008-03-07 22:28:51 -05:00
										 |  |  |     [ app-plist ] keep
 | 
					
						
							| 
									
										
										
										
											2008-03-19 20:15:32 -04:00
										 |  |  |     "Contents/Info.plist" append-path | 
					
						
							| 
									
										
										
										
											2008-04-05 09:30:02 -04:00
										 |  |  |     write-plist ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-02 11:53:30 -04:00
										 |  |  | : copy-dll ( bundle-name -- )
 | 
					
						
							|  |  |  |     "Frameworks/libfactor.dylib" copy-bundle-dir ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : copy-nib ( bundle-name -- )
 | 
					
						
							|  |  |  |     deploy-ui? get [ | 
					
						
							|  |  |  |         "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir | 
					
						
							|  |  |  |     ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | : create-app-dir ( vocab bundle-name -- vm )
 | 
					
						
							| 
									
										
										
										
											2008-04-20 01:49:42 -04:00
										 |  |  |     [ | 
					
						
							| 
									
										
										
										
											2009-01-20 15:31:09 -05:00
										 |  |  |         nip
 | 
					
						
							|  |  |  |         [ copy-dll ] | 
					
						
							|  |  |  |         [ copy-nib ] | 
					
						
							|  |  |  |         [ "Contents/Resources" append-path make-directories ] | 
					
						
							|  |  |  |         tri
 | 
					
						
							| 
									
										
										
										
											2008-04-20 01:49:42 -04:00
										 |  |  |     ] | 
					
						
							|  |  |  |     [ create-app-plist ] | 
					
						
							| 
									
										
										
										
											2009-01-28 02:57:46 -05:00
										 |  |  |     [ "Contents/MacOS/" append-path copy-vm ] 2tri
 | 
					
						
							| 
									
										
										
										
											2008-12-15 01:01:06 -05:00
										 |  |  |     dup OCT: 755 set-file-permissions ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : deploy.app-image ( vocab bundle-name -- str )
 | 
					
						
							|  |  |  |     [ % "/Contents/Resources/" % % ".image" % ] "" make ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-05 00:45:02 -05:00
										 |  |  | : bundle-name ( -- string )
 | 
					
						
							|  |  |  |     deploy-name get ".app" append ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 16:39:16 -05:00
										 |  |  | : show-in-finder ( path -- )
 | 
					
						
							| 
									
										
										
										
											2008-04-20 01:49:42 -04:00
										 |  |  |     [ NSWorkspace -> sharedWorkspace ] | 
					
						
							|  |  |  |     [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
 | 
					
						
							| 
									
										
										
										
											2007-11-24 16:39:16 -05:00
										 |  |  |     -> selectFile:inFileViewerRootedAtPath: drop ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 20:46:37 -04:00
										 |  |  | M: macosx deploy* ( vocab -- )
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |     ".app deploy tool" assert.app | 
					
						
							| 
									
										
										
										
											2008-03-27 18:19:48 -04:00
										 |  |  |     "resource:" [ | 
					
						
							|  |  |  |         dup deploy-config [ | 
					
						
							|  |  |  |             bundle-name dup exists? [ delete-tree ] [ drop ] if
 | 
					
						
							|  |  |  |             [ bundle-name create-app-dir ] keep
 | 
					
						
							|  |  |  |             [ bundle-name deploy.app-image ] keep
 | 
					
						
							|  |  |  |             namespace make-deploy-image | 
					
						
							| 
									
										
										
										
											2008-04-20 01:49:42 -04:00
										 |  |  |             bundle-name show-in-finder | 
					
						
							| 
									
										
										
										
											2008-03-27 18:19:48 -04:00
										 |  |  |         ] bind | 
					
						
							|  |  |  |     ] with-directory ;
 |