lj_archive.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. def onlj_archive(unit, *args):
  2. """
  3. @usage: LJ_ARCHIVE(NAME Name LuaFiles...)
  4. Precompile .lua files using LuaJIT and archive both sources and results using sources names as keys
  5. """
  6. def iter_luas(data):
  7. for a in data:
  8. if a.endswith('.lua'):
  9. yield a
  10. def iter_objs(data):
  11. for a in data:
  12. s = a[:-3] + 'raw'
  13. unit.on_luajit_objdump(['OUT', s, a])
  14. yield s
  15. luas = list(iter_luas(args))
  16. objs = list(iter_objs(luas))
  17. unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs)
  18. unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas)
  19. def onlj_21_archive(unit, *args):
  20. """
  21. @usage: LJ_21_ARCHIVE(NAME Name LuaFiles...) # deprecated
  22. Precompile .lua files using LuaJIT 2.1 and archive both sources and results using sources names as keys
  23. """
  24. def iter_luas(data):
  25. for a in data:
  26. if a.endswith('.lua'):
  27. yield a
  28. def iter_objs(data):
  29. for a in data:
  30. s = a[:-3] + 'raw'
  31. unit.on_luajit_21_objdump(['OUT', s, a])
  32. yield s
  33. luas = list(iter_luas(args))
  34. objs = list(iter_objs(luas))
  35. unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaScripts.inc', 'KEYS', ':'.join(luas)] + objs)
  36. unit.onarchive_by_keys(['DONTCOMPRESS', 'NAME', 'LuaSources.inc', 'KEYS', ':'.join(luas)] + luas)