]> git.lizzy.rs Git - micro.git/blob - tools/info-plist.go
231901aaa4eaabe0cbfae0cb678bdb0826afcf08
[micro.git] / tools / info-plist.go
1 package main
2
3 import (
4         "fmt"
5         "io/ioutil"
6         "os"
7         "runtime"
8 )
9
10 func check(e error) {
11         if e != nil {
12                 panic(e)
13         }
14 }
15
16 func main() {
17         if runtime.GOOS == "darwin" {
18                 if len(os.Args) == 2 {
19                         rawInfoPlistString := `<?xml version="1.0" encoding="UTF-8"?>
20 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
21 <plist version="1.0">
22 <dict>
23     <key>CFBundleIdentifier</key>
24     <string>io.github.micro-editor</string>
25     <key>CFBundleName</key>
26     <string>micro</string>
27     <key>CFBundleInfoDictionaryVersion</key>
28     <string>6.0</string>
29     <key>CFBundlePackageType</key>
30     <string>APPL</string>
31     <key>CFBundleShortVersionString</key>
32     <string>` + os.Args[1] + `</string>
33 </dict>
34 </plist>
35 `
36                         infoPlistData := []byte(rawInfoPlistString)
37
38                         err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644)
39                         check(err)
40                         fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist")
41                 } else {
42                         panic("missing argument for version number!")
43                 }
44         }
45 }