Configured nimble to build/install the bundle binary

This commit is contained in:
Armando Rivera 2021-07-27 22:26:45 -04:00
parent e7be67686a
commit a0e6248333
3 changed files with 58 additions and 2 deletions

View File

@ -5,8 +5,9 @@ author = "Armando Rivera"
description = "macOS Cocoa GUI package"
license = "MIT"
srcDir = "src"
bin = @["bundle"]
# Dependencies
requires "nim >= 1.4.8"
requires "nim >= 1.4.8, plists"

55
src/bundle.nim Normal file
View File

@ -0,0 +1,55 @@
import json, os, plists, times
if paramCount() >= 1:
let fname = paramStr(1)
let dt = now()
let appAuthor = "Armando I. Rivera"
let appName = fname
let iconFile = "appIcon.icns"
let bundleIdentifier = "net.binarymagic." & appName
let appVersion = "0.1"
let appInfo = appVersion & " Created by " & appAuthor & " on " & dt.format("MM-dd-yyyy")
let appCopyRight = "Copyright" & dt.format(" yyyy ") & appAuthor & ". All rights reserved."
let appBundle = appName & ".app"
if fname.len > 0:
var pl = %*
{ "CFBundlePackageType" : "APPL",
"CFBundleInfoDictionaryVersion" : "6.0",
"CFBundleName" : appName,
"CFBundleExecutable" : appName,
"CFBundleIconFile" : iconFile ,
"CFBundleIdentifier" : bundleIdentifier ,
"CFBundleVersion" : appVersion ,
"CFBundleGetInfoString" : appInfo,
"CFBundleShortVersionString" : appVersion ,
"NSHumanReadableCopyright" : appCopyRight ,
"NSPrincipalClass" : "NSApplication" ,
"NSMainNibFile" : "MainMenu"
}
createDir(appBundle & "/Contents/MacOS")
createDir(appBundle & "/Contents/Resources")
createDir(appBundle & "/Contents/Frameworks")
if appName.fileExists:
appName.copyFileWithPermissions(appBundle & "/Contents/MacOS/" & appName)
if iconFile.fileExists:
iconFile.copyFileWithPermissions(appBundle & "/Contents/Resources/" & iconFile)
if "Credits.rtf".fileExists:
"Credits.rtf".copyFileWithPermissions(appBundle & "/Contents/Resources/Credits.rtf")
pl.writePlist(appBundle & "/Contents/Info.plist")
discard execShellCmd("touch " & appBundle)
discard execShellCmd("open " & appBundle)
else:
echo "Usage: bundle <file>"

View File

@ -7,6 +7,6 @@
import unittest
import nimcocoa
import cocoa
test "can add":
check add(5, 5) == 10