1
0
mirror of https://github.com/golang/go synced 2024-11-05 11:46:12 -07:00

use multiline string literal in gobuild

R=r
DELTA=76  (1 added, 0 deleted, 75 changed)
OCL=30497
CL=30510
This commit is contained in:
Russ Cox 2009-06-18 16:32:26 -07:00
parent eba82f4391
commit 05240bb290

View File

@ -12,81 +12,82 @@ import (
"template";
)
var makefileTemplate =
"# DO NOT EDIT. Automatically generated by gobuild.\n"
"{Args|args} >Makefile\n"
"\n"
"D={.section Dir}/{@}{.end}\n"
"\n"
"include $(GOROOT)/src/Make.$(GOARCH)\n"
"AR=gopack\n"
"\n"
"default: packages\n"
"\n"
"clean:\n"
" rm -rf *.[$(OS)] *.a [$(OS)].out {ObjDir}\n"
"\n"
"test: packages\n"
" gotest\n"
"\n"
"coverage: packages\n"
" gotest\n"
" 6cov -g `pwd` | grep -v '_test\\.go:'\n"
"\n"
"%.$O: %.go\n"
" $(GC) -I{ObjDir} $*.go\n"
"\n"
"%.$O: %.c\n"
" $(CC) $*.c\n"
"\n"
"%.$O: %.s\n"
" $(AS) $*.s\n"
"\n"
"{.repeated section Phases}\n"
"O{Phase}=\\\n"
"{.repeated section ArCmds}\n"
"{.repeated section Files}\n"
" {Name|basename}.$O\\\n"
"{.end}\n"
"{.end}\n"
"\n"
"{.end}\n"
"\n"
"phases:{.repeated section Phases} a{Phase}{.end}\n"
"{.repeated section Packages}\n"
"{ObjDir}$D/{Name}.a: phases\n"
"{.end}\n"
"\n"
"{.repeated section Phases}\n"
"a{Phase}: $(O{Phase})\n"
"{.repeated section ArCmds}\n"
" $(AR) grc {ObjDir}$D/{.section Pkg}{Name}.a{.end}{.repeated section Files} {Name|basename}.$O{.end}\n"
"{.end}\n"
" rm -f $(O{Phase})\n"
"\n"
"{.end}\n"
"\n"
"newpkg: clean\n"
" mkdir -p {ObjDir}$D\n"
"{.repeated section Packages}\n"
" $(AR) grc {ObjDir}$D/{Name}.a\n"
"{.end}\n"
"\n"
"$(O1): newpkg\n"
"{.repeated section Phases}\n"
"$(O{Phase|+1}): a{Phase}\n"
"{.end}\n"
"\n"
"nuke: clean\n"
" rm -f{.repeated section Packages} $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a{.end}\n"
"\n"
"packages:{.repeated section Packages} {ObjDir}$D/{Name}.a{.end}\n"
"\n"
"install: packages\n"
" test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D\n"
"{.repeated section Packages}\n"
" cp {ObjDir}$D/{Name}.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a\n"
"{.end}\n"
var makefileTemplate = `
# DO NOT EDIT. Automatically generated by gobuild.
{Args|args} >Makefile
D={.section Dir}/{@}{.end}
include $(GOROOT)/src/Make.$(GOARCH)
AR=gopack
default: packages
clean:
rm -rf *.[$(OS)] *.a [$(OS)].out {ObjDir}
test: packages
gotest
coverage: packages
gotest
6cov -g $$(pwd) | grep -v '_test\.go:'
%.$O: %.go
$(GC) -I{ObjDir} $*.go
%.$O: %.c
$(CC) $*.c
%.$O: %.s
$(AS) $*.s
{.repeated section Phases}
O{Phase}=\
{.repeated section ArCmds}
{.repeated section Files}
{Name|basename}.$O\
{.end}
{.end}
{.end}
phases:{.repeated section Phases} a{Phase}{.end}
{.repeated section Packages}
{ObjDir}$D/{Name}.a: phases
{.end}
{.repeated section Phases}
a{Phase}: $(O{Phase})
{.repeated section ArCmds}
$(AR) grc {ObjDir}$D/{.section Pkg}{Name}.a{.end}{.repeated section Files} {Name|basename}.$O{.end}
{.end}
rm -f $(O{Phase})
{.end}
newpkg: clean
mkdir -p {ObjDir}$D
{.repeated section Packages}
$(AR) grc {ObjDir}$D/{Name}.a
{.end}
$(O1): newpkg
{.repeated section Phases}
$(O{Phase|+1}): a{Phase}
{.end}
nuke: clean
rm -f{.repeated section Packages} $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a{.end}
packages:{.repeated section Packages} {ObjDir}$D/{Name}.a{.end}
install: packages
test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
{.repeated section Packages}
cp {ObjDir}$D/{Name}.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a
{.end}
`
func argsFmt(w io.Writer, x interface{}, format string) {
args := x.([]string);