APPNAME = "gohello"
VERSION = "1.0"

top = "."
out = "build"

def configure(ctx):
  ctx.env.GOC = "6g"
  ctx.env.GOL = "6l"

def build(ctx):
  sources = ["echo.go", "hello.go", "slices.go"]

  for file in sources:
    # Files with ".go" extensions are automatically compiled and linked
    ctx(source=file)

    # Remove .bin extension from file
    binary = file.replace(".go", "")
    ctx(rule="mv ${SRC} ${TGT}", source=(binary + ".bin"), target=binary)

"""
Code to automatically compile and link files with ".go" as their extension.
"""

from waflib import TaskGen

TaskGen.declare_chain(
  name = "goc",
  rule = "${GOC} -o ${TGT} ${SRC}",
  ext_in = ".go",
  ext_out = ".6")

TaskGen.declare_chain(
  name = "gol",
  rule = "${GOL} -o ${TGT} ${SRC}",
  ext_in = ".6",
  ext_out = ".bin",
  reentrant = False)
