Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,13 +1057,18 @@ def GetFlagsModifications(
pch_output = ["/Yc" + self._PchHeader()]
if command == "cxx":
return (
[("cflags_cc", map(expand_special, cflags_cc + pch_output))],
[
(
"cflags_cc",
[expand_special(x) for x in cflags_cc + pch_output],
)
],
self.output_obj,
[],
)
elif command == "cc":
return (
[("cflags_c", map(expand_special, cflags_c + pch_output))],
[("cflags_c", [expand_special(x) for x in cflags_c + pch_output])],
self.output_obj,
[],
)
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/pch.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "pch.h"
13 changes: 13 additions & 0 deletions test/fixtures/pch.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
'targets': [
{
'target_name': 'pch',
'type': 'executable',
'sources': [
'pch.cc',
],
'msvs_precompiled_header': 'pch.h',
'msvs_precompiled_source': 'pch.cc',
},
]
}
1 change: 1 addition & 0 deletions test/fixtures/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#pragma once
16 changes: 15 additions & 1 deletion test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import gyp

fixture_dir = os.path.join(os.path.dirname(__file__), "fixtures")
gyp_file = os.path.join(os.path.dirname(__file__), "fixtures/integration.gyp")
gyp_file = os.path.join(fixture_dir, "integration.gyp")
pch_gyp_file = os.path.join(fixture_dir, "pch.gyp")

if sys.platform == "win32":
sysname = sys.platform
Expand Down Expand Up @@ -91,3 +92,16 @@ def test_msvs(self) -> None:

assert_file(self, "test.vcproj", "msvs/test.vcproj")
assert_file(self, "integration.sln", "msvs/integration.sln")

def test_ninja_precompiled_header(self) -> None:
try:
rc = gyp.main(["-f", "ninja", "--depth", fixture_dir, pch_gyp_file])
except ValueError as exc:
self.skipTest(str(exc))
assert rc == 0

with open(os.path.join(fixture_dir, "out/Default/obj/pch.ninja")) as in_file:
ninja_file = in_file.read()

assert "map object at" not in ninja_file
assert "/Ycpch.h" in ninja_file
Loading