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 copy | 5 import copy |
6 import hashlib | 6 import hashlib |
7 import multiprocessing | 7 import multiprocessing |
8 import os.path | 8 import os.path |
9 import re | 9 import re |
10 import signal | 10 import signal |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 | 411 |
412 # Write out the compilation steps, if any. | 412 # Write out the compilation steps, if any. |
413 link_deps = [] | 413 link_deps = [] |
414 sources = spec.get('sources', []) + extra_sources | 414 sources = spec.get('sources', []) + extra_sources |
415 if sources: | 415 if sources: |
416 pch = None | 416 pch = None |
417 if self.flavor == 'win': | 417 if self.flavor == 'win': |
418 gyp.msvs_emulation.VerifyMissingSources( | 418 gyp.msvs_emulation.VerifyMissingSources( |
419 sources, self.abs_build_dir, generator_flags, self.GypPathToNinja) | 419 sources, self.abs_build_dir, generator_flags, self.GypPathToNinja) |
420 pch = gyp.msvs_emulation.PrecompiledHeader( | 420 pch = gyp.msvs_emulation.PrecompiledHeader( |
421 self.msvs_settings, config_name, self.GypPathToNinja) | 421 self.msvs_settings, config_name, self.GypPathToNinja, |
422 self.GypPathToUniqueOutput, self.obj_ext) | |
422 else: | 423 else: |
423 pch = gyp.xcode_emulation.MacPrefixHeader( | 424 pch = gyp.xcode_emulation.MacPrefixHeader( |
424 self.xcode_settings, self.GypPathToNinja, | 425 self.xcode_settings, self.GypPathToNinja, |
425 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) | 426 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) |
426 link_deps = self.WriteSources( | 427 link_deps = self.WriteSources( |
427 config_name, config, sources, compile_depends_stamp, pch, | 428 config_name, config, sources, compile_depends_stamp, pch, |
428 case_sensitive_filesystem, spec) | 429 case_sensitive_filesystem, spec) |
429 # Some actions/rules output 'sources' that are already object files. | 430 # Some actions/rules output 'sources' that are already object files. |
430 link_deps += [self.GypPathToNinja(f) | 431 link_deps += [self.GypPathToNinja(f) |
431 for f in sources if f.endswith(self.obj_ext)] | 432 for f in sources if f.endswith(self.obj_ext)] |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 self.WriteVariableList('cflags_pch_c', | 770 self.WriteVariableList('cflags_pch_c', |
770 [precompiled_header.GetInclude('c')]) | 771 [precompiled_header.GetInclude('c')]) |
771 self.WriteVariableList('cflags_pch_cc', | 772 self.WriteVariableList('cflags_pch_cc', |
772 [precompiled_header.GetInclude('cc')]) | 773 [precompiled_header.GetInclude('cc')]) |
773 self.WriteVariableList('cflags_pch_objc', | 774 self.WriteVariableList('cflags_pch_objc', |
774 [precompiled_header.GetInclude('m')]) | 775 [precompiled_header.GetInclude('m')]) |
775 self.WriteVariableList('cflags_pch_objcc', | 776 self.WriteVariableList('cflags_pch_objcc', |
776 [precompiled_header.GetInclude('mm')]) | 777 [precompiled_header.GetInclude('mm')]) |
777 | 778 |
778 self.WriteVariableList('cflags', map(self.ExpandSpecial, cflags)) | 779 self.WriteVariableList('cflags', map(self.ExpandSpecial, cflags)) |
779 self.WriteVariableList('cflags_c', map(self.ExpandSpecial, cflags_c)) | 780 self.WriteVariableList('cflags_c', map(self.ExpandSpecial, cflags_c)) |
scottmg
2013/01/23 19:20:53
here
| |
780 self.WriteVariableList('cflags_cc', map(self.ExpandSpecial, cflags_cc)) | 781 self.WriteVariableList('cflags_cc', map(self.ExpandSpecial, cflags_cc)) |
781 if self.flavor == 'mac': | 782 if self.flavor == 'mac': |
782 self.WriteVariableList('cflags_objc', map(self.ExpandSpecial, | 783 self.WriteVariableList('cflags_objc', map(self.ExpandSpecial, |
783 cflags_objc)) | 784 cflags_objc)) |
784 self.WriteVariableList('cflags_objcc', map(self.ExpandSpecial, | 785 self.WriteVariableList('cflags_objcc', map(self.ExpandSpecial, |
785 cflags_objcc)) | 786 cflags_objcc)) |
786 self.ninja.newline() | 787 self.ninja.newline() |
787 outputs = [] | 788 outputs = [] |
788 for source in sources: | 789 for source in sources: |
789 filename, ext = os.path.splitext(source) | 790 filename, ext = os.path.splitext(source) |
(...skipping 25 matching lines...) Expand all Loading... | |
815 continue | 816 continue |
816 input = self.GypPathToNinja(source) | 817 input = self.GypPathToNinja(source) |
817 output = self.GypPathToUniqueOutput(filename + obj_ext) | 818 output = self.GypPathToUniqueOutput(filename + obj_ext) |
818 # Ninja's depfile handling gets confused when the case of a filename | 819 # Ninja's depfile handling gets confused when the case of a filename |
819 # changes on a case-insensitive file system. To work around that, always | 820 # changes on a case-insensitive file system. To work around that, always |
820 # convert .o filenames to lowercase on such file systems. See | 821 # convert .o filenames to lowercase on such file systems. See |
821 # https://github.com/martine/ninja/issues/402 for details. | 822 # https://github.com/martine/ninja/issues/402 for details. |
822 if not case_sensitive_filesystem: | 823 if not case_sensitive_filesystem: |
823 output = output.lower() | 824 output = output.lower() |
824 implicit = precompiled_header.GetObjDependencies([input], [output]) | 825 implicit = precompiled_header.GetObjDependencies([input], [output]) |
826 variables = [] | |
827 if self.flavor == 'win': | |
828 variables, implicit, output = precompiled_header.GetFlagsModifications( | |
829 input, output, implicit, command, cflags_c, cflags_cc, | |
830 self.ExpandSpecial) | |
825 self.ninja.build(output, command, input, | 831 self.ninja.build(output, command, input, |
826 implicit=[gch for _, _, gch in implicit], | 832 implicit=[gch for _, _, gch in implicit], |
827 order_only=predepends) | 833 order_only=predepends, variables=variables) |
Nico
2013/01/23 19:08:54
This adds a variable to every single source file i
scottmg
2013/01/23 19:20:53
The default is [], so ninja_syntax.py doesn't emit
Nico
2013/01/23 19:22:08
Understood :-) Still curious.
| |
828 outputs.append(output) | 834 outputs.append(output) |
829 | 835 |
830 self.WritePchTargets(pch_commands) | 836 self.WritePchTargets(pch_commands) |
831 | 837 |
832 self.ninja.newline() | 838 self.ninja.newline() |
833 return outputs | 839 return outputs |
834 | 840 |
835 def WritePchTargets(self, pch_commands): | 841 def WritePchTargets(self, pch_commands): |
836 """Writes ninja rules to compile prefix headers.""" | 842 """Writes ninja rules to compile prefix headers.""" |
837 if not pch_commands: | 843 if not pch_commands: |
838 return | 844 return |
839 | 845 |
840 for gch, lang_flag, lang, input in pch_commands: | 846 for gch, lang_flag, lang, input in pch_commands: |
Nico
2013/01/23 21:25:26
This is now an empty loop on windows, right?
scottmg
2013/01/23 21:32:21
Yes, and linux too.
Nico
2013/01/23 21:43:35
Well yes, linux doesn't support precompiled header
| |
841 var_name = { | 847 var_name = { |
842 'c': 'cflags_pch_c', | 848 'c': 'cflags_pch_c', |
843 'cc': 'cflags_pch_cc', | 849 'cc': 'cflags_pch_cc', |
844 'm': 'cflags_pch_objc', | 850 'm': 'cflags_pch_objc', |
845 'mm': 'cflags_pch_objcc', | 851 'mm': 'cflags_pch_objcc', |
846 }[lang] | 852 }[lang] |
847 | 853 |
848 map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', } | 854 map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', } |
849 if self.flavor == 'win': | |
850 map.update({'c': 'cc_pch', 'cc': 'cxx_pch'}) | |
851 cmd = map.get(lang) | 855 cmd = map.get(lang) |
852 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) | 856 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) |
853 | 857 |
854 def WriteLink(self, spec, config_name, config, link_deps): | 858 def WriteLink(self, spec, config_name, config, link_deps): |
855 """Write out a link step. Fills out target.binary. """ | 859 """Write out a link step. Fills out target.binary. """ |
856 | 860 |
857 command = { | 861 command = { |
858 'executable': 'link', | 862 'executable': 'link', |
859 'loadable_module': 'solink_module', | 863 'loadable_module': 'solink_module', |
860 'shared_library': 'solink', | 864 'shared_library': 'solink', |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1448 description='CC $out', | 1452 description='CC $out', |
1449 command=('$cc $defines $includes $cflags $cflags_c ' | 1453 command=('$cc $defines $includes $cflags $cflags_c ' |
1450 '$cflags_pch_c -c $in -o $out')) | 1454 '$cflags_pch_c -c $in -o $out')) |
1451 master_ninja.rule( | 1455 master_ninja.rule( |
1452 'cxx', | 1456 'cxx', |
1453 description='CXX $out', | 1457 description='CXX $out', |
1454 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' | 1458 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' |
1455 '$cflags_pch_cc -c $in -o $out'), | 1459 '$cflags_pch_cc -c $in -o $out'), |
1456 depfile='$out.d') | 1460 depfile='$out.d') |
1457 else: | 1461 else: |
1458 # Template for compile commands mostly shared between compiling files | 1462 cc_command = ('ninja -t msvc -o $out -e $arch ' |
1459 # and generating PCH. In the case of PCH, the "output" is specified by /Fp | 1463 '-- ' |
1460 # rather than /Fo (for object files), but we still need to specify an /Fo | 1464 '$cc /nologo /showIncludes /FC ' |
1461 # when compiling PCH. | 1465 '@$out.rsp ' |
1462 cc_template = ('ninja -t msvc -o $out -e $arch ' | 1466 '$cflags_pch_c /c $in /Fo$out /Fd$pdbname ') |
Nico
2013/01/23 21:25:26
So what ends up setting cflags_pch_c?
scottmg
2013/01/23 21:32:21
Ah, good point. Removed both of those as they're n
| |
1467 cxx_command = ('ninja -t msvc -o $out -e $arch ' | |
1463 '-- ' | 1468 '-- ' |
1464 '$cc /nologo /showIncludes /FC ' | 1469 '$cxx /nologo /showIncludes /FC ' |
1465 '@$out.rsp ' | 1470 '@$out.rsp ' |
1466 '$cflags_pch_c /c $in %(outspec)s /Fd$pdbname ') | 1471 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ') |
1467 cxx_template = ('ninja -t msvc -o $out -e $arch ' | |
1468 '-- ' | |
1469 '$cxx /nologo /showIncludes /FC ' | |
1470 '@$out.rsp ' | |
1471 '$cflags_pch_cc /c $in %(outspec)s $pchobj /Fd$pdbname ') | |
1472 master_ninja.rule( | 1472 master_ninja.rule( |
1473 'cc', | 1473 'cc', |
1474 description='CC $out', | 1474 description='CC $out', |
1475 command=cc_template % {'outspec': '/Fo$out'}, | 1475 command=cc_command, |
1476 depfile='$out.d', | |
1477 rspfile='$out.rsp', | |
1478 rspfile_content='$defines $includes $cflags $cflags_c') | |
1479 master_ninja.rule( | |
1480 'cc_pch', | |
1481 description='CC PCH $out', | |
1482 command=cc_template % {'outspec': '/Fp$out /Fo$out.obj'}, | |
1483 depfile='$out.d', | 1476 depfile='$out.d', |
1484 rspfile='$out.rsp', | 1477 rspfile='$out.rsp', |
1485 rspfile_content='$defines $includes $cflags $cflags_c') | 1478 rspfile_content='$defines $includes $cflags $cflags_c') |
1486 master_ninja.rule( | 1479 master_ninja.rule( |
1487 'cxx', | 1480 'cxx', |
1488 description='CXX $out', | 1481 description='CXX $out', |
1489 command=cxx_template % {'outspec': '/Fo$out'}, | 1482 command=cxx_command, |
1490 depfile='$out.d', | |
1491 rspfile='$out.rsp', | |
1492 rspfile_content='$defines $includes $cflags $cflags_cc') | |
1493 master_ninja.rule( | |
1494 'cxx_pch', | |
1495 description='CXX PCH $out', | |
1496 command=cxx_template % {'outspec': '/Fp$out /Fo$out.obj'}, | |
1497 depfile='$out.d', | 1483 depfile='$out.d', |
1498 rspfile='$out.rsp', | 1484 rspfile='$out.rsp', |
1499 rspfile_content='$defines $includes $cflags $cflags_cc') | 1485 rspfile_content='$defines $includes $cflags $cflags_cc') |
1500 master_ninja.rule( | 1486 master_ninja.rule( |
1501 'idl', | 1487 'idl', |
1502 description='IDL $in', | 1488 description='IDL $in', |
1503 command=('%s gyp-win-tool midl-wrapper $arch $outdir ' | 1489 command=('%s gyp-win-tool midl-wrapper $arch $outdir ' |
1504 '$tlb $h $dlldata $iid $proxy $in ' | 1490 '$tlb $h $dlldata $iid $proxy $in ' |
1505 '$idlflags' % sys.executable)) | 1491 '$idlflags' % sys.executable)) |
1506 master_ninja.rule( | 1492 master_ninja.rule( |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1791 arglists.append( | 1777 arglists.append( |
1792 (target_list, target_dicts, data, params, config_name)) | 1778 (target_list, target_dicts, data, params, config_name)) |
1793 pool.map(CallGenerateOutputForConfig, arglists) | 1779 pool.map(CallGenerateOutputForConfig, arglists) |
1794 except KeyboardInterrupt, e: | 1780 except KeyboardInterrupt, e: |
1795 pool.terminate() | 1781 pool.terminate() |
1796 raise e | 1782 raise e |
1797 else: | 1783 else: |
1798 for config_name in config_names: | 1784 for config_name in config_names: |
1799 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1785 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1800 config_name) | 1786 config_name) |
OLD | NEW |