macros_with_error.py 928 B

1234567891011121314151617181920212223242526272829303132
  1. import sys
  2. import _common
  3. import ymake
  4. def onmacros_with_error(unit, *args):
  5. sys.stderr.write('This macros will fail\n')
  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(
  17. unit.path(), msg, ', '.join(paths)
  18. )
  19. ymake.report_configure_error(error_msg)
  20. def onassert(unit, *args):
  21. val = unit.get(args[0])
  22. if val and val.lower() == "no":
  23. msg = ' '.join(args[1:])
  24. ymake.report_configure_error(msg)