michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: import collections michael@0: import os michael@0: import gyp michael@0: import gyp.common michael@0: import gyp.msvs_emulation michael@0: import json michael@0: import sys michael@0: michael@0: generator_supports_multiple_toolsets = True michael@0: michael@0: generator_wants_static_library_dependencies_adjusted = False michael@0: michael@0: generator_default_variables = { michael@0: } michael@0: for dirname in ['INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR', 'PRODUCT_DIR', michael@0: 'LIB_DIR', 'SHARED_LIB_DIR']: michael@0: # Some gyp steps fail if these are empty(!). michael@0: generator_default_variables[dirname] = 'dir' michael@0: for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME', michael@0: 'RULE_INPUT_DIRNAME', 'RULE_INPUT_EXT', michael@0: 'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX', michael@0: 'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX', michael@0: 'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX', michael@0: 'CONFIGURATION_NAME']: michael@0: generator_default_variables[unused] = '' michael@0: michael@0: michael@0: def CalculateVariables(default_variables, params): michael@0: generator_flags = params.get('generator_flags', {}) michael@0: for key, val in generator_flags.items(): michael@0: default_variables.setdefault(key, val) michael@0: default_variables.setdefault('OS', gyp.common.GetFlavor(params)) michael@0: michael@0: flavor = gyp.common.GetFlavor(params) michael@0: if flavor =='win': michael@0: # Copy additional generator configuration data from VS, which is shared michael@0: # by the Windows Ninja generator. michael@0: import gyp.generator.msvs as msvs_generator michael@0: generator_additional_non_configuration_keys = getattr(msvs_generator, michael@0: 'generator_additional_non_configuration_keys', []) michael@0: generator_additional_path_sections = getattr(msvs_generator, michael@0: 'generator_additional_path_sections', []) michael@0: michael@0: gyp.msvs_emulation.CalculateCommonVariables(default_variables, params) michael@0: michael@0: michael@0: def CalculateGeneratorInputInfo(params): michael@0: """Calculate the generator specific info that gets fed to input (called by michael@0: gyp).""" michael@0: generator_flags = params.get('generator_flags', {}) michael@0: if generator_flags.get('adjust_static_libraries', False): michael@0: global generator_wants_static_library_dependencies_adjusted michael@0: generator_wants_static_library_dependencies_adjusted = True michael@0: michael@0: def GetOS(params): michael@0: for d in params['defines']: michael@0: pass michael@0: michael@0: def GenerateOutput(target_list, target_dicts, data, params): michael@0: # Map of target -> list of targets it depends on. michael@0: edges = {} michael@0: michael@0: # Queue of targets to visit. michael@0: targets_to_visit = target_list[:] michael@0: michael@0: sources = []; michael@0: michael@0: while len(targets_to_visit) > 0: michael@0: target = targets_to_visit.pop() michael@0: if target in edges: michael@0: continue michael@0: edges[target] = [] michael@0: michael@0: target_sources = target_dicts[target].get('sources') michael@0: if target_sources: michael@0: for source in target_sources: michael@0: if source.endswith('.cpp'): michael@0: sources.append(source) michael@0: michael@0: for dep in target_dicts[target].get('dependencies', []): michael@0: edges[target].append(dep) michael@0: targets_to_visit.append(dep) michael@0: michael@0: skia_os = data['gyp/core.gyp']['variables']['skia_os%'] michael@0: michael@0: f = open('sources.json', 'w') michael@0: json.dump(sources, f) michael@0: f.close()