From 05240bb290f25cd596d9c0c92ec8782f0359deae Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 18 Jun 2009 16:32:26 -0700 Subject: [PATCH] use multiline string literal in gobuild R=r DELTA=76 (1 added, 0 deleted, 75 changed) OCL=30497 CL=30510 --- src/cmd/gobuild/makefile.go | 151 ++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/src/cmd/gobuild/makefile.go b/src/cmd/gobuild/makefile.go index 2c71917630..5db633c17c 100644 --- a/src/cmd/gobuild/makefile.go +++ b/src/cmd/gobuild/makefile.go @@ -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);