# -*- python -*-
#
# Copyright (c) 2016 Stefan Seefeld
# All rights reserved.
#
# This file is part of Faber. It is made available under the
# Boost Software License, Version 1.0.
# (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)

# define some actions
compile = action('c++.compile', 'c++ $(option) -c -o $(<) $(>)')
link = action('c++.link', 'c++ -o $(<) $(>)')
run = action('run', './$(>)')

# python functions may be actions, too
def test(target, source, **kwds):
    print('performing {}...'.format(target[0].qname))
    # actions may also be called explicitly
    if run(target, source):
        print('...success.')
    else:
        print('...failed.')

# define rules to compile and link C++ code
obj = rule(compile, 'hello.o', 'hello.cpp')
bin = rule(link, 'hello', obj)
hello = rule(test, 'test', bin, attrs=notfile|always)

default = hello
