11cb0ef41Sopenharmony_ci# Copyright (c) 2011 Google Inc. All rights reserved. 21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci# found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci"""gypsh output module 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_cigypsh is a GYP shell. It's not really a generator per se. All it does is 81cb0ef41Sopenharmony_cifire up an interactive Python session with a few local variables set to the 91cb0ef41Sopenharmony_civariables passed to the generator. Like gypd, it's intended as a debugging 101cb0ef41Sopenharmony_ciaid, to facilitate the exploration of .gyp structures after being processed 111cb0ef41Sopenharmony_ciby the input module. 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciThe expected usage is "gyp -f gypsh -D OS=desired_os". 141cb0ef41Sopenharmony_ci""" 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciimport code 181cb0ef41Sopenharmony_ciimport sys 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci# All of this stuff about generator variables was lovingly ripped from gypd.py. 221cb0ef41Sopenharmony_ci# That module has a much better description of what's going on and why. 231cb0ef41Sopenharmony_ci_generator_identity_variables = [ 241cb0ef41Sopenharmony_ci "EXECUTABLE_PREFIX", 251cb0ef41Sopenharmony_ci "EXECUTABLE_SUFFIX", 261cb0ef41Sopenharmony_ci "INTERMEDIATE_DIR", 271cb0ef41Sopenharmony_ci "PRODUCT_DIR", 281cb0ef41Sopenharmony_ci "RULE_INPUT_ROOT", 291cb0ef41Sopenharmony_ci "RULE_INPUT_DIRNAME", 301cb0ef41Sopenharmony_ci "RULE_INPUT_EXT", 311cb0ef41Sopenharmony_ci "RULE_INPUT_NAME", 321cb0ef41Sopenharmony_ci "RULE_INPUT_PATH", 331cb0ef41Sopenharmony_ci "SHARED_INTERMEDIATE_DIR", 341cb0ef41Sopenharmony_ci] 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_cigenerator_default_variables = {} 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cifor v in _generator_identity_variables: 391cb0ef41Sopenharmony_ci generator_default_variables[v] = "<(%s)" % v 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_cidef GenerateOutput(target_list, target_dicts, data, params): 431cb0ef41Sopenharmony_ci locals = { 441cb0ef41Sopenharmony_ci "target_list": target_list, 451cb0ef41Sopenharmony_ci "target_dicts": target_dicts, 461cb0ef41Sopenharmony_ci "data": data, 471cb0ef41Sopenharmony_ci } 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci # Use a banner that looks like the stock Python one and like what 501cb0ef41Sopenharmony_ci # code.interact uses by default, but tack on something to indicate what 511cb0ef41Sopenharmony_ci # locals are available, and identify gypsh. 521cb0ef41Sopenharmony_ci banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format( 531cb0ef41Sopenharmony_ci sys.version, 541cb0ef41Sopenharmony_ci sys.platform, 551cb0ef41Sopenharmony_ci repr(sorted(locals.keys())), 561cb0ef41Sopenharmony_ci ) 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci code.interact(banner, local=locals) 59