macros_with_error.py 897 B

1234567891011121314151617181920212223242526272829
  1. import sys
  2. import _common
  3. import ymake
  4. def onmacros_with_error(unit, *args):
  5. print >> sys.stderr, 'This macros will fail'
  6. raise Exception('Expected fail in MACROS_WITH_ERROR')
  7. def onrestrict_path(unit, *args):
  8. if args:
  9. if 'MSG' in args:
  10. pos = args.index('MSG')
  11. paths, msg = args[:pos], args[pos + 1:]
  12. msg = ' '.join(msg)
  13. else:
  14. paths, msg = args, 'forbidden'
  15. if not _common.strip_roots(unit.path()).startswith(paths):
  16. error_msg = "Path '[[imp]]{}[[rst]]' is restricted - [[bad]]{}[[rst]]. Valid path prefixes are: [[unimp]]{}[[rst]]".format(unit.path(), msg, ', '.join(paths))
  17. ymake.report_configure_error(error_msg)
  18. def onassert(unit, *args):
  19. val = unit.get(args[0])
  20. if val and val.lower() == "no":
  21. msg = ' '.join(args[1:])
  22. ymake.report_configure_error(msg)