github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/py-hwaftools/orch/features/feature_command.py (about) 1 #!/usr/bin/env python 2 ''' 3 Feature to run a command 4 5 It requires no previous steps. It provides the 'command' step. The 6 command_cmd is used as a source for the step. It should be specified 7 with an absolute path or if relative, w.r.t. the command_dir. 8 ''' 9 10 from waflib.TaskGen import feature 11 import waflib.Logs as msg 12 13 from orch.util import urlopen 14 15 import orch.features 16 orch.features.register_defaults( 17 'command', 18 command_dir = '.', 19 command_cmd_prefix = '', 20 command_cmd_postfix = '', 21 command_cmd = None, 22 command_cmd_options = '', 23 command_target = None, 24 ) 25 26 @feature('command') 27 def feature_command(tgen): 28 ''' 29 Run a command 30 ''' 31 cmd_dir = tgen.make_node(tgen.worch.command_dir) 32 cmd_node = cmd_dir.make_node(tgen.worch.command_cmd) 33 cmd_target = tgen.worch.command_target 34 if cmd_target: 35 map(tgen.make_node, tgen.to_list(cmd_target)) 36 cmd_rule = '{command_cmd_prefix}{command_cmd} {command_cmd_options} {command_cmd_postfix}' 37 tgen.step('command', 38 rule = tgen.worch.format(cmd_rule), 39 source = cmd_node, 40 target = cmd_target or "", 41 cwd = cmd_dir.abspath()) 42 43 return