create macos app

This commit is contained in:
Nazar Kanaev 2020-09-13 21:40:33 +01:00
parent 4884953b32
commit 2ecfef79d3
2 changed files with 67 additions and 0 deletions

View File

@ -13,6 +13,7 @@ build_macos: bundle
set GOARCH=amd64
mkdir -p _output/macos
go build -tags "sqlite_foreign_keys release macos" -ldflags="-s -w" -o _output/macos/yarr main.go
go run scripts/package_macos.go _output/macos
build_linux: bundle
set GOOS=linux

66
scripts/package_macos.go Normal file
View File

@ -0,0 +1,66 @@
package main
import (
"os"
"path"
"io/ioutil"
)
var plist = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>yarr</string>
<key>CFBundleDisplayName</key>
<string>yarr</string>
<key>CFBundleIdentifier</key>
<string>nkanaev.yarr</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>yarr</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.news</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 nkanaev. All rights reserved.</string>
</dict>
</plist>
`
func main() {
outdir := os.Args[1]
outfile := "yarr"
binDir := path.Join(outdir, "yarr.app", "Contents/MacOS")
resDir := path.Join(outdir, "yarr.app", "Contents/Resources")
plistPath := path.Join(outdir, "yarr.app", "Contents/Info.plist")
os.MkdirAll(binDir, 0700)
os.MkdirAll(resDir, 0700)
f, _ := ioutil.ReadFile(path.Join(outdir, outfile))
ioutil.WriteFile(path.Join(binDir, outfile), f, 0700)
ioutil.WriteFile(plistPath, []byte(plist), 0600)
}