| Index: pylib/gyp/msvs_emulation.py
|
| ===================================================================
|
| --- pylib/gyp/msvs_emulation.py (revision 1564)
|
| +++ pylib/gyp/msvs_emulation.py (working copy)
|
| @@ -610,29 +610,25 @@
|
| return ((source_ext in c_exts and pch_source_ext in c_exts) or
|
| (source_ext in cc_exts and pch_source_ext in cc_exts))
|
|
|
| +
|
| class PrecompiledHeader(object):
|
| """Helper to generate dependencies and build rules to handle generation of
|
| precompiled headers. Interface matches the GCH handler in xcode_emulation.py.
|
| """
|
| - def __init__(self, settings, config, gyp_to_build_path):
|
| + def __init__(
|
| + self, settings, config, gyp_to_build_path, gyp_to_unique_output, obj_ext):
|
| self.settings = settings
|
| self.config = config
|
| - self.gyp_to_build_path = gyp_to_build_path
|
| + pch_source = self.settings.msvs_precompiled_source[self.config]
|
| + self.pch_source = gyp_to_build_path(pch_source)
|
| + filename, _ = os.path.splitext(pch_source)
|
| + self.output_obj = gyp_to_unique_output(filename + obj_ext).lower()
|
|
|
| def _PchHeader(self):
|
| """Get the header that will appear in an #include line for all source
|
| files."""
|
| return os.path.split(self.settings.msvs_precompiled_header[self.config])[1]
|
|
|
| - def _PchSource(self):
|
| - """Get the source file that is built once to compile the pch data."""
|
| - return self.gyp_to_build_path(
|
| - self.settings.msvs_precompiled_source[self.config])
|
| -
|
| - def _PchOutput(self):
|
| - """Get the name of the output of the compiled pch data."""
|
| - return '${pchprefix}.' + self._PchHeader() + '.pch'
|
| -
|
| def GetObjDependencies(self, sources, objs):
|
| """Given a list of sources files and the corresponding object files,
|
| returns a list of the pch files that should be depended upon. The
|
| @@ -640,26 +636,32 @@
|
| with make.py on Mac, and xcode_emulation.py."""
|
| if not self._PchHeader():
|
| return []
|
| - source = self._PchSource()
|
| - assert source
|
| - pch_ext = os.path.splitext(self._PchSource())[1]
|
| + pch_ext = os.path.splitext(self.pch_source)[1]
|
| for source in sources:
|
| if _LanguageMatchesForPch(os.path.splitext(source)[1], pch_ext):
|
| - return [(None, None, self._PchOutput())]
|
| + return [(None, None, self.output_obj)]
|
| return []
|
|
|
| def GetPchBuildCommands(self):
|
| - """Returns [(path_to_pch, language_flag, language, header)].
|
| - |path_to_gch| and |header| are relative to the build directory."""
|
| - header = self._PchHeader()
|
| - source = self._PchSource()
|
| - if not source or not header:
|
| - return []
|
| - ext = os.path.splitext(source)[1]
|
| - lang = 'c' if ext == '.c' else 'cc'
|
| - return [(self._PchOutput(), '/Yc' + header, lang, source)]
|
| + """Not used on Windows as there are no additional build steps required
|
| + (instead, existing steps are modified in GetFlagsModifications below)."""
|
| + return []
|
|
|
| + def GetFlagsModifications(self, input, output, implicit, command,
|
| + cflags_c, cflags_cc, expand_special):
|
| + """Get the modified cflags and implicit dependencies that should be used
|
| + for the pch compilation step."""
|
| + if input == self.pch_source:
|
| + pch_output = ['/Yc' + self._PchHeader()]
|
| + if command == 'cxx':
|
| + return ([('cflags_cc', map(expand_special, cflags_cc + pch_output))],
|
| + self.output_obj, [])
|
| + elif command == 'cc':
|
| + return ([('cflags_c', map(expand_special, cflags_c + pch_output))],
|
| + self.output_obj, [])
|
| + return [], output, implicit
|
|
|
| +
|
| vs_version = None
|
| def GetVSVersion(generator_flags):
|
| global vs_version
|
|
|