]> Cypherpunks repositories - gostls13.git/commitdiff
goinstall: generate makefiles using exp/template
authorRob Pike <r@golang.org>
Tue, 26 Jul 2011 21:45:36 +0000 (14:45 -0700)
committerRob Pike <r@golang.org>
Tue, 26 Jul 2011 21:45:36 +0000 (14:45 -0700)
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4809052

src/cmd/goinstall/make.go

index 0fd9b02a84b81f785a0f40c1222058083f4379eb..9c1c7c4d79f1dbf023a2c2ce06ab86f807209882 100644 (file)
@@ -8,11 +8,11 @@ package main
 
 import (
        "bytes"
+       "exp/template"
        "go/build"
        "os"
        "path/filepath"
        "strings"
-       "template"
 )
 
 // domake builds the package in dir.
@@ -138,43 +138,38 @@ type makedata struct {
        Imports   []string // gc/ld import paths
 }
 
-var makefileTemplate = template.MustParse(`
+var makefileTemplate = template.New("Makefile").MustParse(`
 include $(GOROOT)/src/Make.inc
 
-TARG={Targ}
-TARGDIR={TargDir}
+TARG={{.Targ}}
+TARGDIR={{.TargDir}}
 
-{.section GoFiles}
+{{with .GoFiles}}
 GOFILES=\
-{.repeated section @}
-       {@}\
-{.end}
+{{range .}}    {{.}}\
+{{end}}
 
-{.end}
-{.section OFiles}
+{{end}}
+{{with .OFiles}}
 OFILES=\
-{.repeated section @}
-       {@}\
-{.end}
+{{range .}}    {{.}}\
+{{end}}
 
-{.end}
-{.section CgoFiles}
+{{end}}
+{{with .CgoFiles}}
 CGOFILES=\
-{.repeated section @}
-       {@}\
-{.end}
+{{range .}}    {{.}}\
+{{end}}
 
-{.end}
-{.section CgoOFiles}
+{{end}}
+{{with .CgoOFiles}}
 CGO_OFILES=\
-{.repeated section @}
-       {@}\
-{.end}
+{{range .}}    {{.}}\
+{{end}}
 
-{.end}
-GCIMPORTS={.repeated section Imports}-I "{@}" {.end}
-LDIMPORTS={.repeated section Imports}-L "{@}" {.end}
+{{end}}
+GCIMPORTS={{range .Imports}}-I "{{.}}" {{end}}
+LDIMPORTS={{range .Imports}}-L "{{.}}" {{end}}
 
-include $(GOROOT)/src/Make.{Type}
-`,
-       nil)
+include $(GOROOT)/src/Make.{{.Type}}
+`)