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

Unified Diff: tools/gn/ninja_binary_target_writer.cc

Issue 1893933002: gn: Use .obj extension for pch objects on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_binary_target_writer.cc
diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc
index a62f8725838ad1faf7ac01c64b07db95d3c44ccb..4a923c3bde018909c27a41ff26f9f5dd54679e82 100644
--- a/tools/gn/ninja_binary_target_writer.cc
+++ b/tools/gn/ninja_binary_target_writer.cc
@@ -103,14 +103,15 @@ const char* GetPCHLangSuffixForToolType(Toolchain::ToolType type) {
}
}
-std::string GetWindowsPCHObjectExtension(Toolchain::ToolType tool_type) {
+std::string GetWindowsPCHObjectExtension(Toolchain::ToolType tool_type,
+ const std::string& obj_extension) {
const char* lang_suffix = GetPCHLangSuffixForToolType(tool_type);
std::string result = ".";
// For MSVC, annotate the obj files with the language type. For example:
- // obj/foo/target_name.precompile.o ->
- // obj/foo/target_name.precompile.cc.o
+ // obj/foo/target_name.precompile.obj ->
+ // obj/foo/target_name.precompile.cc.obj
result += lang_suffix;
- result += ".o";
+ result += obj_extension;
return result;
}
@@ -182,7 +183,8 @@ void GetPCHOutputFiles(const Target* target,
Tool::PrecompiledHeaderType header_type = tool->precompiled_header_type();
switch (header_type) {
case Tool::PCH_MSVC:
- output_extension = GetWindowsPCHObjectExtension(tool_type);
+ output_extension = GetWindowsPCHObjectExtension(
+ tool_type, output_value.substr(extension_offset - 1));
break;
case Tool::PCH_GCC:
output_extension = GetGCCPCHOutputExtension(tool_type);
@@ -621,7 +623,7 @@ void NinjaBinaryTargetWriter::WriteSources(
if (tool_type != Toolchain::TYPE_NONE) {
// Only include PCH deps that correspond to the tool type, for instance,
- // do not specify target_name.precompile.cc.o (a CXX PCH file) as a dep
+ // do not specify target_name.precompile.cc.obj (a CXX PCH file) as a dep
// for the output of a C tool type.
//
// This makes the assumption that pch_deps only contains pch output files
@@ -631,9 +633,13 @@ void NinjaBinaryTargetWriter::WriteSources(
if (tool->precompiled_header_type() != Tool::PCH_NONE) {
for (const auto& dep : pch_deps) {
const std::string& output_value = dep.value();
+ size_t extension_offset = FindExtensionOffset(output_value);
+ if (extension_offset == std::string::npos)
+ continue;
std::string output_extension;
if (tool->precompiled_header_type() == Tool::PCH_MSVC) {
- output_extension = GetWindowsPCHObjectExtension(tool_type);
+ output_extension = GetWindowsPCHObjectExtension(
+ tool_type, output_value.substr(extension_offset - 1));
} else if (tool->precompiled_header_type() == Tool::PCH_GCC) {
output_extension = GetGCCPCHOutputExtension(tool_type);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698