copy_files_to_build_prefix.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from _common import sort_by_keywords
  2. SOURCE_ROOT = '${ARCADIA_ROOT}/'
  3. BUILD_ROOT = '${ARCADIA_BUILD_ROOT}/'
  4. CURDIR = '${CURDIR}/'
  5. BINDIR = '${BINDIR}/'
  6. def on_copy_files_to_build_prefix(unit, *args):
  7. keywords = {'PREFIX': 1, 'GLOBAL': 0}
  8. # NB! keyword 'GLOBAL' is a way to skip this word from the list of files
  9. flat_args, spec_args = sort_by_keywords(keywords, args)
  10. prefix = spec_args['PREFIX'][0] if 'PREFIX' in spec_args else ''
  11. if len(prefix) > 0:
  12. build_prefix = '/'.join([BUILD_ROOT, prefix])
  13. else:
  14. build_prefix = BUILD_ROOT
  15. for arg in flat_args:
  16. if arg.startswith(build_prefix):
  17. # nothing to do
  18. pass
  19. elif len(prefix) > 0 and arg.startswith(BUILD_ROOT):
  20. unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(BUILD_ROOT):])])
  21. elif arg.startswith(SOURCE_ROOT):
  22. unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(SOURCE_ROOT):])])
  23. else:
  24. offset = 0
  25. if arg.startswith(BINDIR):
  26. offset = len(BINDIR)
  27. elif arg.startswith(CURDIR):
  28. offset = len(CURDIR)
  29. unit.oncopy_file([arg, '{}/{}/{}'.format(build_prefix, unit.get(['MODDIR']), arg[offset:])])