Skip to content

Commit

Permalink
Added echo.go and updated waf script.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfe committed Mar 20, 2011
1 parent 737f914 commit 1e5194d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
10 changes: 10 additions & 0 deletions go/README
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ Installing waf
$ curl -O http://waf.googlecode.com/files/waf-1.6.3
$ mv waf-1.6.3 waf
$ ./waf --version

----------------------------

This directory:

$ ./waf configure

$ ./waf build (or just ./waf)

$ ./waf distclean
24 changes: 24 additions & 0 deletions go/echo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import ("os"
"flag")

var omitNewLine = flag.Bool("n", false, "Omit new line")

const (Space = " "; Newline = "\n")

func main() {
flag.Parse()

var s string = "";

for i := 0; i < flag.NArg(); i++ {
if i > 0 { s += Space }

s += flag.Arg(i);
}

if !*omitNewLine { s += Newline }

os.Stdout.WriteString(s)
}
12 changes: 9 additions & 3 deletions go/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ def configure(ctx):
ctx.env.GOC = "6g"
ctx.env.GOL = "6l"

def build(ctx):
def go(ctx, source, target):
go_compile = "${GOC} -o ${TGT} ${SRC}"
go_link = "${GOL} -o ${TGT} ${SRC}"

ctx(rule=go_compile, source="hello.go", target="hello.6")
ctx(rule=go_link, source="hello.6", target="hello")
object_file = target + ".6"

ctx(rule=go_compile, source=source, target=object_file)
ctx(rule=go_link, source=object_file, target=target)

def build(ctx):
go(ctx, "hello.go", "hello")
go(ctx, "echo.go", "echo")

0 comments on commit 1e5194d

Please sign in to comment.