#! /usr/bin/env python # encoding: utf-8 # Thomas Nagy, 2016 # import os from waflib import TaskGen, Build, Utils @TaskGen.feature('ruler') @TaskGen.before('process_rule') def test(self): if not self.bld.is_install or self.bld.is_install == Build.UNINSTALL: while self.meths: # do not generate tasks: the target file may not be there self.meths.pop() return tg = self.bld.get_tgen_by_name(self.bring_in) tg.post() # let it create its installation task assert tg.install_task.outputs self.source = tg.install_task.outputs def configure(conf): tmpdir = conf.bldnode.make_node('tmpdir') def build(bld): bld.is_install = env.INSTALL bld.path.make_node('tmpfile').write('test') bld.env.PREFIX = tmpdir.abspath() bld.install_as('${PREFIX}/bin/foo', 'tmpfile', chmod=Utils.O755) bld.symlink_as('${PREFIX}/bin/bar', '../tmpfile') tsk = bld.install_files('${PREFIX}/bin', 'tmpfile', chmod=Utils.O755, name='cheese') bld(rule='ls -l ${SRC}', always=True, bring_in='cheese', features='ruler') env = conf.env.derive() env.INSTALL = Build.INSTALL conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env) assert tmpdir.exists() assert tmpdir.make_node('bin/foo').exists() assert tmpdir.make_node('bin/tmpfile').abspath() assert tmpdir.make_node('bin/foo').read() == tmpdir.make_node('bin/tmpfile').read() assert os.path.lexists(tmpdir.make_node('bin/bar').abspath()) assert os.readlink(tmpdir.make_node('bin/bar').abspath()) == '../tmpfile' env.INSTALL = Build.UNINSTALL conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env) assert not tmpdir.exists() assert not tmpdir.make_node('bin/foo').exists() assert not tmpdir.make_node('bin/tmpfile').exists() assert not os.path.lexists(tmpdir.make_node('bin/bar').abspath()) assert not tmpdir.exists()