"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py" (8 Mar 2017, 3474 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    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 """gypd output module
    6 
    7 This module produces gyp input as its output.  Output files are given the
    8 .gypd extension to avoid overwriting the .gyp files that they are generated
    9 from.  Internal references to .gyp files (such as those found in
   10 "dependencies" sections) are not adjusted to point to .gypd files instead;
   11 unlike other paths, which are relative to the .gyp or .gypd file, such paths
   12 are relative to the directory from which gyp was run to create the .gypd file.
   13 
   14 This generator module is intended to be a sample and a debugging aid, hence
   15 the "d" for "debug" in .gypd.  It is useful to inspect the results of the
   16 various merges, expansions, and conditional evaluations performed by gyp
   17 and to see a representation of what would be fed to a generator module.
   18 
   19 It's not advisable to rename .gypd files produced by this module to .gyp,
   20 because they will have all merges, expansions, and evaluations already
   21 performed and the relevant constructs not present in the output; paths to
   22 dependencies may be wrong; and various sections that do not belong in .gyp
   23 files such as such as "included_files" and "*_excluded" will be present.
   24 Output will also be stripped of comments.  This is not intended to be a
   25 general-purpose gyp pretty-printer; for that, you probably just want to
   26 run "pprint.pprint(eval(open('source.gyp').read()))", which will still strip
   27 comments but won't do all of the other things done to this module's output.
   28 
   29 The specific formatting of the output generated by this module is subject
   30 to change.
   31 """
   32 
   33 
   34 import gyp.common
   35 import errno
   36 import os
   37 import pprint
   38 
   39 
   40 # These variables should just be spit back out as variable references.
   41 _generator_identity_variables = [
   42   'CONFIGURATION_NAME',
   43   'EXECUTABLE_PREFIX',
   44   'EXECUTABLE_SUFFIX',
   45   'INTERMEDIATE_DIR',
   46   'LIB_DIR',
   47   'PRODUCT_DIR',
   48   'RULE_INPUT_ROOT',
   49   'RULE_INPUT_DIRNAME',
   50   'RULE_INPUT_EXT',
   51   'RULE_INPUT_NAME',
   52   'RULE_INPUT_PATH',
   53   'SHARED_INTERMEDIATE_DIR',
   54   'SHARED_LIB_DIR',
   55   'SHARED_LIB_PREFIX',
   56   'SHARED_LIB_SUFFIX',
   57   'STATIC_LIB_PREFIX',
   58   'STATIC_LIB_SUFFIX',
   59 ]
   60 
   61 # gypd doesn't define a default value for OS like many other generator
   62 # modules.  Specify "-D OS=whatever" on the command line to provide a value.
   63 generator_default_variables = {
   64 }
   65 
   66 # gypd supports multiple toolsets
   67 generator_supports_multiple_toolsets = True
   68 
   69 # TODO(mark): This always uses <, which isn't right.  The input module should
   70 # notify the generator to tell it which phase it is operating in, and this
   71 # module should use < for the early phase and then switch to > for the late
   72 # phase.  Bonus points for carrying @ back into the output too.
   73 for v in _generator_identity_variables:
   74   generator_default_variables[v] = '<(%s)' % v
   75 
   76 
   77 def GenerateOutput(target_list, target_dicts, data, params):
   78   output_files = {}
   79   for qualified_target in target_list:
   80     [input_file, target] = \
   81         gyp.common.ParseQualifiedTarget(qualified_target)[0:2]
   82 
   83     if input_file[-4:] != '.gyp':
   84       continue
   85     input_file_stem = input_file[:-4]
   86     output_file = input_file_stem + params['options'].suffix + '.gypd'
   87 
   88     if not output_file in output_files:
   89       output_files[output_file] = input_file
   90 
   91   for output_file, input_file in output_files.iteritems():
   92     output = open(output_file, 'w')
   93     pprint.pprint(data[input_file], output)
   94     output.close()