#! /usr/bin/env python

top = '.'
out = 'out'

def configure(conf):
	pass

def build(bld):
	bld.package(name='blah.tar', version='1.0.1')
	bld.package(name='aha.tar', deps=['blah.tar'])

import Build
def package(*k, **kw):
	sub = k[1:]
	t = k[0](*sub, **kw)
	t.features = 'package'
Build.BuildContext.package = package

from TaskGen import feature, before
@feature('package')
@before('apply_core')
def make_package_tasks(self):
	tsk = self.create_task('pack')
	ins = []

	for x in getattr(self, 'deps', []):
		y = self.bld.name_to_obj(x, self.env)
		y.post()
		#  build order ..
		for t in y.tasks:
			tsk.set_run_after(t)
			ins.extend(t.outputs)

	tsk.set_inputs(ins)
	tsk.set_outputs(self.path.find_or_declare(self.name))

	tsk.env.VERSION = getattr(self, 'version', '')

import Task
cls = Task.simple_task_type('pack', 'date > ${TGT}', vars=['VERSION']) # for testing purposes
Task.update_outputs(cls)

