uservices.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import json
  2. import ymake
  3. def on_process_usrv_files(unit, *args):
  4. mode = None
  5. if args[0] == 'NO_DEPS':
  6. for f in args[1:]:
  7. if f == 'OUT_NOAUTO':
  8. mode = f
  9. continue
  10. if mode is not None:
  11. unit.on_move([f + '.usrv', mode, f])
  12. elif f.endswith('.cpp'):
  13. unit.on_move([f + '.usrv', 'OUT', f])
  14. else:
  15. unit.on_move([f + '.usrv', 'OUT_NOAUTO', f])
  16. return
  17. deps_file = unit.resolve(unit.resolve_arc_path(args[0]))
  18. try:
  19. all_deps = json.load(open(deps_file, 'r'))
  20. except Exception as e:
  21. ymake.report_configure_error('Malformed dependencies JSON `{}`: {}'.format(args[0], e.__repr__()))
  22. return
  23. mode = 'OUT'
  24. for f in args[1:]:
  25. if f == 'OUT_NOAUTO':
  26. mode = f
  27. continue
  28. try:
  29. deps = all_deps[f]
  30. except KeyError:
  31. ymake.report_configure_error('Dependencies for {} not found in {}'.format(f, args[0]))
  32. unit.on_usrv_mv_with_deps([f])
  33. return
  34. deps_type = 'OUTPUT_INCLUDES' if f.endswith('.proto') else 'CPP_DEPS'
  35. unit.on_move([f + '.usrv', mode, f, deps_type] + deps)