-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.go
78 lines (73 loc) · 1.66 KB
/
builder.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//go:build generate
// +build generate
package main
import (
"runtime"
"strconv"
"strings"
"github.com/josephspurrier/goversioninfo"
)
func main() {
major, minor, patch, build := splitVersion(Version)
fileVersion := goversioninfo.FileVersion{
Major: major,
Minor: minor,
Patch: patch,
Build: build,
}
vi := goversioninfo.VersionInfo{
IconPath: "icon.ico",
ManifestPath: "cadscan.manifest",
FixedFileInfo: goversioninfo.FixedFileInfo{
FileVersion: fileVersion,
ProductVersion: fileVersion,
FileFlagsMask: "3f",
FileFlags: "00",
FileOS: "040004",
FileType: "01",
FileSubType: "00",
},
StringFileInfo: goversioninfo.StringFileInfo{
CompanyName: "SCJ Alliance",
FileDescription: "CAD File Scanner",
FileVersion: Version,
OriginalFilename: "cadscan.exe",
ProductName: "CAD File Scanner",
ProductVersion: Version,
},
VarFileInfo: goversioninfo.VarFileInfo{
Translation: goversioninfo.Translation{
LangID: goversioninfo.LngUSEnglish,
CharsetID: goversioninfo.CsUnicode,
},
},
}
vi.Build()
vi.Walk()
vi.WriteSyso("cadscan.syso", runtime.GOARCH)
}
func splitVersion(version string) (major, minor, patch, build int) {
parts := strings.Split(Version, ".")
switch len(parts) {
case 4:
if val, err := strconv.Atoi(parts[3]); err == nil {
build = val
}
fallthrough
case 3:
if val, err := strconv.Atoi(parts[2]); err == nil {
patch = val
}
fallthrough
case 2:
if val, err := strconv.Atoi(parts[1]); err == nil {
minor = val
}
fallthrough
case 1:
if val, err := strconv.Atoi(parts[0]); err == nil {
major = val
}
}
return
}