Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 27353003: Adds the ability to skip includes. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pylib/gyp/input.py » ('j') | pylib/gyp/input.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import copy 5 import copy
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import multiprocessing 8 import multiprocessing
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 # - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file) 205 # - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file)
206 # into the equivalent ninja path. 206 # into the equivalent ninja path.
207 # 207 #
208 # - GypPathToUniqueOutput translates a gyp path into a ninja path to write 208 # - GypPathToUniqueOutput translates a gyp path into a ninja path to write
209 # an output file; the result can be namespaced such that it is unique 209 # an output file; the result can be namespaced such that it is unique
210 # to the input file name as well as the output target name. 210 # to the input file name as well as the output target name.
211 211
212 class NinjaWriter: 212 class NinjaWriter:
213 def __init__(self, qualified_target, target_outputs, base_dir, build_dir, 213 def __init__(self, qualified_target, target_outputs, base_dir, build_dir,
214 output_file, toplevel_build, output_file_name, flavor, 214 output_file, toplevel_build, output_file_name, flavor,
215 deps_file=None, toplevel_dir=None): 215 toplevel_dir=None):
216 """ 216 """
217 base_dir: path from source root to directory containing this gyp file, 217 base_dir: path from source root to directory containing this gyp file,
218 by gyp semantics, all input paths are relative to this 218 by gyp semantics, all input paths are relative to this
219 build_dir: path from source root to build output 219 build_dir: path from source root to build output
220 toplevel_dir: path to the toplevel directory 220 toplevel_dir: path to the toplevel directory
221 """ 221 """
222 222
223 self.qualified_target = qualified_target 223 self.qualified_target = qualified_target
224 self.target_outputs = target_outputs 224 self.target_outputs = target_outputs
225 self.base_dir = base_dir 225 self.base_dir = base_dir
(...skipping 13 matching lines...) Expand all
239 self.win_env = {} 239 self.win_env = {}
240 for arch in ('x86', 'x64'): 240 for arch in ('x86', 'x64'):
241 self.win_env[arch] = 'environment.' + arch 241 self.win_env[arch] = 'environment.' + arch
242 242
243 # Relative path from build output dir to base dir. 243 # Relative path from build output dir to base dir.
244 build_to_top = gyp.common.InvertRelativePath(build_dir, toplevel_dir) 244 build_to_top = gyp.common.InvertRelativePath(build_dir, toplevel_dir)
245 self.build_to_base = os.path.join(build_to_top, base_dir) 245 self.build_to_base = os.path.join(build_to_top, base_dir)
246 # Relative path from base dir to build dir. 246 # Relative path from base dir to build dir.
247 base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir) 247 base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir)
248 self.base_to_build = os.path.join(base_to_top, build_dir) 248 self.base_to_build = os.path.join(base_to_top, build_dir)
249 self.link_deps_file = deps_file
250 249
251 def ExpandSpecial(self, path, product_dir=None): 250 def ExpandSpecial(self, path, product_dir=None):
252 """Expand specials like $!PRODUCT_DIR in |path|. 251 """Expand specials like $!PRODUCT_DIR in |path|.
253 252
254 If |product_dir| is None, assumes the cwd is already the product 253 If |product_dir| is None, assumes the cwd is already the product
255 dir. Otherwise, |product_dir| is the relative path to the product 254 dir. Otherwise, |product_dir| is the relative path to the product
256 dir. 255 dir.
257 """ 256 """
258 257
259 PRODUCT_DIR = '$!PRODUCT_DIR' 258 PRODUCT_DIR = '$!PRODUCT_DIR'
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 # - Linkable dependencies (like a .a or a .so): add them to the link line. 977 # - Linkable dependencies (like a .a or a .so): add them to the link line.
979 # - Non-linkable dependencies (like a rule that generates a file 978 # - Non-linkable dependencies (like a rule that generates a file
980 # and writes a stamp file): add them to implicit_deps 979 # and writes a stamp file): add them to implicit_deps
981 extra_link_deps = set() 980 extra_link_deps = set()
982 for dep in spec['dependencies']: 981 for dep in spec['dependencies']:
983 target = self.target_outputs.get(dep) 982 target = self.target_outputs.get(dep)
984 if not target: 983 if not target:
985 continue 984 continue
986 linkable = target.Linkable() 985 linkable = target.Linkable()
987 if linkable: 986 if linkable:
988 if self.link_deps_file:
989 # Save the mapping of link deps.
990 self.link_deps_file.write(self.qualified_target)
991 self.link_deps_file.write(' ')
992 self.link_deps_file.write(target.binary)
993 self.link_deps_file.write('\n')
994
995 new_deps = [] 987 new_deps = []
996 if (self.flavor == 'win' and 988 if (self.flavor == 'win' and
997 target.component_objs and 989 target.component_objs and
998 self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): 990 self.msvs_settings.IsUseLibraryDependencyInputs(config_name)):
999 new_deps = target.component_objs 991 new_deps = target.component_objs
1000 elif self.flavor == 'win' and target.import_lib: 992 elif self.flavor == 'win' and target.import_lib:
1001 new_deps = [target.import_lib] 993 new_deps = [target.import_lib]
1002 elif target.UsesToc(self.flavor): 994 elif target.UsesToc(self.flavor):
1003 solibs.add(target.binary) 995 solibs.add(target.binary)
1004 implicit_deps.add(target.binary + '.TOC') 996 implicit_deps.add(target.binary + '.TOC')
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 os.path.normpath(build_file)): 2001 os.path.normpath(build_file)):
2010 all_targets.add(target) 2002 all_targets.add(target)
2011 all_outputs = set() 2003 all_outputs = set()
2012 2004
2013 # target_outputs is a map from qualified target name to a Target object. 2005 # target_outputs is a map from qualified target name to a Target object.
2014 target_outputs = {} 2006 target_outputs = {}
2015 # target_short_names is a map from target short name to a list of Target 2007 # target_short_names is a map from target short name to a list of Target
2016 # objects. 2008 # objects.
2017 target_short_names = {} 2009 target_short_names = {}
2018 2010
2019 # Extract the optional link deps file name.
2020 LINK_DEPS_FILE = 'link_deps_file'
2021 if LINK_DEPS_FILE in generator_flags:
2022 link_deps_file = open(generator_flags.get(LINK_DEPS_FILE), 'wb')
2023 else:
2024 link_deps_file = None
2025
2026 for qualified_target in target_list: 2011 for qualified_target in target_list:
2027 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target 2012 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target
2028 build_file, name, toolset = \ 2013 build_file, name, toolset = \
2029 gyp.common.ParseQualifiedTarget(qualified_target) 2014 gyp.common.ParseQualifiedTarget(qualified_target)
2030 2015
2031 this_make_global_settings = data[build_file].get('make_global_settings', []) 2016 this_make_global_settings = data[build_file].get('make_global_settings', [])
2032 assert make_global_settings == this_make_global_settings, ( 2017 assert make_global_settings == this_make_global_settings, (
2033 "make_global_settings needs to be the same for all targets.") 2018 "make_global_settings needs to be the same for all targets.")
2034 2019
2035 spec = target_dicts[qualified_target] 2020 spec = target_dicts[qualified_target]
2036 if flavor == 'mac': 2021 if flavor == 'mac':
2037 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) 2022 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec)
2038 2023
2039 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir) 2024 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir)
2040 2025
2041 base_path = os.path.dirname(build_file) 2026 base_path = os.path.dirname(build_file)
2042 obj = 'obj' 2027 obj = 'obj'
2043 if toolset != 'target': 2028 if toolset != 'target':
2044 obj += '.' + toolset 2029 obj += '.' + toolset
2045 output_file = os.path.join(obj, base_path, name + '.ninja') 2030 output_file = os.path.join(obj, base_path, name + '.ninja')
2046 2031
2047 ninja_output = StringIO() 2032 ninja_output = StringIO()
2048 writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir, 2033 writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir,
2049 ninja_output, 2034 ninja_output,
2050 toplevel_build, output_file, 2035 toplevel_build, output_file,
2051 flavor, link_deps_file, 2036 flavor, toplevel_dir=options.toplevel_dir)
2052 toplevel_dir=options.toplevel_dir)
2053 2037
2054 target = writer.WriteSpec(spec, config_name, generator_flags) 2038 target = writer.WriteSpec(spec, config_name, generator_flags)
2055 2039
2056 if ninja_output.tell() > 0: 2040 if ninja_output.tell() > 0:
2057 # Only create files for ninja files that actually have contents. 2041 # Only create files for ninja files that actually have contents.
2058 with OpenOutput(os.path.join(toplevel_build, output_file)) as ninja_file: 2042 with OpenOutput(os.path.join(toplevel_build, output_file)) as ninja_file:
2059 ninja_file.write(ninja_output.getvalue()) 2043 ninja_file.write(ninja_output.getvalue())
2060 ninja_output.close() 2044 ninja_output.close()
2061 master_ninja.subninja(output_file) 2045 master_ninja.subninja(output_file)
2062 2046
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 arglists.append( 2109 arglists.append(
2126 (target_list, target_dicts, data, params, config_name)) 2110 (target_list, target_dicts, data, params, config_name))
2127 pool.map(CallGenerateOutputForConfig, arglists) 2111 pool.map(CallGenerateOutputForConfig, arglists)
2128 except KeyboardInterrupt, e: 2112 except KeyboardInterrupt, e:
2129 pool.terminate() 2113 pool.terminate()
2130 raise e 2114 raise e
2131 else: 2115 else:
2132 for config_name in config_names: 2116 for config_name in config_names:
2133 GenerateOutputForConfig(target_list, target_dicts, data, params, 2117 GenerateOutputForConfig(target_list, target_dicts, data, params,
2134 config_name) 2118 config_name)
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/input.py » ('j') | pylib/gyp/input.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698