asm.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2008-2018 (ita)
  4. """
  5. Assembly support, used by tools such as gas and nasm
  6. To declare targets using assembly::
  7. def configure(conf):
  8. conf.load('gcc gas')
  9. def build(bld):
  10. bld(
  11. features='c cstlib asm',
  12. source = 'test.S',
  13. target = 'asmtest')
  14. bld(
  15. features='asm asmprogram',
  16. source = 'test.S',
  17. target = 'asmtest')
  18. Support for pure asm programs and libraries should also work::
  19. def configure(conf):
  20. conf.load('nasm')
  21. conf.find_program('ld', 'ASLINK')
  22. def build(bld):
  23. bld(
  24. features='asm asmprogram',
  25. source = 'test.S',
  26. target = 'asmtest')
  27. """
  28. from waflib import Task
  29. from waflib.Tools.ccroot import link_task, stlink_task
  30. from waflib.TaskGen import extension
  31. class asm(Task.Task):
  32. """
  33. Compiles asm files by gas/nasm/yasm/...
  34. """
  35. color = 'BLUE'
  36. run_str = '${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
  37. @extension('.s', '.S', '.asm', '.ASM', '.spp', '.SPP')
  38. def asm_hook(self, node):
  39. """
  40. Binds the asm extension to the asm task
  41. :param node: input file
  42. :type node: :py:class:`waflib.Node.Node`
  43. """
  44. return self.create_compiled_task('asm', node)
  45. class asmprogram(link_task):
  46. "Links object files into a c program"
  47. run_str = '${ASLINK} ${ASLINKFLAGS} ${ASLNK_TGT_F}${TGT} ${ASLNK_SRC_F}${SRC}'
  48. ext_out = ['.bin']
  49. inst_to = '${BINDIR}'
  50. class asmshlib(asmprogram):
  51. "Links object files into a c shared library"
  52. inst_to = '${LIBDIR}'
  53. class asmstlib(stlink_task):
  54. "Links object files into a c static library"
  55. pass # do not remove
  56. def configure(conf):
  57. conf.env.ASMPATH_ST = '-I%s'