jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Mark Coggeshall, 2010
  4. "SAS support"
  5. import os, re
  6. from waflib import Utils, Task, TaskGen, Runner, Build, Errors, Node, Logs
  7. from waflib.TaskGen import feature, before_method
  8. sas_fun, _ = Task.compile_fun('sas -sysin ${SRCFILE} -log ${LOGFILE} -print ${LSTFILE}', shell=False)
  9. class sas(Task.Task):
  10. vars = ['SAS', 'SASFLAGS']
  11. def run(task):
  12. command = 'SAS'
  13. env = task.env
  14. bld = task.generator.bld
  15. fun = sas_fun
  16. node = task.inputs[0]
  17. logfilenode = node.change_ext('.log')
  18. lstfilenode = node.change_ext('.lst')
  19. # set the cwd
  20. task.cwd = task.inputs[0].parent.get_src().abspath()
  21. Logs.debug('runner: %s on %s' % (command, node.abspath))
  22. SASINPUTS = node.parent.get_bld().abspath() + os.pathsep + node.parent.get_src().abspath() + os.pathsep
  23. task.env.env = {'SASINPUTS': SASINPUTS}
  24. task.env.SRCFILE = node.abspath()
  25. task.env.LOGFILE = logfilenode.abspath()
  26. task.env.LSTFILE = lstfilenode.abspath()
  27. ret = fun(task)
  28. if ret:
  29. Logs.error('Running %s on %r returned a non-zero exit' % (command, node))
  30. Logs.error('SRCFILE = %r' % node)
  31. Logs.error('LOGFILE = %r' % logfilenode)
  32. Logs.error('LSTFILE = %r' % lstfilenode)
  33. return ret
  34. @feature('sas')
  35. @before_method('process_source')
  36. def apply_sas(self):
  37. if not getattr(self, 'type', None) in ('sas',):
  38. self.type = 'sas'
  39. self.env['logdir'] = getattr(self, 'logdir', 'log')
  40. self.env['lstdir'] = getattr(self, 'lstdir', 'lst')
  41. deps_lst = []
  42. if getattr(self, 'deps', None):
  43. deps = self.to_list(self.deps)
  44. for filename in deps:
  45. n = self.path.find_resource(filename)
  46. if not n: n = self.bld.root.find_resource(filename)
  47. if not n: raise Errors.WafError('cannot find input file %s for processing' % filename)
  48. if not n in deps_lst: deps_lst.append(n)
  49. for node in self.to_nodes(self.source):
  50. if self.type == 'sas':
  51. task = self.create_task('sas', src=node)
  52. task.dep_nodes = deps_lst
  53. self.source = []
  54. def configure(self):
  55. self.find_program('sas', var='SAS', mandatory=False)