aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/macros_with_error.py
blob: e82fb56d2c66e7bab1f35b8f8a8ac97f40669f3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys

import _common

import ymake


def onmacros_with_error(unit, *args):
    print >> sys.stderr, 'This macros will fail'
    raise Exception('Expected fail in MACROS_WITH_ERROR')


def onrestrict_path(unit, *args):
    if args:
        if 'MSG' in args:
            pos = args.index('MSG')
            paths, msg = args[:pos], args[pos + 1:]
            msg = ' '.join(msg)
        else:
            paths, msg = args, 'forbidden'
        if not _common.strip_roots(unit.path()).startswith(paths):
            error_msg = "Path '[[imp]]{}[[rst]]' is restricted - [[bad]]{}[[rst]]. Valid path prefixes are: [[unimp]]{}[[rst]]".format(unit.path(), msg, ', '.join(paths))
            ymake.report_configure_error(error_msg)

def onassert(unit, *args):
    val = unit.get(args[0])
    if val and val.lower() == "no":
        msg = ' '.join(args[1:])
        ymake.report_configure_error(msg)