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 5"""gypsh output module 6 7gypsh is a GYP shell. It's not really a generator per se. All it does is 8fire up an interactive Python session with a few local variables set to the 9variables passed to the generator. Like gypd, it's intended as a debugging 10aid, to facilitate the exploration of .gyp structures after being processed 11by the input module. 12 13The expected usage is "gyp -f gypsh -D OS=desired_os". 14""" 15 16 17import code 18import sys 19 20 21# All of this stuff about generator variables was lovingly ripped from gypd.py. 22# That module has a much better description of what's going on and why. 23_generator_identity_variables = [ 24 "EXECUTABLE_PREFIX", 25 "EXECUTABLE_SUFFIX", 26 "INTERMEDIATE_DIR", 27 "PRODUCT_DIR", 28 "RULE_INPUT_ROOT", 29 "RULE_INPUT_DIRNAME", 30 "RULE_INPUT_EXT", 31 "RULE_INPUT_NAME", 32 "RULE_INPUT_PATH", 33 "SHARED_INTERMEDIATE_DIR", 34] 35 36generator_default_variables = {} 37 38for v in _generator_identity_variables: 39 generator_default_variables[v] = "<(%s)" % v 40 41 42def GenerateOutput(target_list, target_dicts, data, params): 43 locals = { 44 "target_list": target_list, 45 "target_dicts": target_dicts, 46 "data": data, 47 } 48 49 # Use a banner that looks like the stock Python one and like what 50 # code.interact uses by default, but tack on something to indicate what 51 # locals are available, and identify gypsh. 52 banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format( 53 sys.version, 54 sys.platform, 55 repr(sorted(locals.keys())), 56 ) 57 58 code.interact(banner, local=locals) 59