"Fossies" - the Fresh Open Source Software Archive

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