2b736191533b7277955d62b0bfebc0ba361eacb4fd6bcbcf468c5d333e80dfb1fbb189e0ba0750978cd6d597f74bae625ac8be78f37aadb3d22f5ee02116d2 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) 2011 Google Inc. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. """gypsh output module
  5. gypsh is a GYP shell. It's not really a generator per se. All it does is
  6. fire up an interactive Python session with a few local variables set to the
  7. variables passed to the generator. Like gypd, it's intended as a debugging
  8. aid, to facilitate the exploration of .gyp structures after being processed
  9. by the input module.
  10. The expected usage is "gyp -f gypsh -D OS=desired_os".
  11. """
  12. import code
  13. import sys
  14. # All of this stuff about generator variables was lovingly ripped from gypd.py.
  15. # That module has a much better description of what's going on and why.
  16. _generator_identity_variables = [
  17. "EXECUTABLE_PREFIX",
  18. "EXECUTABLE_SUFFIX",
  19. "INTERMEDIATE_DIR",
  20. "PRODUCT_DIR",
  21. "RULE_INPUT_ROOT",
  22. "RULE_INPUT_DIRNAME",
  23. "RULE_INPUT_EXT",
  24. "RULE_INPUT_NAME",
  25. "RULE_INPUT_PATH",
  26. "SHARED_INTERMEDIATE_DIR",
  27. ]
  28. generator_default_variables = {}
  29. for v in _generator_identity_variables:
  30. generator_default_variables[v] = "<(%s)" % v
  31. def GenerateOutput(target_list, target_dicts, data, params):
  32. locals = {
  33. "target_list": target_list,
  34. "target_dicts": target_dicts,
  35. "data": data,
  36. }
  37. # Use a banner that looks like the stock Python one and like what
  38. # code.interact uses by default, but tack on something to indicate what
  39. # locals are available, and identify gypsh.
  40. banner = (
  41. f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
  42. f"{sorted(locals.keys())!r}\ngypsh"
  43. )
  44. code.interact(banner, local=locals)