"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py" (8 Mar 2017, 3426 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) 2012 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 import collections
    6 import os
    7 import gyp
    8 import gyp.common
    9 import gyp.msvs_emulation
   10 import json
   11 import sys
   12 
   13 generator_supports_multiple_toolsets = True
   14 
   15 generator_wants_static_library_dependencies_adjusted = False
   16 
   17 generator_filelist_paths = {
   18 }
   19 
   20 generator_default_variables = {
   21 }
   22 for dirname in ['INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR', 'PRODUCT_DIR',
   23                 'LIB_DIR', 'SHARED_LIB_DIR']:
   24   # Some gyp steps fail if these are empty(!).
   25   generator_default_variables[dirname] = 'dir'
   26 for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME',
   27                'RULE_INPUT_DIRNAME', 'RULE_INPUT_EXT',
   28                'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX',
   29                'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX',
   30                'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX',
   31                'CONFIGURATION_NAME']:
   32   generator_default_variables[unused] = ''
   33 
   34 
   35 def CalculateVariables(default_variables, params):
   36   generator_flags = params.get('generator_flags', {})
   37   for key, val in generator_flags.items():
   38     default_variables.setdefault(key, val)
   39   default_variables.setdefault('OS', gyp.common.GetFlavor(params))
   40 
   41   flavor = gyp.common.GetFlavor(params)
   42   if flavor =='win':
   43     # Copy additional generator configuration data from VS, which is shared
   44     # by the Windows Ninja generator.
   45     import gyp.generator.msvs as msvs_generator
   46     generator_additional_non_configuration_keys = getattr(msvs_generator,
   47         'generator_additional_non_configuration_keys', [])
   48     generator_additional_path_sections = getattr(msvs_generator,
   49         'generator_additional_path_sections', [])
   50 
   51     gyp.msvs_emulation.CalculateCommonVariables(default_variables, params)
   52 
   53 
   54 def CalculateGeneratorInputInfo(params):
   55   """Calculate the generator specific info that gets fed to input (called by
   56   gyp)."""
   57   generator_flags = params.get('generator_flags', {})
   58   if generator_flags.get('adjust_static_libraries', False):
   59     global generator_wants_static_library_dependencies_adjusted
   60     generator_wants_static_library_dependencies_adjusted = True
   61 
   62   toplevel = params['options'].toplevel_dir
   63   generator_dir = os.path.relpath(params['options'].generator_output or '.')
   64   # output_dir: relative path from generator_dir to the build directory.
   65   output_dir = generator_flags.get('output_dir', 'out')
   66   qualified_out_dir = os.path.normpath(os.path.join(
   67       toplevel, generator_dir, output_dir, 'gypfiles'))
   68   global generator_filelist_paths
   69   generator_filelist_paths = {
   70       'toplevel': toplevel,
   71       'qualified_out_dir': qualified_out_dir,
   72   }
   73 
   74 def GenerateOutput(target_list, target_dicts, data, params):
   75   # Map of target -> list of targets it depends on.
   76   edges = {}
   77 
   78   # Queue of targets to visit.
   79   targets_to_visit = target_list[:]
   80 
   81   while len(targets_to_visit) > 0:
   82     target = targets_to_visit.pop()
   83     if target in edges:
   84       continue
   85     edges[target] = []
   86 
   87     for dep in target_dicts[target].get('dependencies', []):
   88       edges[target].append(dep)
   89       targets_to_visit.append(dep)
   90 
   91   try:
   92     filepath = params['generator_flags']['output_dir']
   93   except KeyError:
   94     filepath = '.'
   95   filename = os.path.join(filepath, 'dump.json')
   96   f = open(filename, 'w')
   97   json.dump(edges, f)
   98   f.close()
   99   print 'Wrote json to %s.' % filename