]> git.lizzy.rs Git - micro.git/blob - tools/info-plist.go
Fix cross compilation from macOS
[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 )
11
12 func check(e error) {
13         if e != nil {
14                 panic(e)
15         }
16 }
17
18 func main() {
19         if len(os.Args) == 3 {
20                 if os.Args[1] == "darwin" {
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[2] + `</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                 }
44         } else {
45                 panic("missing arguments")
46         }
47 }