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