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