diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py index f1c15819..84e0b4f3 100644 --- a/pylib/gyp/msvs_emulation.py +++ b/pylib/gyp/msvs_emulation.py @@ -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, [], ) diff --git a/test/fixtures/pch.cc b/test/fixtures/pch.cc new file mode 100644 index 00000000..1d9f38c5 --- /dev/null +++ b/test/fixtures/pch.cc @@ -0,0 +1 @@ +#include "pch.h" diff --git a/test/fixtures/pch.gyp b/test/fixtures/pch.gyp new file mode 100644 index 00000000..628c9410 --- /dev/null +++ b/test/fixtures/pch.gyp @@ -0,0 +1,13 @@ +{ + 'targets': [ + { + 'target_name': 'pch', + 'type': 'executable', + 'sources': [ + 'pch.cc', + ], + 'msvs_precompiled_header': 'pch.h', + 'msvs_precompiled_source': 'pch.cc', + }, + ] +} diff --git a/test/fixtures/pch.h b/test/fixtures/pch.h new file mode 100644 index 00000000..6f70f09b --- /dev/null +++ b/test/fixtures/pch.h @@ -0,0 +1 @@ +#pragma once diff --git a/test/integration_test.py b/test/integration_test.py index 26d78763..8244708a 100644 --- a/test/integration_test.py +++ b/test/integration_test.py @@ -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 @@ -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