OLD | NEW |
---|---|
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 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 os.path | 7 import os.path |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 | 347 |
348 assert targets == filter(None, targets), targets | 348 assert targets == filter(None, targets), targets |
349 if len(targets) == 0: | 349 if len(targets) == 0: |
350 return None | 350 return None |
351 if len(targets) > 1: | 351 if len(targets) > 1: |
352 stamp = self.GypPathToUniqueOutput(name + '.stamp') | 352 stamp = self.GypPathToUniqueOutput(name + '.stamp') |
353 targets = self.ninja.build(stamp, 'stamp', targets) | 353 targets = self.ninja.build(stamp, 'stamp', targets) |
354 self.ninja.newline() | 354 self.ninja.newline() |
355 return targets[0] | 355 return targets[0] |
356 | 356 |
357 def WriteSpec(self, spec, config_name, generator_flags): | 357 def WriteSpec(self, spec, config_name, generator_flags, |
358 case_sensitive_filesystem): | |
M-A Ruel
2012/09/10 14:03:13
Sorry I'm not familiar with the code so the questi
| |
358 """The main entry point for NinjaWriter: write the build rules for a spec. | 359 """The main entry point for NinjaWriter: write the build rules for a spec. |
359 | 360 |
360 Returns a Target object, which represents the output paths for this spec. | 361 Returns a Target object, which represents the output paths for this spec. |
361 Returns None if there are no outputs (e.g. a settings-only 'none' type | 362 Returns None if there are no outputs (e.g. a settings-only 'none' type |
362 target).""" | 363 target).""" |
363 | 364 |
364 self.config_name = config_name | 365 self.config_name = config_name |
365 self.name = spec['target_name'] | 366 self.name = spec['target_name'] |
366 self.toolset = spec['toolset'] | 367 self.toolset = spec['toolset'] |
367 config = spec['configurations'][config_name] | 368 config = spec['configurations'][config_name] |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 if sources: | 422 if sources: |
422 pch = None | 423 pch = None |
423 if self.flavor == 'win': | 424 if self.flavor == 'win': |
424 pch = gyp.msvs_emulation.PrecompiledHeader( | 425 pch = gyp.msvs_emulation.PrecompiledHeader( |
425 self.msvs_settings, config_name, self.GypPathToNinja) | 426 self.msvs_settings, config_name, self.GypPathToNinja) |
426 else: | 427 else: |
427 pch = gyp.xcode_emulation.MacPrefixHeader( | 428 pch = gyp.xcode_emulation.MacPrefixHeader( |
428 self.xcode_settings, self.GypPathToNinja, | 429 self.xcode_settings, self.GypPathToNinja, |
429 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) | 430 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) |
430 link_deps = self.WriteSources( | 431 link_deps = self.WriteSources( |
431 config_name, config, sources, compile_depends_stamp, pch) | 432 config_name, config, sources, compile_depends_stamp, pch, |
433 case_sensitive_filesystem) | |
432 # Some actions/rules output 'sources' that are already object files. | 434 # Some actions/rules output 'sources' that are already object files. |
433 link_deps += [self.GypPathToNinja(f) | 435 link_deps += [self.GypPathToNinja(f) |
434 for f in sources if f.endswith(self.obj_ext)] | 436 for f in sources if f.endswith(self.obj_ext)] |
435 | 437 |
436 if self.flavor == 'win' and self.target.type == 'static_library': | 438 if self.flavor == 'win' and self.target.type == 'static_library': |
437 self.target.component_objs = link_deps | 439 self.target.component_objs = link_deps |
438 | 440 |
439 # Write out a link step, if needed. | 441 # Write out a link step, if needed. |
440 output = None | 442 output = None |
441 if link_deps or self.target.actions_stamp or actions_depends: | 443 if link_deps or self.target.actions_stamp or actions_depends: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 | 700 |
699 env = self.GetSortedXcodeEnv(additional_settings=extra_env) | 701 env = self.GetSortedXcodeEnv(additional_settings=extra_env) |
700 env = self.ComputeExportEnvString(env) | 702 env = self.ComputeExportEnvString(env) |
701 | 703 |
702 self.ninja.build(out, 'mac_tool', info_plist, | 704 self.ninja.build(out, 'mac_tool', info_plist, |
703 variables=[('mactool_cmd', 'copy-info-plist'), | 705 variables=[('mactool_cmd', 'copy-info-plist'), |
704 ('env', env)]) | 706 ('env', env)]) |
705 bundle_depends.append(out) | 707 bundle_depends.append(out) |
706 | 708 |
707 def WriteSources(self, config_name, config, sources, predepends, | 709 def WriteSources(self, config_name, config, sources, predepends, |
708 precompiled_header): | 710 precompiled_header, case_sensitive_filesystem): |
709 """Write build rules to compile all of |sources|.""" | 711 """Write build rules to compile all of |sources|.""" |
710 if self.toolset == 'host': | 712 if self.toolset == 'host': |
711 self.ninja.variable('ar', '$ar_host') | 713 self.ninja.variable('ar', '$ar_host') |
712 self.ninja.variable('cc', '$cc_host') | 714 self.ninja.variable('cc', '$cc_host') |
713 self.ninja.variable('cxx', '$cxx_host') | 715 self.ninja.variable('cxx', '$cxx_host') |
714 self.ninja.variable('ld', '$ld_host') | 716 self.ninja.variable('ld', '$ld_host') |
715 | 717 |
716 extra_defines = [] | 718 extra_defines = [] |
717 if self.flavor == 'mac': | 719 if self.flavor == 'mac': |
718 cflags = self.xcode_settings.GetCflags(config_name) | 720 cflags = self.xcode_settings.GetCflags(config_name) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 elif self.flavor == 'mac' and ext == 'mm': | 793 elif self.flavor == 'mac' and ext == 'mm': |
792 command = 'objcxx' | 794 command = 'objcxx' |
793 elif self.flavor == 'win' and ext == 'rc': | 795 elif self.flavor == 'win' and ext == 'rc': |
794 command = 'rc' | 796 command = 'rc' |
795 obj_ext = '.res' | 797 obj_ext = '.res' |
796 else: | 798 else: |
797 # Ignore unhandled extensions. | 799 # Ignore unhandled extensions. |
798 continue | 800 continue |
799 input = self.GypPathToNinja(source) | 801 input = self.GypPathToNinja(source) |
800 output = self.GypPathToUniqueOutput(filename + obj_ext) | 802 output = self.GypPathToUniqueOutput(filename + obj_ext) |
803 # Ninja's depfile handling gets confused when the case of a filename | |
804 # changes on a case-insensitive file system. To work around that, always | |
805 # convert .o filenames to lowercase on such file systems. See | |
806 # https://github.com/martine/ninja/issues/402 for details. | |
807 if not case_sensitive_filesystem: | |
808 output = output.lower() | |
801 implicit = precompiled_header.GetObjDependencies([input], [output]) | 809 implicit = precompiled_header.GetObjDependencies([input], [output]) |
802 self.ninja.build(output, command, input, | 810 self.ninja.build(output, command, input, |
803 implicit=[gch for _, _, gch in implicit], | 811 implicit=[gch for _, _, gch in implicit], |
804 order_only=predepends) | 812 order_only=predepends) |
805 outputs.append(output) | 813 outputs.append(output) |
806 | 814 |
807 self.WritePchTargets(pch_commands) | 815 self.WritePchTargets(pch_commands) |
808 | 816 |
809 self.ninja.newline() | 817 self.ninja.newline() |
810 return outputs | 818 return outputs |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 # build_dir: relative path from source root to our output files. | 1297 # build_dir: relative path from source root to our output files. |
1290 # e.g. "out/Debug" | 1298 # e.g. "out/Debug" |
1291 build_dir = os.path.join(generator_flags.get('output_dir', 'out'), | 1299 build_dir = os.path.join(generator_flags.get('output_dir', 'out'), |
1292 config_name) | 1300 config_name) |
1293 | 1301 |
1294 toplevel_build = os.path.join(options.toplevel_dir, build_dir) | 1302 toplevel_build = os.path.join(options.toplevel_dir, build_dir) |
1295 | 1303 |
1296 master_ninja = ninja_syntax.Writer( | 1304 master_ninja = ninja_syntax.Writer( |
1297 OpenOutput(os.path.join(toplevel_build, 'build.ninja')), | 1305 OpenOutput(os.path.join(toplevel_build, 'build.ninja')), |
1298 width=120) | 1306 width=120) |
1307 case_sensitive_filesystem = not os.path.exists( | |
1308 os.path.join(toplevel_build, 'BUILD.NINJA')) | |
M-A Ruel
2012/09/10 14:03:13
<3 that's a good idea.
| |
1299 | 1309 |
1300 # Put build-time support tools in out/{config_name}. | 1310 # Put build-time support tools in out/{config_name}. |
1301 gyp.common.CopyTool(flavor, toplevel_build) | 1311 gyp.common.CopyTool(flavor, toplevel_build) |
1302 | 1312 |
1303 # Grab make settings for CC/CXX. | 1313 # Grab make settings for CC/CXX. |
1304 # The rules are | 1314 # The rules are |
1305 # - The priority from low to high is gcc/g++, the 'make_global_settings' in | 1315 # - The priority from low to high is gcc/g++, the 'make_global_settings' in |
1306 # gyp, the environment variable. | 1316 # gyp, the environment variable. |
1307 # - If there is no 'make_global_settings' for CC.host/CXX.host or | 1317 # - If there is no 'make_global_settings' for CC.host/CXX.host or |
1308 # 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set | 1318 # 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1675 if toolset != 'target': | 1685 if toolset != 'target': |
1676 obj += '.' + toolset | 1686 obj += '.' + toolset |
1677 output_file = os.path.join(obj, base_path, name + '.ninja') | 1687 output_file = os.path.join(obj, base_path, name + '.ninja') |
1678 | 1688 |
1679 abs_build_dir = os.path.abspath(toplevel_build) | 1689 abs_build_dir = os.path.abspath(toplevel_build) |
1680 writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir, | 1690 writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir, |
1681 OpenOutput(os.path.join(toplevel_build, output_file)), | 1691 OpenOutput(os.path.join(toplevel_build, output_file)), |
1682 flavor, abs_build_dir=abs_build_dir) | 1692 flavor, abs_build_dir=abs_build_dir) |
1683 master_ninja.subninja(output_file) | 1693 master_ninja.subninja(output_file) |
1684 | 1694 |
1685 target = writer.WriteSpec(spec, config_name, generator_flags) | 1695 target = writer.WriteSpec( |
1696 spec, config_name, generator_flags, case_sensitive_filesystem) | |
1686 if target: | 1697 if target: |
1687 if name != target.FinalOutput() and spec['toolset'] == 'target': | 1698 if name != target.FinalOutput() and spec['toolset'] == 'target': |
1688 target_short_names.setdefault(name, []).append(target) | 1699 target_short_names.setdefault(name, []).append(target) |
1689 target_outputs[qualified_target] = target | 1700 target_outputs[qualified_target] = target |
1690 if qualified_target in all_targets: | 1701 if qualified_target in all_targets: |
1691 all_outputs.add(target.FinalOutput()) | 1702 all_outputs.add(target.FinalOutput()) |
1692 | 1703 |
1693 if target_short_names: | 1704 if target_short_names: |
1694 # Write a short name to build this target. This benefits both the | 1705 # Write a short name to build this target. This benefits both the |
1695 # "build chrome" case as well as the gyp tests, which expect to be | 1706 # "build chrome" case as well as the gyp tests, which expect to be |
(...skipping 16 matching lines...) Expand all Loading... | |
1712 | 1723 |
1713 user_config = params.get('generator_flags', {}).get('config', None) | 1724 user_config = params.get('generator_flags', {}).get('config', None) |
1714 if user_config: | 1725 if user_config: |
1715 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1726 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1716 user_config) | 1727 user_config) |
1717 else: | 1728 else: |
1718 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1729 config_names = target_dicts[target_list[0]]['configurations'].keys() |
1719 for config_name in config_names: | 1730 for config_name in config_names: |
1720 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1731 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1721 config_name) | 1732 config_name) |
OLD | NEW |