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

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

Issue 12052029: ninja windows: Make pch work on VS2012, and simplify implementation (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | pylib/gyp/msvs_emulation.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 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
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 # Ignore unhandled extensions. 815 # Ignore unhandled extensions.
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])
Nico 2013/01/23 21:43:35 Ah, here. Thanks.
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)
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:
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
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 /c $in /Fo$out /Fd$pdbname ')
1462 cc_template = ('ninja -t msvc -o $out -e $arch ' 1466 cxx_command = ('ninja -t msvc -o $out -e $arch '
1463 '-- ' 1467 '-- '
1464 '$cc /nologo /showIncludes /FC ' 1468 '$cxx /nologo /showIncludes /FC '
1465 '@$out.rsp ' 1469 '@$out.rsp /c $in /Fo$out /Fd$pdbname ')
1466 '$cflags_pch_c /c $in %(outspec)s /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( 1470 master_ninja.rule(
1473 'cc', 1471 'cc',
1474 description='CC $out', 1472 description='CC $out',
1475 command=cc_template % {'outspec': '/Fo$out'}, 1473 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', 1474 depfile='$out.d',
1484 rspfile='$out.rsp', 1475 rspfile='$out.rsp',
1485 rspfile_content='$defines $includes $cflags $cflags_c') 1476 rspfile_content='$defines $includes $cflags $cflags_c')
1486 master_ninja.rule( 1477 master_ninja.rule(
1487 'cxx', 1478 'cxx',
1488 description='CXX $out', 1479 description='CXX $out',
1489 command=cxx_template % {'outspec': '/Fo$out'}, 1480 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', 1481 depfile='$out.d',
1498 rspfile='$out.rsp', 1482 rspfile='$out.rsp',
1499 rspfile_content='$defines $includes $cflags $cflags_cc') 1483 rspfile_content='$defines $includes $cflags $cflags_cc')
1500 master_ninja.rule( 1484 master_ninja.rule(
1501 'idl', 1485 'idl',
1502 description='IDL $in', 1486 description='IDL $in',
1503 command=('%s gyp-win-tool midl-wrapper $arch $outdir ' 1487 command=('%s gyp-win-tool midl-wrapper $arch $outdir '
1504 '$tlb $h $dlldata $iid $proxy $in ' 1488 '$tlb $h $dlldata $iid $proxy $in '
1505 '$idlflags' % sys.executable)) 1489 '$idlflags' % sys.executable))
1506 master_ninja.rule( 1490 master_ninja.rule(
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 arglists.append( 1775 arglists.append(
1792 (target_list, target_dicts, data, params, config_name)) 1776 (target_list, target_dicts, data, params, config_name))
1793 pool.map(CallGenerateOutputForConfig, arglists) 1777 pool.map(CallGenerateOutputForConfig, arglists)
1794 except KeyboardInterrupt, e: 1778 except KeyboardInterrupt, e:
1795 pool.terminate() 1779 pool.terminate()
1796 raise e 1780 raise e
1797 else: 1781 else:
1798 for config_name in config_names: 1782 for config_name in config_names:
1799 GenerateOutputForConfig(target_list, target_dicts, data, params, 1783 GenerateOutputForConfig(target_list, target_dicts, data, params,
1800 config_name) 1784 config_name)
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | pylib/gyp/msvs_emulation.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698