OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/target.h" | 5 #include "tools/gn/target.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 FillOutputFiles(); | 301 FillOutputFiles(); |
302 | 302 |
303 if (settings()->build_settings()->check_for_bad_items()) { | 303 if (settings()->build_settings()->check_for_bad_items()) { |
304 if (!CheckVisibility(err)) | 304 if (!CheckVisibility(err)) |
305 return false; | 305 return false; |
306 if (!CheckTestonly(err)) | 306 if (!CheckTestonly(err)) |
307 return false; | 307 return false; |
308 if (!CheckAssertNoDeps(err)) | 308 if (!CheckAssertNoDeps(err)) |
309 return false; | 309 return false; |
310 CheckSourcesGenerated(); | 310 CheckSourcesGenerated(); |
| 311 if (config_values_.has_precompiled_headers() && |
| 312 !CheckPrecompiledHeaders(err)) |
| 313 return false; |
311 } | 314 } |
312 | 315 |
313 if (!write_runtime_deps_output_.value().empty()) | 316 if (!write_runtime_deps_output_.value().empty()) |
314 g_scheduler->AddWriteRuntimeDepsTarget(this); | 317 g_scheduler->AddWriteRuntimeDepsTarget(this); |
315 | 318 |
316 return true; | 319 return true; |
317 } | 320 } |
318 | 321 |
319 bool Target::IsBinary() const { | 322 bool Target::IsBinary() const { |
320 return output_type_ == EXECUTABLE || | 323 return output_type_ == EXECUTABLE || |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 check_data_deps = g_scheduler->IsFileGeneratedByWriteRuntimeDeps(out_file); | 773 check_data_deps = g_scheduler->IsFileGeneratedByWriteRuntimeDeps(out_file); |
771 // Check object files (much slower and very rare) only if the "normal" | 774 // Check object files (much slower and very rare) only if the "normal" |
772 // output check failed. | 775 // output check failed. |
773 consider_object_files = !check_data_deps; | 776 consider_object_files = !check_data_deps; |
774 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, | 777 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, |
775 consider_object_files, | 778 consider_object_files, |
776 check_data_deps, &seen_targets)) | 779 check_data_deps, &seen_targets)) |
777 g_scheduler->AddUnknownGeneratedInput(this, source); | 780 g_scheduler->AddUnknownGeneratedInput(this, source); |
778 } | 781 } |
779 } | 782 } |
| 783 |
| 784 bool Target::CheckPrecompiledHeaders(Err* err) const { |
| 785 // Figure out what source types are needed. |
| 786 SourceFileTypeSet used_types; |
| 787 for (const auto& source : sources_) |
| 788 used_types.Set(GetSourceFileType(source)); |
| 789 |
| 790 // Not all source types support precompiled precompiled headers. |
| 791 static const SourceFileType kSourceTypesToCheck[] = { |
| 792 SOURCE_C, SOURCE_CPP, SOURCE_M, SOURCE_MM, |
| 793 }; |
| 794 |
| 795 bool is_valid = true; |
| 796 for (auto type : kSourceTypesToCheck) { |
| 797 if (!used_types.Get(type)) |
| 798 continue; |
| 799 |
| 800 const Toolchain::ToolType toolType = |
| 801 Toolchain::GetToolTypeForSourceType(type); |
| 802 const Tool* tool = toolchain_->GetTool(toolType); |
| 803 |
| 804 if (!tool || tool->precompiled_header_type() != Tool::PCH_NONE) |
| 805 continue; |
| 806 |
| 807 // Make a generic error first and then append a list of "broken" tool()s. |
| 808 if (!err->has_error()) { |
| 809 *err = Err(defined_from(), |
| 810 "Toolchain (" + toolchain_->label().GetUserVisibleName(false) + |
| 811 ") used by target (" + label().GetUserVisibleName(false) + |
| 812 ") doesn't support precompiled headers.", |
| 813 "Either remove the precompiled header from the target or add " |
| 814 "support to the toolchain."); |
| 815 is_valid = false; |
| 816 } |
| 817 |
| 818 err->AppendSubErr(Err(tool->defined_from(), |
| 819 "Tool \"" + Toolchain::ToolTypeToName(toolType) + |
| 820 "\" doesn't set precompiled_header_type.")); |
| 821 } |
| 822 |
| 823 return is_valid; |
| 824 } |
OLD | NEW |