MCPcopy Create free account
hub / github.com/nodejs/node / _HandlePreCompiledHeaders

Function _HandlePreCompiledHeaders

tools/gyp/pylib/gyp/generator/msvs.py:1654–1699  ·  view source on GitHub ↗
(p, sources, spec)

Source from the content-addressed store, hash-verified

1652
1653
1654def _HandlePreCompiledHeaders(p, sources, spec):
1655 # Pre-compiled header source stubs need a different compiler flag
1656 # (generate precompiled header) and any source file not of the same
1657 # kind (i.e. C vs. C++) as the precompiled header source stub needs
1658 # to have use of precompiled headers disabled.
1659 extensions_excluded_from_precompile = []
1660 for config_name, config in spec["configurations"].items():
1661 source = config.get("msvs_precompiled_source")
1662 if source:
1663 source = _FixPath(source)
1664 # UsePrecompiledHeader=1 for if using precompiled headers.
1665 tool = MSVSProject.Tool("VCCLCompilerTool", {"UsePrecompiledHeader": "1"})
1666 p.AddFileConfig(
1667 source, _ConfigFullName(config_name, config), {}, tools=[tool]
1668 )
1669 _basename, extension = os.path.splitext(source)
1670 if extension == ".c":
1671 extensions_excluded_from_precompile = [".cc", ".cpp", ".cxx"]
1672 else:
1673 extensions_excluded_from_precompile = [".c"]
1674
1675 def DisableForSourceTree(source_tree):
1676 for source in source_tree:
1677 if isinstance(source, MSVSProject.Filter):
1678 DisableForSourceTree(source.contents)
1679 else:
1680 _basename, extension = os.path.splitext(source)
1681 if extension in extensions_excluded_from_precompile:
1682 for config_name, config in spec["configurations"].items():
1683 tool = MSVSProject.Tool(
1684 "VCCLCompilerTool",
1685 {
1686 "UsePrecompiledHeader": "0",
1687 "ForcedIncludeFiles": "$(NOINHERIT)",
1688 },
1689 )
1690 p.AddFileConfig(
1691 _FixPath(source),
1692 _ConfigFullName(config_name, config),
1693 {},
1694 tools=[tool],
1695 )
1696
1697 # Do nothing if there was no precompiled source.
1698 if extensions_excluded_from_precompile:
1699 DisableForSourceTree(sources)
1700
1701
1702def _AddActions(actions_to_add, spec, relative_path_of_gyp_file):

Callers 1

_GenerateMSVSProjectFunction · 0.85

Calls 6

_FixPathFunction · 0.85
_ConfigFullNameFunction · 0.85
DisableForSourceTreeFunction · 0.85
AddFileConfigMethod · 0.80
getMethod · 0.65
itemsMethod · 0.45

Tested by

no test coverage detected