Skip to content

Commit db3660b

Browse files
committed
Don't gen files per GOOS+GOARCH, but only GOARCH
1 parent fdbb5fe commit db3660b

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

genassets.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// +build ignore
22

33
// This is run during go generate and embeds ssh-agent-pipe into the ssh-agent-inject binary.
4-
// * Compiles the ssh-agent-pipe binary for all platforms.
4+
// * Compiles the ssh-agent-pipe binary for all target platforms (GOOS=linux, different GOARCHs).
55
// * Creates a .tar.gz with that binary having executable permissions set.
6-
// * Stores that .tar.gz files in the assets/ folder as Go source files targeting the respective host platform.
6+
// * Stores that .tar.gz files in the assets/ folder as Go source files targeting the respective GOARCH.
77

88
package main
99

@@ -31,19 +31,17 @@ const AgentArchive = {{.agent|quote}}
3131
func main() {
3232
os.RemoveAll("assets")
3333
os.MkdirAll("assets", 0700)
34-
platforms := map[string][]string{
35-
"amd64": {"darwin", "linux", "windows"},
36-
"arm": {"linux"},
37-
"arm64": {"linux"},
34+
archs := []string{
35+
"amd64",
36+
"arm",
37+
"arm64",
3838
}
39-
for arch, hosts := range platforms {
39+
for _, arch := range archs {
4040
archive, err := buildAgentArchive(arch)
4141
if err != nil {
4242
log.Fatalln("Failed compiling ssh-agent-pipe", err)
4343
}
44-
for _, host := range hosts {
45-
genPlatformAssets(arch, host, archive)
46-
}
44+
genPlatformAssets(arch, archive)
4745
}
4846
}
4947

@@ -81,13 +79,14 @@ func buildAgentArchive(arch string) ([]byte, error) {
8179
return buffer.Bytes(), nil
8280
}
8381

84-
func genPlatformAssets(arch string, hostOS string, archive []byte) {
85-
config := map[string]string{
86-
"agent": string(archive),
87-
}
88-
file, err := os.Create(fmt.Sprintf("assets/assets_%s_%s.go", hostOS, arch))
82+
func genPlatformAssets(arch string, archive []byte) {
83+
file, err := os.Create(fmt.Sprintf("assets/assets_%s.go", arch))
84+
defer file.Close()
8985
if err != nil {
9086
log.Fatalln("Failed writing assets", err)
9187
}
88+
config := map[string]string{
89+
"agent": string(archive),
90+
}
9291
assetsTemplate.Execute(file, config)
9392
}

0 commit comments

Comments
 (0)