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.

1393 lines
52 KiB

6 years ago
  1. """SCons.Action
  2. This encapsulates information about executing any sort of action that
  3. can build one or more target Nodes (typically files) from one or more
  4. source Nodes (also typically files) given a specific Environment.
  5. The base class here is ActionBase. The base class supplies just a few
  6. OO utility methods and some generic methods for displaying information
  7. about an Action in response to the various commands that control printing.
  8. A second-level base class is _ActionAction. This extends ActionBase
  9. by providing the methods that can be used to show and perform an
  10. action. True Action objects will subclass _ActionAction; Action
  11. factory class objects will subclass ActionBase.
  12. The heavy lifting is handled by subclasses for the different types of
  13. actions we might execute:
  14. CommandAction
  15. CommandGeneratorAction
  16. FunctionAction
  17. ListAction
  18. The subclasses supply the following public interface methods used by
  19. other modules:
  20. __call__()
  21. THE public interface, "calling" an Action object executes the
  22. command or Python function. This also takes care of printing
  23. a pre-substitution command for debugging purposes.
  24. get_contents()
  25. Fetches the "contents" of an Action for signature calculation
  26. plus the varlist. This is what gets MD5 checksummed to decide
  27. if a target needs to be rebuilt because its action changed.
  28. genstring()
  29. Returns a string representation of the Action *without*
  30. command substitution, but allows a CommandGeneratorAction to
  31. generate the right action based on the specified target,
  32. source and env. This is used by the Signature subsystem
  33. (through the Executor) to obtain an (imprecise) representation
  34. of the Action operation for informative purposes.
  35. Subclasses also supply the following methods for internal use within
  36. this module:
  37. __str__()
  38. Returns a string approximation of the Action; no variable
  39. substitution is performed.
  40. execute()
  41. The internal method that really, truly, actually handles the
  42. execution of a command or Python function. This is used so
  43. that the __call__() methods can take care of displaying any
  44. pre-substitution representations, and *then* execute an action
  45. without worrying about the specific Actions involved.
  46. get_presig()
  47. Fetches the "contents" of a subclass for signature calculation.
  48. The varlist is added to this to produce the Action's contents.
  49. TODO(?): Change this to always return ascii/bytes and not unicode (or py3 strings)
  50. strfunction()
  51. Returns a substituted string representation of the Action.
  52. This is used by the _ActionAction.show() command to display the
  53. command/function that will be executed to generate the target(s).
  54. There is a related independent ActionCaller class that looks like a
  55. regular Action, and which serves as a wrapper for arbitrary functions
  56. that we want to let the user specify the arguments to now, but actually
  57. execute later (when an out-of-date check determines that it's needed to
  58. be executed, for example). Objects of this class are returned by an
  59. ActionFactory class that provides a __call__() method as a convenient
  60. way for wrapping up the functions.
  61. """
  62. # Copyright (c) 2001 - 2017 The SCons Foundation
  63. #
  64. # Permission is hereby granted, free of charge, to any person obtaining
  65. # a copy of this software and associated documentation files (the
  66. # "Software"), to deal in the Software without restriction, including
  67. # without limitation the rights to use, copy, modify, merge, publish,
  68. # distribute, sublicense, and/or sell copies of the Software, and to
  69. # permit persons to whom the Software is furnished to do so, subject to
  70. # the following conditions:
  71. #
  72. # The above copyright notice and this permission notice shall be included
  73. # in all copies or substantial portions of the Software.
  74. #
  75. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  76. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  77. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  78. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  79. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  80. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  81. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  82. __revision__ = "src/engine/SCons/Action.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  83. import os
  84. import pickle
  85. import re
  86. import sys
  87. import subprocess
  88. import itertools
  89. import inspect
  90. import SCons.Debug
  91. from SCons.Debug import logInstanceCreation
  92. import SCons.Errors
  93. import SCons.Util
  94. import SCons.Subst
  95. # we use these a lot, so try to optimize them
  96. is_String = SCons.Util.is_String
  97. is_List = SCons.Util.is_List
  98. class _null(object):
  99. pass
  100. print_actions = 1
  101. execute_actions = 1
  102. print_actions_presub = 0
  103. # Use pickle protocol 1 when pickling functions for signature
  104. # otherwise python3 and python2 will yield different pickles
  105. # for the same object.
  106. # This is due to default being 1 for python 2.7, and 3 for 3.x
  107. # TODO: We can roll this forward to 2 (if it has value), but not
  108. # before a deprecation cycle as the sconsigns will change
  109. ACTION_SIGNATURE_PICKLE_PROTOCOL = 1
  110. def rfile(n):
  111. try:
  112. return n.rfile()
  113. except AttributeError:
  114. return n
  115. def default_exitstatfunc(s):
  116. return s
  117. strip_quotes = re.compile('^[\'"](.*)[\'"]$')
  118. def _callable_contents(obj):
  119. """Return the signature contents of a callable Python object.
  120. """
  121. try:
  122. # Test if obj is a method.
  123. return _function_contents(obj.__func__)
  124. except AttributeError:
  125. try:
  126. # Test if obj is a callable object.
  127. return _function_contents(obj.__call__.__func__)
  128. except AttributeError:
  129. try:
  130. # Test if obj is a code object.
  131. return _code_contents(obj)
  132. except AttributeError:
  133. # Test if obj is a function object.
  134. return _function_contents(obj)
  135. def _object_contents(obj):
  136. """Return the signature contents of any Python object.
  137. We have to handle the case where object contains a code object
  138. since it can be pickled directly.
  139. """
  140. try:
  141. # Test if obj is a method.
  142. return _function_contents(obj.__func__)
  143. except AttributeError:
  144. try:
  145. # Test if obj is a callable object.
  146. return _function_contents(obj.__call__.__func__)
  147. except AttributeError:
  148. try:
  149. # Test if obj is a code object.
  150. return _code_contents(obj)
  151. except AttributeError:
  152. try:
  153. # Test if obj is a function object.
  154. return _function_contents(obj)
  155. except AttributeError as ae:
  156. # Should be a pickle-able Python object.
  157. try:
  158. return _object_instance_content(obj)
  159. # pickling an Action instance or object doesn't yield a stable
  160. # content as instance property may be dumped in different orders
  161. # return pickle.dumps(obj, ACTION_SIGNATURE_PICKLE_PROTOCOL)
  162. except (pickle.PicklingError, TypeError, AttributeError) as ex:
  163. # This is weird, but it seems that nested classes
  164. # are unpickable. The Python docs say it should
  165. # always be a PicklingError, but some Python
  166. # versions seem to return TypeError. Just do
  167. # the best we can.
  168. return bytearray(repr(obj), 'utf-8')
  169. def _code_contents(code, docstring=None):
  170. """Return the signature contents of a code object.
  171. By providing direct access to the code object of the
  172. function, Python makes this extremely easy. Hooray!
  173. Unfortunately, older versions of Python include line
  174. number indications in the compiled byte code. Boo!
  175. So we remove the line number byte codes to prevent
  176. recompilations from moving a Python function.
  177. See:
  178. - https://docs.python.org/2/library/inspect.html
  179. - http://python-reference.readthedocs.io/en/latest/docs/code/index.html
  180. For info on what each co\_ variable provides
  181. The signature is as follows (should be byte/chars):
  182. co_argcount, len(co_varnames), len(co_cellvars), len(co_freevars),
  183. ( comma separated signature for each object in co_consts ),
  184. ( comma separated signature for each object in co_names ),
  185. ( The bytecode with line number bytecodes removed from co_code )
  186. co_argcount - Returns the number of positional arguments (including arguments with default values).
  187. co_varnames - Returns a tuple containing the names of the local variables (starting with the argument names).
  188. co_cellvars - Returns a tuple containing the names of local variables that are referenced by nested functions.
  189. co_freevars - Returns a tuple containing the names of free variables. (?)
  190. co_consts - Returns a tuple containing the literals used by the bytecode.
  191. co_names - Returns a tuple containing the names used by the bytecode.
  192. co_code - Returns a string representing the sequence of bytecode instructions.
  193. """
  194. # contents = []
  195. # The code contents depends on the number of local variables
  196. # but not their actual names.
  197. contents = bytearray("{}, {}".format(code.co_argcount, len(code.co_varnames)), 'utf-8')
  198. contents.extend(b", ")
  199. contents.extend(bytearray(str(len(code.co_cellvars)), 'utf-8'))
  200. contents.extend(b", ")
  201. contents.extend(bytearray(str(len(code.co_freevars)), 'utf-8'))
  202. # The code contents depends on any constants accessed by the
  203. # function. Note that we have to call _object_contents on each
  204. # constants because the code object of nested functions can
  205. # show-up among the constants.
  206. z = [_object_contents(cc) for cc in code.co_consts[1:]]
  207. contents.extend(b',(')
  208. contents.extend(bytearray(',', 'utf-8').join(z))
  209. contents.extend(b')')
  210. # The code contents depends on the variable names used to
  211. # accessed global variable, as changing the variable name changes
  212. # the variable actually accessed and therefore changes the
  213. # function result.
  214. z= [bytearray(_object_contents(cc)) for cc in code.co_names]
  215. contents.extend(b',(')
  216. contents.extend(bytearray(',','utf-8').join(z))
  217. contents.extend(b')')
  218. # The code contents depends on its actual code!!!
  219. contents.extend(b',(')
  220. contents.extend(code.co_code)
  221. contents.extend(b')')
  222. return contents
  223. def _function_contents(func):
  224. """
  225. The signature is as follows (should be byte/chars):
  226. < _code_contents (see above) from func.__code__ >
  227. ,( comma separated _object_contents for function argument defaults)
  228. ,( comma separated _object_contents for any closure contents )
  229. See also: https://docs.python.org/3/reference/datamodel.html
  230. - func.__code__ - The code object representing the compiled function body.
  231. - func.__defaults__ - A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value
  232. - func.__closure__ - None or a tuple of cells that contain bindings for the function's free variables.
  233. :Returns:
  234. Signature contents of a function. (in bytes)
  235. """
  236. contents = [_code_contents(func.__code__, func.__doc__)]
  237. # The function contents depends on the value of defaults arguments
  238. if func.__defaults__:
  239. function_defaults_contents = [_object_contents(cc) for cc in func.__defaults__]
  240. defaults = bytearray(b',(')
  241. defaults.extend(bytearray(b',').join(function_defaults_contents))
  242. defaults.extend(b')')
  243. contents.append(defaults)
  244. else:
  245. contents.append(b',()')
  246. # The function contents depends on the closure captured cell values.
  247. closure = func.__closure__ or []
  248. try:
  249. closure_contents = [_object_contents(x.cell_contents) for x in closure]
  250. except AttributeError:
  251. closure_contents = []
  252. contents.append(b',(')
  253. contents.append(bytearray(b',').join(closure_contents))
  254. contents.append(b')')
  255. retval = bytearray(b'').join(contents)
  256. return retval
  257. def _object_instance_content(obj):
  258. """
  259. Returns consistant content for a action class or an instance thereof
  260. :Parameters:
  261. - `obj` Should be either and action class or an instance thereof
  262. :Returns:
  263. bytearray or bytes representing the obj suitable for generating a signature from.
  264. """
  265. retval = bytearray()
  266. if obj is None:
  267. return b'N.'
  268. if isinstance(obj, SCons.Util.BaseStringTypes):
  269. return SCons.Util.to_bytes(obj)
  270. inst_class = obj.__class__
  271. inst_class_name = bytearray(obj.__class__.__name__,'utf-8')
  272. inst_class_module = bytearray(obj.__class__.__module__,'utf-8')
  273. inst_class_hierarchy = bytearray(repr(inspect.getclasstree([obj.__class__,])),'utf-8')
  274. # print("ICH:%s : %s"%(inst_class_hierarchy, repr(obj)))
  275. properties = [(p, getattr(obj, p, "None")) for p in dir(obj) if not (p[:2] == '__' or inspect.ismethod(getattr(obj, p)) or inspect.isbuiltin(getattr(obj,p))) ]
  276. properties.sort()
  277. properties_str = ','.join(["%s=%s"%(p[0],p[1]) for p in properties])
  278. properties_bytes = bytearray(properties_str,'utf-8')
  279. methods = [p for p in dir(obj) if inspect.ismethod(getattr(obj, p))]
  280. methods.sort()
  281. method_contents = []
  282. for m in methods:
  283. # print("Method:%s"%m)
  284. v = _function_contents(getattr(obj, m))
  285. # print("[%s->]V:%s [%s]"%(m,v,type(v)))
  286. method_contents.append(v)
  287. retval = bytearray(b'{')
  288. retval.extend(inst_class_name)
  289. retval.extend(b":")
  290. retval.extend(inst_class_module)
  291. retval.extend(b'}[[')
  292. retval.extend(inst_class_hierarchy)
  293. retval.extend(b']]{{')
  294. retval.extend(bytearray(b",").join(method_contents))
  295. retval.extend(b"}}{{{")
  296. retval.extend(properties_bytes)
  297. retval.extend(b'}}}')
  298. return retval
  299. # print("class :%s"%inst_class)
  300. # print("class_name :%s"%inst_class_name)
  301. # print("class_module :%s"%inst_class_module)
  302. # print("Class hier :\n%s"%pp.pformat(inst_class_hierarchy))
  303. # print("Inst Properties:\n%s"%pp.pformat(properties))
  304. # print("Inst Methods :\n%s"%pp.pformat(methods))
  305. def _actionAppend(act1, act2):
  306. # This function knows how to slap two actions together.
  307. # Mainly, it handles ListActions by concatenating into
  308. # a single ListAction.
  309. a1 = Action(act1)
  310. a2 = Action(act2)
  311. if a1 is None:
  312. return a2
  313. if a2 is None:
  314. return a1
  315. if isinstance(a1, ListAction):
  316. if isinstance(a2, ListAction):
  317. return ListAction(a1.list + a2.list)
  318. else:
  319. return ListAction(a1.list + [ a2 ])
  320. else:
  321. if isinstance(a2, ListAction):
  322. return ListAction([ a1 ] + a2.list)
  323. else:
  324. return ListAction([ a1, a2 ])
  325. def _do_create_keywords(args, kw):
  326. """This converts any arguments after the action argument into
  327. their equivalent keywords and adds them to the kw argument.
  328. """
  329. v = kw.get('varlist', ())
  330. # prevent varlist="FOO" from being interpreted as ['F', 'O', 'O']
  331. if is_String(v): v = (v,)
  332. kw['varlist'] = tuple(v)
  333. if args:
  334. # turn positional args into equivalent keywords
  335. cmdstrfunc = args[0]
  336. if cmdstrfunc is None or is_String(cmdstrfunc):
  337. kw['cmdstr'] = cmdstrfunc
  338. elif callable(cmdstrfunc):
  339. kw['strfunction'] = cmdstrfunc
  340. else:
  341. raise SCons.Errors.UserError(
  342. 'Invalid command display variable type. '
  343. 'You must either pass a string or a callback which '
  344. 'accepts (target, source, env) as parameters.')
  345. if len(args) > 1:
  346. kw['varlist'] = tuple(SCons.Util.flatten(args[1:])) + kw['varlist']
  347. if kw.get('strfunction', _null) is not _null \
  348. and kw.get('cmdstr', _null) is not _null:
  349. raise SCons.Errors.UserError(
  350. 'Cannot have both strfunction and cmdstr args to Action()')
  351. def _do_create_action(act, kw):
  352. """This is the actual "implementation" for the
  353. Action factory method, below. This handles the
  354. fact that passing lists to Action() itself has
  355. different semantics than passing lists as elements
  356. of lists.
  357. The former will create a ListAction, the latter
  358. will create a CommandAction by converting the inner
  359. list elements to strings."""
  360. if isinstance(act, ActionBase):
  361. return act
  362. if is_String(act):
  363. var=SCons.Util.get_environment_var(act)
  364. if var:
  365. # This looks like a string that is purely an Environment
  366. # variable reference, like "$FOO" or "${FOO}". We do
  367. # something special here...we lazily evaluate the contents
  368. # of that Environment variable, so a user could put something
  369. # like a function or a CommandGenerator in that variable
  370. # instead of a string.
  371. return LazyAction(var, kw)
  372. commands = str(act).split('\n')
  373. if len(commands) == 1:
  374. return CommandAction(commands[0], **kw)
  375. # The list of string commands may include a LazyAction, so we
  376. # reprocess them via _do_create_list_action.
  377. return _do_create_list_action(commands, kw)
  378. if is_List(act):
  379. return CommandAction(act, **kw)
  380. if callable(act):
  381. try:
  382. gen = kw['generator']
  383. del kw['generator']
  384. except KeyError:
  385. gen = 0
  386. if gen:
  387. action_type = CommandGeneratorAction
  388. else:
  389. action_type = FunctionAction
  390. return action_type(act, kw)
  391. # Catch a common error case with a nice message:
  392. if isinstance(act, int) or isinstance(act, float):
  393. raise TypeError("Don't know how to create an Action from a number (%s)"%act)
  394. # Else fail silently (???)
  395. return None
  396. def _do_create_list_action(act, kw):
  397. """A factory for list actions. Convert the input list into Actions
  398. and then wrap them in a ListAction."""
  399. acts = []
  400. for a in act:
  401. aa = _do_create_action(a, kw)
  402. if aa is not None: acts.append(aa)
  403. if not acts:
  404. return ListAction([])
  405. elif len(acts) == 1:
  406. return acts[0]
  407. else:
  408. return ListAction(acts)
  409. def Action(act, *args, **kw):
  410. """A factory for action objects."""
  411. # Really simple: the _do_create_* routines do the heavy lifting.
  412. _do_create_keywords(args, kw)
  413. if is_List(act):
  414. return _do_create_list_action(act, kw)
  415. return _do_create_action(act, kw)
  416. class ActionBase(object):
  417. """Base class for all types of action objects that can be held by
  418. other objects (Builders, Executors, etc.) This provides the
  419. common methods for manipulating and combining those actions."""
  420. def __eq__(self, other):
  421. return self.__dict__ == other
  422. def no_batch_key(self, env, target, source):
  423. return None
  424. batch_key = no_batch_key
  425. def genstring(self, target, source, env):
  426. return str(self)
  427. def get_contents(self, target, source, env):
  428. result = self.get_presig(target, source, env)
  429. if not isinstance(result,(bytes, bytearray)):
  430. result = bytearray("",'utf-8').join([ SCons.Util.to_bytes(r) for r in result ])
  431. else:
  432. # Make a copy and put in bytearray, without this the contents returned by get_presig
  433. # can be changed by the logic below, appending with each call and causing very
  434. # hard to track down issues...
  435. result = bytearray(result)
  436. # At this point everything should be a bytearray
  437. # This should never happen, as the Action() factory should wrap
  438. # the varlist, but just in case an action is created directly,
  439. # we duplicate this check here.
  440. vl = self.get_varlist(target, source, env)
  441. if is_String(vl): vl = (vl,)
  442. for v in vl:
  443. # do the subst this way to ignore $(...$) parts:
  444. if isinstance(result, bytearray):
  445. result.extend(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source)))
  446. else:
  447. raise Exception("WE SHOULD NEVER GET HERE result should be bytearray not:%s"%type(result))
  448. # result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source)))
  449. if isinstance(result, (bytes,bytearray)):
  450. return result
  451. else:
  452. raise Exception("WE SHOULD NEVER GET HERE - #2 result should be bytearray not:%s" % type(result))
  453. # return b''.join(result)
  454. def __add__(self, other):
  455. return _actionAppend(self, other)
  456. def __radd__(self, other):
  457. return _actionAppend(other, self)
  458. def presub_lines(self, env):
  459. # CommandGeneratorAction needs a real environment
  460. # in order to return the proper string here, since
  461. # it may call LazyAction, which looks up a key
  462. # in that env. So we temporarily remember the env here,
  463. # and CommandGeneratorAction will use this env
  464. # when it calls its _generate method.
  465. self.presub_env = env
  466. lines = str(self).split('\n')
  467. self.presub_env = None # don't need this any more
  468. return lines
  469. def get_varlist(self, target, source, env, executor=None):
  470. return self.varlist
  471. def get_targets(self, env, executor):
  472. """
  473. Returns the type of targets ($TARGETS, $CHANGED_TARGETS) used
  474. by this action.
  475. """
  476. return self.targets
  477. class _ActionAction(ActionBase):
  478. """Base class for actions that create output objects."""
  479. def __init__(self, cmdstr=_null, strfunction=_null, varlist=(),
  480. presub=_null, chdir=None, exitstatfunc=None,
  481. batch_key=None, targets='$TARGETS',
  482. **kw):
  483. self.cmdstr = cmdstr
  484. if strfunction is not _null:
  485. if strfunction is None:
  486. self.cmdstr = None
  487. else:
  488. self.strfunction = strfunction
  489. self.varlist = varlist
  490. self.presub = presub
  491. self.chdir = chdir
  492. if not exitstatfunc:
  493. exitstatfunc = default_exitstatfunc
  494. self.exitstatfunc = exitstatfunc
  495. self.targets = targets
  496. if batch_key:
  497. if not callable(batch_key):
  498. # They have set batch_key, but not to their own
  499. # callable. The default behavior here will batch
  500. # *all* targets+sources using this action, separated
  501. # for each construction environment.
  502. def default_batch_key(self, env, target, source):
  503. return (id(self), id(env))
  504. batch_key = default_batch_key
  505. SCons.Util.AddMethod(self, batch_key, 'batch_key')
  506. def print_cmd_line(self, s, target, source, env):
  507. """
  508. In python 3, and in some of our tests, sys.stdout is
  509. a String io object, and it takes unicode strings only
  510. In other cases it's a regular Python 2.x file object
  511. which takes strings (bytes), and if you pass those a
  512. unicode object they try to decode with 'ascii' codec
  513. which fails if the cmd line has any hi-bit-set chars.
  514. This code assumes s is a regular string, but should
  515. work if it's unicode too.
  516. """
  517. try:
  518. sys.stdout.write(s + u"\n")
  519. except UnicodeDecodeError:
  520. sys.stdout.write(s + "\n")
  521. def __call__(self, target, source, env,
  522. exitstatfunc=_null,
  523. presub=_null,
  524. show=_null,
  525. execute=_null,
  526. chdir=_null,
  527. executor=None):
  528. if not is_List(target):
  529. target = [target]
  530. if not is_List(source):
  531. source = [source]
  532. if presub is _null:
  533. presub = self.presub
  534. if presub is _null:
  535. presub = print_actions_presub
  536. if exitstatfunc is _null: exitstatfunc = self.exitstatfunc
  537. if show is _null: show = print_actions
  538. if execute is _null: execute = execute_actions
  539. if chdir is _null: chdir = self.chdir
  540. save_cwd = None
  541. if chdir:
  542. save_cwd = os.getcwd()
  543. try:
  544. chdir = str(chdir.get_abspath())
  545. except AttributeError:
  546. if not is_String(chdir):
  547. if executor:
  548. chdir = str(executor.batches[0].targets[0].dir)
  549. else:
  550. chdir = str(target[0].dir)
  551. if presub:
  552. if executor:
  553. target = executor.get_all_targets()
  554. source = executor.get_all_sources()
  555. t = ' and '.join(map(str, target))
  556. l = '\n '.join(self.presub_lines(env))
  557. out = u"Building %s with action:\n %s\n" % (t, l)
  558. sys.stdout.write(out)
  559. cmd = None
  560. if show and self.strfunction:
  561. if executor:
  562. target = executor.get_all_targets()
  563. source = executor.get_all_sources()
  564. try:
  565. cmd = self.strfunction(target, source, env, executor)
  566. except TypeError:
  567. cmd = self.strfunction(target, source, env)
  568. if cmd:
  569. if chdir:
  570. cmd = ('os.chdir(%s)\n' % repr(chdir)) + cmd
  571. try:
  572. get = env.get
  573. except AttributeError:
  574. print_func = self.print_cmd_line
  575. else:
  576. print_func = get('PRINT_CMD_LINE_FUNC')
  577. if not print_func:
  578. print_func = self.print_cmd_line
  579. print_func(cmd, target, source, env)
  580. stat = 0
  581. if execute:
  582. if chdir:
  583. os.chdir(chdir)
  584. try:
  585. stat = self.execute(target, source, env, executor=executor)
  586. if isinstance(stat, SCons.Errors.BuildError):
  587. s = exitstatfunc(stat.status)
  588. if s:
  589. stat.status = s
  590. else:
  591. stat = s
  592. else:
  593. stat = exitstatfunc(stat)
  594. finally:
  595. if save_cwd:
  596. os.chdir(save_cwd)
  597. if cmd and save_cwd:
  598. print_func('os.chdir(%s)' % repr(save_cwd), target, source, env)
  599. return stat
  600. def _string_from_cmd_list(cmd_list):
  601. """Takes a list of command line arguments and returns a pretty
  602. representation for printing."""
  603. cl = []
  604. for arg in map(str, cmd_list):
  605. if ' ' in arg or '\t' in arg:
  606. arg = '"' + arg + '"'
  607. cl.append(arg)
  608. return ' '.join(cl)
  609. default_ENV = None
  610. def get_default_ENV(env):
  611. """
  612. A fiddlin' little function that has an 'import SCons.Environment' which
  613. can't be moved to the top level without creating an import loop. Since
  614. this import creates a local variable named 'SCons', it blocks access to
  615. the global variable, so we move it here to prevent complaints about local
  616. variables being used uninitialized.
  617. """
  618. global default_ENV
  619. try:
  620. return env['ENV']
  621. except KeyError:
  622. if not default_ENV:
  623. import SCons.Environment
  624. # This is a hideously expensive way to get a default shell
  625. # environment. What it really should do is run the platform
  626. # setup to get the default ENV. Fortunately, it's incredibly
  627. # rare for an Environment not to have a shell environment, so
  628. # we're not going to worry about it overmuch.
  629. default_ENV = SCons.Environment.Environment()['ENV']
  630. return default_ENV
  631. def _subproc(scons_env, cmd, error = 'ignore', **kw):
  632. """Do common setup for a subprocess.Popen() call
  633. This function is still in draft mode. We're going to need something like
  634. it in the long run as more and more places use subprocess, but I'm sure
  635. it'll have to be tweaked to get the full desired functionality.
  636. one special arg (so far?), 'error', to tell what to do with exceptions.
  637. """
  638. # allow std{in,out,err} to be "'devnull'"
  639. io = kw.get('stdin')
  640. if is_String(io) and io == 'devnull':
  641. kw['stdin'] = open(os.devnull)
  642. io = kw.get('stdout')
  643. if is_String(io) and io == 'devnull':
  644. kw['stdout'] = open(os.devnull, 'w')
  645. io = kw.get('stderr')
  646. if is_String(io) and io == 'devnull':
  647. kw['stderr'] = open(os.devnull, 'w')
  648. # Figure out what shell environment to use
  649. ENV = kw.get('env', None)
  650. if ENV is None: ENV = get_default_ENV(scons_env)
  651. # Ensure that the ENV values are all strings:
  652. new_env = {}
  653. for key, value in ENV.items():
  654. if is_List(value):
  655. # If the value is a list, then we assume it is a path list,
  656. # because that's a pretty common list-like value to stick
  657. # in an environment variable:
  658. value = SCons.Util.flatten_sequence(value)
  659. new_env[key] = os.pathsep.join(map(str, value))
  660. else:
  661. # It's either a string or something else. If it's a string,
  662. # we still want to call str() because it might be a *Unicode*
  663. # string, which makes subprocess.Popen() gag. If it isn't a
  664. # string or a list, then we just coerce it to a string, which
  665. # is the proper way to handle Dir and File instances and will
  666. # produce something reasonable for just about everything else:
  667. new_env[key] = str(value)
  668. kw['env'] = new_env
  669. try:
  670. return subprocess.Popen(cmd, **kw)
  671. except EnvironmentError as e:
  672. if error == 'raise': raise
  673. # return a dummy Popen instance that only returns error
  674. class dummyPopen(object):
  675. def __init__(self, e): self.exception = e
  676. def communicate(self, input=None): return ('', '')
  677. def wait(self): return -self.exception.errno
  678. stdin = None
  679. class f(object):
  680. def read(self): return ''
  681. def readline(self): return ''
  682. def __iter__(self): return iter(())
  683. stdout = stderr = f()
  684. return dummyPopen(e)
  685. class CommandAction(_ActionAction):
  686. """Class for command-execution actions."""
  687. def __init__(self, cmd, **kw):
  688. # Cmd can actually be a list or a single item; if it's a
  689. # single item it should be the command string to execute; if a
  690. # list then it should be the words of the command string to
  691. # execute. Only a single command should be executed by this
  692. # object; lists of commands should be handled by embedding
  693. # these objects in a ListAction object (which the Action()
  694. # factory above does). cmd will be passed to
  695. # Environment.subst_list() for substituting environment
  696. # variables.
  697. if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.CommandAction')
  698. _ActionAction.__init__(self, **kw)
  699. if is_List(cmd):
  700. if [c for c in cmd if is_List(c)]:
  701. raise TypeError("CommandAction should be given only " \
  702. "a single command")
  703. self.cmd_list = cmd
  704. def __str__(self):
  705. if is_List(self.cmd_list):
  706. return ' '.join(map(str, self.cmd_list))
  707. return str(self.cmd_list)
  708. def process(self, target, source, env, executor=None):
  709. if executor:
  710. result = env.subst_list(self.cmd_list, 0, executor=executor)
  711. else:
  712. result = env.subst_list(self.cmd_list, 0, target, source)
  713. silent = None
  714. ignore = None
  715. while True:
  716. try: c = result[0][0][0]
  717. except IndexError: c = None
  718. if c == '@': silent = 1
  719. elif c == '-': ignore = 1
  720. else: break
  721. result[0][0] = result[0][0][1:]
  722. try:
  723. if not result[0][0]:
  724. result[0] = result[0][1:]
  725. except IndexError:
  726. pass
  727. return result, ignore, silent
  728. def strfunction(self, target, source, env, executor=None):
  729. if self.cmdstr is None:
  730. return None
  731. if self.cmdstr is not _null:
  732. from SCons.Subst import SUBST_RAW
  733. if executor:
  734. c = env.subst(self.cmdstr, SUBST_RAW, executor=executor)
  735. else:
  736. c = env.subst(self.cmdstr, SUBST_RAW, target, source)
  737. if c:
  738. return c
  739. cmd_list, ignore, silent = self.process(target, source, env, executor)
  740. if silent:
  741. return ''
  742. return _string_from_cmd_list(cmd_list[0])
  743. def execute(self, target, source, env, executor=None):
  744. """Execute a command action.
  745. This will handle lists of commands as well as individual commands,
  746. because construction variable substitution may turn a single
  747. "command" into a list. This means that this class can actually
  748. handle lists of commands, even though that's not how we use it
  749. externally.
  750. """
  751. escape_list = SCons.Subst.escape_list
  752. flatten_sequence = SCons.Util.flatten_sequence
  753. try:
  754. shell = env['SHELL']
  755. except KeyError:
  756. raise SCons.Errors.UserError('Missing SHELL construction variable.')
  757. try:
  758. spawn = env['SPAWN']
  759. except KeyError:
  760. raise SCons.Errors.UserError('Missing SPAWN construction variable.')
  761. else:
  762. if is_String(spawn):
  763. spawn = env.subst(spawn, raw=1, conv=lambda x: x)
  764. escape = env.get('ESCAPE', lambda x: x)
  765. ENV = get_default_ENV(env)
  766. # Ensure that the ENV values are all strings:
  767. for key, value in ENV.items():
  768. if not is_String(value):
  769. if is_List(value):
  770. # If the value is a list, then we assume it is a
  771. # path list, because that's a pretty common list-like
  772. # value to stick in an environment variable:
  773. value = flatten_sequence(value)
  774. ENV[key] = os.pathsep.join(map(str, value))
  775. else:
  776. # If it isn't a string or a list, then we just coerce
  777. # it to a string, which is the proper way to handle
  778. # Dir and File instances and will produce something
  779. # reasonable for just about everything else:
  780. ENV[key] = str(value)
  781. if executor:
  782. target = executor.get_all_targets()
  783. source = executor.get_all_sources()
  784. cmd_list, ignore, silent = self.process(target, list(map(rfile, source)), env, executor)
  785. # Use len() to filter out any "command" that's zero-length.
  786. for cmd_line in filter(len, cmd_list):
  787. # Escape the command line for the interpreter we are using.
  788. cmd_line = escape_list(cmd_line, escape)
  789. result = spawn(shell, escape, cmd_line[0], cmd_line, ENV)
  790. if not ignore and result:
  791. msg = "Error %s" % result
  792. return SCons.Errors.BuildError(errstr=msg,
  793. status=result,
  794. action=self,
  795. command=cmd_line)
  796. return 0
  797. def get_presig(self, target, source, env, executor=None):
  798. """Return the signature contents of this action's command line.
  799. This strips $(-$) and everything in between the string,
  800. since those parts don't affect signatures.
  801. """
  802. from SCons.Subst import SUBST_SIG
  803. cmd = self.cmd_list
  804. if is_List(cmd):
  805. cmd = ' '.join(map(str, cmd))
  806. else:
  807. cmd = str(cmd)
  808. if executor:
  809. return env.subst_target_source(cmd, SUBST_SIG, executor=executor)
  810. else:
  811. return env.subst_target_source(cmd, SUBST_SIG, target, source)
  812. def get_implicit_deps(self, target, source, env, executor=None):
  813. icd = env.get('IMPLICIT_COMMAND_DEPENDENCIES', True)
  814. if is_String(icd) and icd[:1] == '$':
  815. icd = env.subst(icd)
  816. if not icd or icd in ('0', 'None'):
  817. return []
  818. from SCons.Subst import SUBST_SIG
  819. if executor:
  820. cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, executor=executor)
  821. else:
  822. cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, target, source)
  823. res = []
  824. for cmd_line in cmd_list:
  825. if cmd_line:
  826. d = str(cmd_line[0])
  827. m = strip_quotes.match(d)
  828. if m:
  829. d = m.group(1)
  830. d = env.WhereIs(d)
  831. if d:
  832. res.append(env.fs.File(d))
  833. return res
  834. class CommandGeneratorAction(ActionBase):
  835. """Class for command-generator actions."""
  836. def __init__(self, generator, kw):
  837. if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.CommandGeneratorAction')
  838. self.generator = generator
  839. self.gen_kw = kw
  840. self.varlist = kw.get('varlist', ())
  841. self.targets = kw.get('targets', '$TARGETS')
  842. def _generate(self, target, source, env, for_signature, executor=None):
  843. # ensure that target is a list, to make it easier to write
  844. # generator functions:
  845. if not is_List(target):
  846. target = [target]
  847. if executor:
  848. target = executor.get_all_targets()
  849. source = executor.get_all_sources()
  850. ret = self.generator(target=target,
  851. source=source,
  852. env=env,
  853. for_signature=for_signature)
  854. gen_cmd = Action(ret, **self.gen_kw)
  855. if not gen_cmd:
  856. raise SCons.Errors.UserError("Object returned from command generator: %s cannot be used to create an Action." % repr(ret))
  857. return gen_cmd
  858. def __str__(self):
  859. try:
  860. env = self.presub_env
  861. except AttributeError:
  862. env = None
  863. if env is None:
  864. env = SCons.Defaults.DefaultEnvironment()
  865. act = self._generate([], [], env, 1)
  866. return str(act)
  867. def batch_key(self, env, target, source):
  868. return self._generate(target, source, env, 1).batch_key(env, target, source)
  869. def genstring(self, target, source, env, executor=None):
  870. return self._generate(target, source, env, 1, executor).genstring(target, source, env)
  871. def __call__(self, target, source, env, exitstatfunc=_null, presub=_null,
  872. show=_null, execute=_null, chdir=_null, executor=None):
  873. act = self._generate(target, source, env, 0, executor)
  874. if act is None:
  875. raise SCons.Errors.UserError("While building `%s': "
  876. "Cannot deduce file extension from source files: %s"
  877. % (repr(list(map(str, target))), repr(list(map(str, source)))))
  878. return act(target, source, env, exitstatfunc, presub,
  879. show, execute, chdir, executor)
  880. def get_presig(self, target, source, env, executor=None):
  881. """Return the signature contents of this action's command line.
  882. This strips $(-$) and everything in between the string,
  883. since those parts don't affect signatures.
  884. """
  885. return self._generate(target, source, env, 1, executor).get_presig(target, source, env)
  886. def get_implicit_deps(self, target, source, env, executor=None):
  887. return self._generate(target, source, env, 1, executor).get_implicit_deps(target, source, env)
  888. def get_varlist(self, target, source, env, executor=None):
  889. return self._generate(target, source, env, 1, executor).get_varlist(target, source, env, executor)
  890. def get_targets(self, env, executor):
  891. return self._generate(None, None, env, 1, executor).get_targets(env, executor)
  892. class LazyAction(CommandGeneratorAction, CommandAction):
  893. """
  894. A LazyAction is a kind of hybrid generator and command action for
  895. strings of the form "$VAR". These strings normally expand to other
  896. strings (think "$CCCOM" to "$CC -c -o $TARGET $SOURCE"), but we also
  897. want to be able to replace them with functions in the construction
  898. environment. Consequently, we want lazy evaluation and creation of
  899. an Action in the case of the function, but that's overkill in the more
  900. normal case of expansion to other strings.
  901. So we do this with a subclass that's both a generator *and*
  902. a command action. The overridden methods all do a quick check
  903. of the construction variable, and if it's a string we just call
  904. the corresponding CommandAction method to do the heavy lifting.
  905. If not, then we call the same-named CommandGeneratorAction method.
  906. The CommandGeneratorAction methods work by using the overridden
  907. _generate() method, that is, our own way of handling "generation" of
  908. an action based on what's in the construction variable.
  909. """
  910. def __init__(self, var, kw):
  911. if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.LazyAction')
  912. CommandAction.__init__(self, '${'+var+'}', **kw)
  913. self.var = SCons.Util.to_String(var)
  914. self.gen_kw = kw
  915. def get_parent_class(self, env):
  916. c = env.get(self.var)
  917. if is_String(c) and not '\n' in c:
  918. return CommandAction
  919. return CommandGeneratorAction
  920. def _generate_cache(self, env):
  921. if env:
  922. c = env.get(self.var, '')
  923. else:
  924. c = ''
  925. gen_cmd = Action(c, **self.gen_kw)
  926. if not gen_cmd:
  927. raise SCons.Errors.UserError("$%s value %s cannot be used to create an Action." % (self.var, repr(c)))
  928. return gen_cmd
  929. def _generate(self, target, source, env, for_signature, executor=None):
  930. return self._generate_cache(env)
  931. def __call__(self, target, source, env, *args, **kw):
  932. c = self.get_parent_class(env)
  933. return c.__call__(self, target, source, env, *args, **kw)
  934. def get_presig(self, target, source, env):
  935. c = self.get_parent_class(env)
  936. return c.get_presig(self, target, source, env)
  937. def get_varlist(self, target, source, env, executor=None):
  938. c = self.get_parent_class(env)
  939. return c.get_varlist(self, target, source, env, executor)
  940. class FunctionAction(_ActionAction):
  941. """Class for Python function actions."""
  942. def __init__(self, execfunction, kw):
  943. if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.FunctionAction')
  944. self.execfunction = execfunction
  945. try:
  946. self.funccontents = _callable_contents(execfunction)
  947. except AttributeError:
  948. try:
  949. # See if execfunction will do the heavy lifting for us.
  950. self.gc = execfunction.get_contents
  951. except AttributeError:
  952. # This is weird, just do the best we can.
  953. self.funccontents = _object_contents(execfunction)
  954. _ActionAction.__init__(self, **kw)
  955. def function_name(self):
  956. try:
  957. return self.execfunction.__name__
  958. except AttributeError:
  959. try:
  960. return self.execfunction.__class__.__name__
  961. except AttributeError:
  962. return "unknown_python_function"
  963. def strfunction(self, target, source, env, executor=None):
  964. if self.cmdstr is None:
  965. return None
  966. if self.cmdstr is not _null:
  967. from SCons.Subst import SUBST_RAW
  968. if executor:
  969. c = env.subst(self.cmdstr, SUBST_RAW, executor=executor)
  970. else:
  971. c = env.subst(self.cmdstr, SUBST_RAW, target, source)
  972. if c:
  973. return c
  974. def array(a):
  975. def quote(s):
  976. try:
  977. str_for_display = s.str_for_display
  978. except AttributeError:
  979. s = repr(s)
  980. else:
  981. s = str_for_display()
  982. return s
  983. return '[' + ", ".join(map(quote, a)) + ']'
  984. try:
  985. strfunc = self.execfunction.strfunction
  986. except AttributeError:
  987. pass
  988. else:
  989. if strfunc is None:
  990. return None
  991. if callable(strfunc):
  992. return strfunc(target, source, env)
  993. name = self.function_name()
  994. tstr = array(target)
  995. sstr = array(source)
  996. return "%s(%s, %s)" % (name, tstr, sstr)
  997. def __str__(self):
  998. name = self.function_name()
  999. if name == 'ActionCaller':
  1000. return str(self.execfunction)
  1001. return "%s(target, source, env)" % name
  1002. def execute(self, target, source, env, executor=None):
  1003. exc_info = (None,None,None)
  1004. try:
  1005. if executor:
  1006. target = executor.get_all_targets()
  1007. source = executor.get_all_sources()
  1008. rsources = list(map(rfile, source))
  1009. try:
  1010. result = self.execfunction(target=target, source=rsources, env=env)
  1011. except KeyboardInterrupt as e:
  1012. raise
  1013. except SystemExit as e:
  1014. raise
  1015. except Exception as e:
  1016. result = e
  1017. exc_info = sys.exc_info()
  1018. if result:
  1019. result = SCons.Errors.convert_to_BuildError(result, exc_info)
  1020. result.node=target
  1021. result.action=self
  1022. try:
  1023. result.command=self.strfunction(target, source, env, executor)
  1024. except TypeError:
  1025. result.command=self.strfunction(target, source, env)
  1026. # FIXME: This maintains backward compatibility with respect to
  1027. # which type of exceptions were returned by raising an
  1028. # exception and which ones were returned by value. It would
  1029. # probably be best to always return them by value here, but
  1030. # some codes do not check the return value of Actions and I do
  1031. # not have the time to modify them at this point.
  1032. if (exc_info[1] and
  1033. not isinstance(exc_info[1],EnvironmentError)):
  1034. raise result
  1035. return result
  1036. finally:
  1037. # Break the cycle between the traceback object and this
  1038. # function stack frame. See the sys.exc_info() doc info for
  1039. # more information about this issue.
  1040. del exc_info
  1041. def get_presig(self, target, source, env):
  1042. """Return the signature contents of this callable action."""
  1043. try:
  1044. return self.gc(target, source, env)
  1045. except AttributeError:
  1046. return self.funccontents
  1047. def get_implicit_deps(self, target, source, env):
  1048. return []
  1049. class ListAction(ActionBase):
  1050. """Class for lists of other actions."""
  1051. def __init__(self, actionlist):
  1052. if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.ListAction')
  1053. def list_of_actions(x):
  1054. if isinstance(x, ActionBase):
  1055. return x
  1056. return Action(x)
  1057. self.list = list(map(list_of_actions, actionlist))
  1058. # our children will have had any varlist
  1059. # applied; we don't need to do it again
  1060. self.varlist = ()
  1061. self.targets = '$TARGETS'
  1062. def genstring(self, target, source, env):
  1063. return '\n'.join([a.genstring(target, source, env) for a in self.list])
  1064. def __str__(self):
  1065. return '\n'.join(map(str, self.list))
  1066. def presub_lines(self, env):
  1067. return SCons.Util.flatten_sequence(
  1068. [a.presub_lines(env) for a in self.list])
  1069. def get_presig(self, target, source, env):
  1070. """Return the signature contents of this action list.
  1071. Simple concatenation of the signatures of the elements.
  1072. """
  1073. return b"".join([bytes(x.get_contents(target, source, env)) for x in self.list])
  1074. def __call__(self, target, source, env, exitstatfunc=_null, presub=_null,
  1075. show=_null, execute=_null, chdir=_null, executor=None):
  1076. if executor:
  1077. target = executor.get_all_targets()
  1078. source = executor.get_all_sources()
  1079. for act in self.list:
  1080. stat = act(target, source, env, exitstatfunc, presub,
  1081. show, execute, chdir, executor)
  1082. if stat:
  1083. return stat
  1084. return 0
  1085. def get_implicit_deps(self, target, source, env):
  1086. result = []
  1087. for act in self.list:
  1088. result.extend(act.get_implicit_deps(target, source, env))
  1089. return result
  1090. def get_varlist(self, target, source, env, executor=None):
  1091. result = SCons.Util.OrderedDict()
  1092. for act in self.list:
  1093. for var in act.get_varlist(target, source, env, executor):
  1094. result[var] = True
  1095. return list(result.keys())
  1096. class ActionCaller(object):
  1097. """A class for delaying calling an Action function with specific
  1098. (positional and keyword) arguments until the Action is actually
  1099. executed.
  1100. This class looks to the rest of the world like a normal Action object,
  1101. but what it's really doing is hanging on to the arguments until we
  1102. have a target, source and env to use for the expansion.
  1103. """
  1104. def __init__(self, parent, args, kw):
  1105. self.parent = parent
  1106. self.args = args
  1107. self.kw = kw
  1108. def get_contents(self, target, source, env):
  1109. actfunc = self.parent.actfunc
  1110. try:
  1111. # "self.actfunc" is a function.
  1112. contents = actfunc.__code__.co_code
  1113. except AttributeError:
  1114. # "self.actfunc" is a callable object.
  1115. try:
  1116. contents = actfunc.__call__.__func__.__code__.co_code
  1117. except AttributeError:
  1118. # No __call__() method, so it might be a builtin
  1119. # or something like that. Do the best we can.
  1120. contents = repr(actfunc)
  1121. return contents
  1122. def subst(self, s, target, source, env):
  1123. # If s is a list, recursively apply subst()
  1124. # to every element in the list
  1125. if is_List(s):
  1126. result = []
  1127. for elem in s:
  1128. result.append(self.subst(elem, target, source, env))
  1129. return self.parent.convert(result)
  1130. # Special-case hack: Let a custom function wrapped in an
  1131. # ActionCaller get at the environment through which the action
  1132. # was called by using this hard-coded value as a special return.
  1133. if s == '$__env__':
  1134. return env
  1135. elif is_String(s):
  1136. return env.subst(s, 1, target, source)
  1137. return self.parent.convert(s)
  1138. def subst_args(self, target, source, env):
  1139. return [self.subst(x, target, source, env) for x in self.args]
  1140. def subst_kw(self, target, source, env):
  1141. kw = {}
  1142. for key in list(self.kw.keys()):
  1143. kw[key] = self.subst(self.kw[key], target, source, env)
  1144. return kw
  1145. def __call__(self, target, source, env, executor=None):
  1146. args = self.subst_args(target, source, env)
  1147. kw = self.subst_kw(target, source, env)
  1148. return self.parent.actfunc(*args, **kw)
  1149. def strfunction(self, target, source, env):
  1150. args = self.subst_args(target, source, env)
  1151. kw = self.subst_kw(target, source, env)
  1152. return self.parent.strfunc(*args, **kw)
  1153. def __str__(self):
  1154. return self.parent.strfunc(*self.args, **self.kw)
  1155. class ActionFactory(object):
  1156. """A factory class that will wrap up an arbitrary function
  1157. as an SCons-executable Action object.
  1158. The real heavy lifting here is done by the ActionCaller class.
  1159. We just collect the (positional and keyword) arguments that we're
  1160. called with and give them to the ActionCaller object we create,
  1161. so it can hang onto them until it needs them.
  1162. """
  1163. def __init__(self, actfunc, strfunc, convert=lambda x: x):
  1164. self.actfunc = actfunc
  1165. self.strfunc = strfunc
  1166. self.convert = convert
  1167. def __call__(self, *args, **kw):
  1168. ac = ActionCaller(self, args, kw)
  1169. action = Action(ac, strfunction=ac.strfunction)
  1170. return action
  1171. # Local Variables:
  1172. # tab-width:4
  1173. # indent-tabs-mode:nil
  1174. # End:
  1175. # vim: set expandtab tabstop=4 shiftwidth=4: