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/ninja_binary_target_writer.h" | 5 #include "tools/gn/ninja_binary_target_writer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 UniqueVector<const Target*> linkable_deps; | 941 UniqueVector<const Target*> linkable_deps; |
942 UniqueVector<const Target*> non_linkable_deps; | 942 UniqueVector<const Target*> non_linkable_deps; |
943 GetDeps(&extra_object_files, &linkable_deps, &non_linkable_deps); | 943 GetDeps(&extra_object_files, &linkable_deps, &non_linkable_deps); |
944 | 944 |
945 // The classifier should never put extra object files in a source set: | 945 // The classifier should never put extra object files in a source set: |
946 // any source sets that we depend on should appear in our non-linkable | 946 // any source sets that we depend on should appear in our non-linkable |
947 // deps instead. | 947 // deps instead. |
948 DCHECK(extra_object_files.empty()); | 948 DCHECK(extra_object_files.empty()); |
949 | 949 |
950 std::vector<OutputFile> order_only_deps; | 950 std::vector<OutputFile> order_only_deps; |
951 for (const auto& dep : non_linkable_deps) | 951 for (auto* dep : non_linkable_deps) |
952 order_only_deps.push_back(dep->dependency_output_file()); | 952 order_only_deps.push_back(dep->dependency_output_file()); |
953 | 953 |
954 WriteStampForTarget(object_files, order_only_deps); | 954 WriteStampForTarget(object_files, order_only_deps); |
955 } | 955 } |
956 | 956 |
957 void NinjaBinaryTargetWriter::GetDeps( | 957 void NinjaBinaryTargetWriter::GetDeps( |
958 UniqueVector<OutputFile>* extra_object_files, | 958 UniqueVector<OutputFile>* extra_object_files, |
959 UniqueVector<const Target*>* linkable_deps, | 959 UniqueVector<const Target*>* linkable_deps, |
960 UniqueVector<const Target*>* non_linkable_deps) const { | 960 UniqueVector<const Target*>* non_linkable_deps) const { |
961 // Normal public/private deps. | 961 // Normal public/private deps. |
962 for (const auto& pair : target_->GetDeps(Target::DEPS_LINKED)) { | 962 for (const auto& pair : target_->GetDeps(Target::DEPS_LINKED)) { |
963 ClassifyDependency(pair.ptr, extra_object_files, | 963 ClassifyDependency(pair.ptr, extra_object_files, |
964 linkable_deps, non_linkable_deps); | 964 linkable_deps, non_linkable_deps); |
965 } | 965 } |
966 | 966 |
967 // Inherited libraries. | 967 // Inherited libraries. |
968 for (const auto& inherited_target : | 968 for (auto* inherited_target : target_->inherited_libraries().GetOrdered()) { |
969 target_->inherited_libraries().GetOrdered()) { | |
970 ClassifyDependency(inherited_target, extra_object_files, | 969 ClassifyDependency(inherited_target, extra_object_files, |
971 linkable_deps, non_linkable_deps); | 970 linkable_deps, non_linkable_deps); |
972 } | 971 } |
973 | 972 |
974 // Data deps. | 973 // Data deps. |
975 for (const auto& data_dep_pair : target_->data_deps()) | 974 for (const auto& data_dep_pair : target_->data_deps()) |
976 non_linkable_deps->push_back(data_dep_pair.ptr); | 975 non_linkable_deps->push_back(data_dep_pair.ptr); |
977 } | 976 } |
978 | 977 |
979 void NinjaBinaryTargetWriter::ClassifyDependency( | 978 void NinjaBinaryTargetWriter::ClassifyDependency( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 non_linkable_deps->push_back(dep); | 1021 non_linkable_deps->push_back(dep); |
1023 } | 1022 } |
1024 } | 1023 } |
1025 | 1024 |
1026 void NinjaBinaryTargetWriter::WriteOrderOnlyDependencies( | 1025 void NinjaBinaryTargetWriter::WriteOrderOnlyDependencies( |
1027 const UniqueVector<const Target*>& non_linkable_deps) { | 1026 const UniqueVector<const Target*>& non_linkable_deps) { |
1028 if (!non_linkable_deps.empty()) { | 1027 if (!non_linkable_deps.empty()) { |
1029 out_ << " ||"; | 1028 out_ << " ||"; |
1030 | 1029 |
1031 // Non-linkable targets. | 1030 // Non-linkable targets. |
1032 for (const auto& non_linkable_dep : non_linkable_deps) { | 1031 for (auto* non_linkable_dep : non_linkable_deps) { |
1033 out_ << " "; | 1032 out_ << " "; |
1034 path_output_.WriteFile(out_, non_linkable_dep->dependency_output_file()); | 1033 path_output_.WriteFile(out_, non_linkable_dep->dependency_output_file()); |
1035 } | 1034 } |
1036 } | 1035 } |
1037 } | 1036 } |
1038 | 1037 |
1039 OutputFile NinjaBinaryTargetWriter::GetWindowsPCHFile( | 1038 OutputFile NinjaBinaryTargetWriter::GetWindowsPCHFile( |
1040 Toolchain::ToolType tool_type) const { | 1039 Toolchain::ToolType tool_type) const { |
1041 // Use "obj/{dir}/{target_name}_{lang}.pch" which ends up | 1040 // Use "obj/{dir}/{target_name}_{lang}.pch" which ends up |
1042 // looking like "obj/chrome/browser/browser_cc.pch" | 1041 // looking like "obj/chrome/browser/browser_cc.pch" |
(...skipping 25 matching lines...) Expand all Loading... |
1068 "\n" | 1067 "\n" |
1069 "In the latter case, either rename one of the files or move one of\n" | 1068 "In the latter case, either rename one of the files or move one of\n" |
1070 "the sources to a separate source_set to avoid them both being in\n" | 1069 "the sources to a separate source_set to avoid them both being in\n" |
1071 "the same target."); | 1070 "the same target."); |
1072 g_scheduler->FailWithError(err); | 1071 g_scheduler->FailWithError(err); |
1073 return false; | 1072 return false; |
1074 } | 1073 } |
1075 } | 1074 } |
1076 return true; | 1075 return true; |
1077 } | 1076 } |
OLD | NEW |