diff --git a/makefile b/makefile index 1105fe8..4b8905f 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/scripts/package_macos.go b/scripts/package_macos.go new file mode 100644 index 0000000..dd722b0 --- /dev/null +++ b/scripts/package_macos.go @@ -0,0 +1,66 @@ +package main + +import ( + "os" + "path" + "io/ioutil" +) + +var plist = ` + + + + CFBundleName + yarr + CFBundleDisplayName + yarr + CFBundleIdentifier + nkanaev.yarr + CFBundleVersion + 1.0 + CFBundlePackageType + APPL + CFBundleExecutable + yarr + + CFBundleIconFile + AppIcon + CFBundleIconName + AppIcon + LSApplicationCategoryType + public.app-category.news + + NSHighResolutionCapable + True + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleShortVersionString + 1.1 + + LSMinimumSystemVersion + 10.13 + LSUIElement + + NSHumanReadableCopyright + Copyright © 2020 nkanaev. All rights reserved. + + +` + +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) +}