OLD | NEW |
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 collections | 5 import collections |
6 import copy | 6 import copy |
7 import hashlib | 7 import hashlib |
8 import json | 8 import json |
9 import multiprocessing | 9 import multiprocessing |
10 import os.path | 10 import os.path |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 649 |
650 # Rules can potentially make use of some special variables which | 650 # Rules can potentially make use of some special variables which |
651 # must vary per source file. | 651 # must vary per source file. |
652 # Compute the list of variables we'll need to provide. | 652 # Compute the list of variables we'll need to provide. |
653 special_locals = ('source', 'root', 'dirname', 'ext', 'name') | 653 special_locals = ('source', 'root', 'dirname', 'ext', 'name') |
654 needed_variables = set(['source']) | 654 needed_variables = set(['source']) |
655 for argument in args: | 655 for argument in args: |
656 for var in special_locals: | 656 for var in special_locals: |
657 if '${%s}' % var in argument: | 657 if '${%s}' % var in argument: |
658 needed_variables.add(var) | 658 needed_variables.add(var) |
| 659 needed_variables = sorted(needed_variables) |
659 | 660 |
660 def cygwin_munge(path): | 661 def cygwin_munge(path): |
661 # pylint: disable=cell-var-from-loop | 662 # pylint: disable=cell-var-from-loop |
662 if is_cygwin: | 663 if is_cygwin: |
663 return path.replace('\\', '/') | 664 return path.replace('\\', '/') |
664 return path | 665 return path |
665 | 666 |
666 inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])] | 667 inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])] |
667 | 668 |
668 # If there are n source files matching the rule, and m additional rule | 669 # If there are n source files matching the rule, and m additional rule |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 elif var == 'name': | 723 elif var == 'name': |
723 extra_bindings.append(('name', cygwin_munge(basename))) | 724 extra_bindings.append(('name', cygwin_munge(basename))) |
724 else: | 725 else: |
725 assert var == None, repr(var) | 726 assert var == None, repr(var) |
726 | 727 |
727 outputs = [self.GypPathToNinja(o, env) for o in outputs] | 728 outputs = [self.GypPathToNinja(o, env) for o in outputs] |
728 if self.flavor == 'win': | 729 if self.flavor == 'win': |
729 # WriteNewNinjaRule uses unique_name for creating an rsp file on win. | 730 # WriteNewNinjaRule uses unique_name for creating an rsp file on win. |
730 extra_bindings.append(('unique_name', | 731 extra_bindings.append(('unique_name', |
731 hashlib.md5(outputs[0]).hexdigest())) | 732 hashlib.md5(outputs[0]).hexdigest())) |
| 733 |
732 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), | 734 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), |
733 implicit=inputs, | 735 implicit=inputs, |
734 order_only=prebuild, | 736 order_only=prebuild, |
735 variables=extra_bindings) | 737 variables=extra_bindings) |
736 | 738 |
737 all_outputs.extend(outputs) | 739 all_outputs.extend(outputs) |
738 | 740 |
739 return all_outputs | 741 return all_outputs |
740 | 742 |
741 def WriteCopies(self, copies, prebuild, mac_bundle_depends): | 743 def WriteCopies(self, copies, prebuild, mac_bundle_depends): |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 command = command + '_notoc' | 1247 command = command + '_notoc' |
1246 elif self.flavor == 'win': | 1248 elif self.flavor == 'win': |
1247 extra_bindings.append(('binary', output)) | 1249 extra_bindings.append(('binary', output)) |
1248 pdbname = self.msvs_settings.GetPDBName( | 1250 pdbname = self.msvs_settings.GetPDBName( |
1249 config_name, self.ExpandSpecial, output + '.pdb') | 1251 config_name, self.ExpandSpecial, output + '.pdb') |
1250 if pdbname: | 1252 if pdbname: |
1251 output = [output, pdbname] | 1253 output = [output, pdbname] |
1252 | 1254 |
1253 | 1255 |
1254 if len(solibs): | 1256 if len(solibs): |
1255 extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) | 1257 extra_bindings.append(('solibs', |
| 1258 gyp.common.EncodePOSIXShellList(sorted(solibs)))) |
1256 | 1259 |
1257 ninja_file.build(output, command + command_suffix, link_deps, | 1260 ninja_file.build(output, command + command_suffix, link_deps, |
1258 implicit=list(implicit_deps), | 1261 implicit=sorted(implicit_deps), |
1259 order_only=list(order_deps), | 1262 order_only=list(order_deps), |
1260 variables=extra_bindings) | 1263 variables=extra_bindings) |
1261 return linked_binary | 1264 return linked_binary |
1262 | 1265 |
1263 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): | 1266 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): |
1264 extra_link_deps = any(self.target_outputs.get(dep).Linkable() | 1267 extra_link_deps = any(self.target_outputs.get(dep).Linkable() |
1265 for dep in spec.get('dependencies', []) | 1268 for dep in spec.get('dependencies', []) |
1266 if dep in self.target_outputs) | 1269 if dep in self.target_outputs) |
1267 if spec['type'] == 'none' or (not link_deps and not extra_link_deps): | 1270 if spec['type'] == 'none' or (not link_deps and not extra_link_deps): |
1268 # TODO(evan): don't call this function for 'none' target types, as | 1271 # TODO(evan): don't call this function for 'none' target types, as |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 if flavor == 'win': | 1897 if flavor == 'win': |
1895 configs = [target_dicts[qualified_target]['configurations'][config_name] | 1898 configs = [target_dicts[qualified_target]['configurations'][config_name] |
1896 for qualified_target in target_list] | 1899 for qualified_target in target_list] |
1897 shared_system_includes = None | 1900 shared_system_includes = None |
1898 if not generator_flags.get('ninja_use_custom_environment_files', 0): | 1901 if not generator_flags.get('ninja_use_custom_environment_files', 0): |
1899 shared_system_includes = \ | 1902 shared_system_includes = \ |
1900 gyp.msvs_emulation.ExtractSharedMSVSSystemIncludes( | 1903 gyp.msvs_emulation.ExtractSharedMSVSSystemIncludes( |
1901 configs, generator_flags) | 1904 configs, generator_flags) |
1902 cl_paths = gyp.msvs_emulation.GenerateEnvironmentFiles( | 1905 cl_paths = gyp.msvs_emulation.GenerateEnvironmentFiles( |
1903 toplevel_build, generator_flags, shared_system_includes, OpenOutput) | 1906 toplevel_build, generator_flags, shared_system_includes, OpenOutput) |
1904 for arch, path in cl_paths.iteritems(): | 1907 for arch, path in sorted(cl_paths.iteritems()): |
1905 if clang_cl: | 1908 if clang_cl: |
1906 # If we have selected clang-cl, use that instead. | 1909 # If we have selected clang-cl, use that instead. |
1907 path = clang_cl | 1910 path = clang_cl |
1908 command = CommandWithWrapper('CC', wrappers, | 1911 command = CommandWithWrapper('CC', wrappers, |
1909 QuoteShellArgument(path, 'win')) | 1912 QuoteShellArgument(path, 'win')) |
1910 if clang_cl: | 1913 if clang_cl: |
1911 # Use clang-cl to cross-compile for x86 or x86_64. | 1914 # Use clang-cl to cross-compile for x86 or x86_64. |
1912 command += (' -m32' if arch == 'x86' else ' -m64') | 1915 command += (' -m32' if arch == 'x86' else ' -m64') |
1913 master_ninja.variable('cl_' + arch, command) | 1916 master_ninja.variable('cl_' + arch, command) |
1914 | 1917 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 non_empty_target_names.add(name) | 2333 non_empty_target_names.add(name) |
2331 else: | 2334 else: |
2332 empty_target_names.add(name) | 2335 empty_target_names.add(name) |
2333 | 2336 |
2334 if target_short_names: | 2337 if target_short_names: |
2335 # Write a short name to build this target. This benefits both the | 2338 # Write a short name to build this target. This benefits both the |
2336 # "build chrome" case as well as the gyp tests, which expect to be | 2339 # "build chrome" case as well as the gyp tests, which expect to be |
2337 # able to run actions and build libraries by their short name. | 2340 # able to run actions and build libraries by their short name. |
2338 master_ninja.newline() | 2341 master_ninja.newline() |
2339 master_ninja.comment('Short names for targets.') | 2342 master_ninja.comment('Short names for targets.') |
2340 for short_name in target_short_names: | 2343 for short_name in sorted(target_short_names): |
2341 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in | 2344 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in |
2342 target_short_names[short_name]]) | 2345 target_short_names[short_name]]) |
2343 | 2346 |
2344 # Write phony targets for any empty targets that weren't written yet. As | 2347 # Write phony targets for any empty targets that weren't written yet. As |
2345 # short names are not necessarily unique only do this for short names that | 2348 # short names are not necessarily unique only do this for short names that |
2346 # haven't already been output for another target. | 2349 # haven't already been output for another target. |
2347 empty_target_names = empty_target_names - non_empty_target_names | 2350 empty_target_names = empty_target_names - non_empty_target_names |
2348 if empty_target_names: | 2351 if empty_target_names: |
2349 master_ninja.newline() | 2352 master_ninja.newline() |
2350 master_ninja.comment('Empty targets (output for completeness).') | 2353 master_ninja.comment('Empty targets (output for completeness).') |
2351 for name in sorted(empty_target_names): | 2354 for name in sorted(empty_target_names): |
2352 master_ninja.build(name, 'phony') | 2355 master_ninja.build(name, 'phony') |
2353 | 2356 |
2354 if all_outputs: | 2357 if all_outputs: |
2355 master_ninja.newline() | 2358 master_ninja.newline() |
2356 master_ninja.build('all', 'phony', list(all_outputs)) | 2359 master_ninja.build('all', 'phony', sorted(all_outputs)) |
2357 master_ninja.default(generator_flags.get('default_target', 'all')) | 2360 master_ninja.default(generator_flags.get('default_target', 'all')) |
2358 | 2361 |
2359 master_ninja_file.close() | 2362 master_ninja_file.close() |
2360 | 2363 |
2361 | 2364 |
2362 def PerformBuild(data, configurations, params): | 2365 def PerformBuild(data, configurations, params): |
2363 options = params['options'] | 2366 options = params['options'] |
2364 for config in configurations: | 2367 for config in configurations: |
2365 builddir = os.path.join(options.toplevel_dir, 'out', config) | 2368 builddir = os.path.join(options.toplevel_dir, 'out', config) |
2366 arguments = ['ninja', '-C', builddir] | 2369 arguments = ['ninja', '-C', builddir] |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 arglists.append( | 2404 arglists.append( |
2402 (target_list, target_dicts, data, params, config_name)) | 2405 (target_list, target_dicts, data, params, config_name)) |
2403 pool.map(CallGenerateOutputForConfig, arglists) | 2406 pool.map(CallGenerateOutputForConfig, arglists) |
2404 except KeyboardInterrupt, e: | 2407 except KeyboardInterrupt, e: |
2405 pool.terminate() | 2408 pool.terminate() |
2406 raise e | 2409 raise e |
2407 else: | 2410 else: |
2408 for config_name in config_names: | 2411 for config_name in config_names: |
2409 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2412 GenerateOutputForConfig(target_list, target_dicts, data, params, |
2410 config_name) | 2413 config_name) |
OLD | NEW |