-
-
Notifications
You must be signed in to change notification settings - Fork 141
/
resource.go
38 lines (32 loc) · 857 Bytes
/
resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//go:build ignore
// generates resource files.
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/koho/frpmgr/pkg/version"
)
var (
versionArray = strings.ReplaceAll(version.Number, ".", ",")
archMap = map[string]string{"amd64": "pe-x86-64", "386": "pe-i386"}
)
func main() {
rcFiles, err := filepath.Glob("cmd/*/*.rc")
if err != nil {
println(err.Error())
os.Exit(1)
}
for _, rc := range rcFiles {
for goArch, resArch := range archMap {
output := strings.TrimSuffix(rc, filepath.Ext(rc)) + fmt.Sprintf("_windows_%s.syso", goArch)
res, err := exec.Command("windres", "-DVERSION_ARRAY="+versionArray, "-DVERSION_STR="+version.Number,
"-i", rc, "-o", output, "-O", "coff", "-c", "65001", "-F", resArch).CombinedOutput()
if err != nil {
println(err.Error(), string(res))
}
}
}
}