ios_assets.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import _common as common
  2. import ymake
  3. import os
  4. def onios_assets(unit, *args):
  5. _, kv = common.sort_by_keywords(
  6. {'ROOT': 1, 'CONTENTS': -1, 'FLAGS': -1},
  7. args
  8. )
  9. if not kv.get('ROOT', []) and kv.get('CONTENTS', []):
  10. ymake.report_configure_error('Please specify ROOT directory for assets')
  11. origin_root = kv.get('ROOT')[0]
  12. destination_root = os.path.normpath(os.path.join('$BINDIR', os.path.basename(origin_root)))
  13. rel_list = []
  14. for cont in kv.get('CONTENTS', []):
  15. rel = os.path.relpath(cont, origin_root)
  16. if rel.startswith('..'):
  17. ymake.report_configure_error('{} is not subpath of {}'.format(cont, origin_root))
  18. rel_list.append(rel)
  19. if not rel_list:
  20. return
  21. results_list = [os.path.join('$B', unit.path()[3:], os.path.basename(origin_root), i) for i in rel_list]
  22. if len(kv.get('CONTENTS', [])) != len(results_list):
  23. ymake.report_configure_error('IOS_ASSETTS content length is not equals results')
  24. for s, d in zip(kv.get('CONTENTS', []), results_list):
  25. unit.oncopy_file([s, d])
  26. if kv.get('FLAGS', []):
  27. unit.onios_app_assets_flags(kv.get('FLAGS', []))
  28. unit.on_ios_assets([destination_root] + results_list)