]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.deploy.macosx: copy "icon.icns" from deployed vocab to app bundle as app icon
authorJoe Groff <arcata@gmail.com>
Mon, 15 Feb 2010 18:56:23 +0000 (10:56 -0800)
committerJoe Groff <arcata@gmail.com>
Mon, 15 Feb 2010 18:56:23 +0000 (10:56 -0800)
basis/tools/deploy/macosx/macosx.factor
basis/vocabs/metadata/metadata.factor

index bec3e78cbdeb6e61ab3049a14b37a102967d2572..8bd3749093404b0dadf39bf64969ca4abb000e81 100644 (file)
@@ -6,7 +6,7 @@ sequences system tools.deploy.backend tools.deploy.config
 tools.deploy.config.editor assocs hashtables prettyprint
 io.backend.unix cocoa io.encodings.utf8 io.backend
 cocoa.application cocoa.classes cocoa.plists
-combinators ;
+combinators vocabs.metadata vocabs.loader ;
 IN: tools.deploy.macosx
 
 : bundle-dir ( -- dir )
@@ -16,7 +16,7 @@ IN: tools.deploy.macosx
     [ bundle-dir prepend-path swap ] keep
     "Contents" prepend-path append-path copy-tree ;
 
-: app-plist ( executable bundle-name -- assoc )
+: app-plist ( icon? executable bundle-name -- assoc )
     [
         "6.0" "CFBundleInfoDictionaryVersion" set
         "APPL" "CFBundlePackageType" set
@@ -25,9 +25,11 @@ IN: tools.deploy.macosx
 
         [ "CFBundleExecutable" set ]
         [ "org.factor." prepend "CFBundleIdentifier" set ] bi
+
+        [ "Icon.icns" "CFBundleIconFile" set ] when
     ] H{ } make-assoc ;
 
-: create-app-plist ( executable bundle-name -- )
+: create-app-plist ( icon? executable bundle-name -- )
     [ app-plist ] keep
     "Contents/Info.plist" append-path
     write-plist ;
@@ -40,16 +42,24 @@ IN: tools.deploy.macosx
         "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
     ] [ drop ] if ;
 
+: copy-icns ( vocab bundle-name -- icon? )
+    swap dup vocab-mac-icon-path vocab-append-path dup exists?
+    [ swap "Contents/Resources/Icon.icns" append-path copy-file t ]
+    [ 2drop f ] if ;
+
 : create-app-dir ( vocab bundle-name -- vm )
-    [
-        nip {
-            [ copy-dll ]
-            [ copy-nib ]
-            [ "Contents/Resources" append-path make-directories ]
-        } cleave
-    ]
-    [ create-app-plist ]
-    [ "Contents/MacOS/" append-path copy-vm ] 2tri
+    {
+        [
+            nip {
+                [ copy-dll ]
+                [ copy-nib ]
+                [ "Contents/Resources" append-path make-directories ]
+            } cleave
+        ]
+        [ copy-icns ]
+        [ create-app-plist ]
+        [ "Contents/MacOS/" append-path copy-vm ]
+    } 2cleave
     dup OCT: 755 set-file-permissions ;
 
 : deploy.app-image ( vocab bundle-name -- str )
index 43c7641577cdf413574dfe6c7edaf2903abf9f70..04a0ea7546c0945e5f1f2ab89767b0cb02eecf40 100644 (file)
@@ -19,6 +19,12 @@ MEMO: vocab-file-contents ( vocab name -- seq )
         3append throw
     ] ?if ;
 
+: vocab-windows-icon-path ( vocab -- string )
+    vocab-dir "icon.ico" append-path ;
+
+: vocab-mac-icon-path ( vocab -- string )
+    vocab-dir "icon.icns" append-path ;
+
 : vocab-resources-path ( vocab -- string )
     vocab-dir "resources.txt" append-path ;