ios_assets.py 1.2 KB

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