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 <cstring> | 7 #include <cstring> |
8 #include <set> | 8 #include <set> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 | 745 |
746 UniqueVector<OutputFile> extra_object_files; | 746 UniqueVector<OutputFile> extra_object_files; |
747 UniqueVector<const Target*> linkable_deps; | 747 UniqueVector<const Target*> linkable_deps; |
748 UniqueVector<const Target*> non_linkable_deps; | 748 UniqueVector<const Target*> non_linkable_deps; |
749 GetDeps(&extra_object_files, &linkable_deps, &non_linkable_deps); | 749 GetDeps(&extra_object_files, &linkable_deps, &non_linkable_deps); |
750 | 750 |
751 // Object files. | 751 // Object files. |
752 path_output_.WriteFiles(out_, object_files); | 752 path_output_.WriteFiles(out_, object_files); |
753 path_output_.WriteFiles(out_, extra_object_files); | 753 path_output_.WriteFiles(out_, extra_object_files); |
754 | 754 |
755 // Libraries specified by paths. | |
brettw
2015/12/18 00:04:55
We should get a test for this new behavior.
agrieve
2015/12/18 15:39:07
Done.
| |
756 const OrderedSet<LibFile>& libs = target_->all_libs(); | |
757 for (size_t i = 0; i < libs.size(); i++) { | |
758 if (libs[i].is_source_file()) { | |
brettw
2015/12/18 00:04:55
No {} for single-line ones (file style).
agrieve
2015/12/18 15:39:07
Done.
| |
759 path_output_.WriteFile(out_, libs[i].source_file()); | |
760 } | |
761 } | |
762 | |
755 // Dependencies. | 763 // Dependencies. |
756 std::vector<OutputFile> implicit_deps; | 764 std::vector<OutputFile> implicit_deps; |
757 std::vector<OutputFile> solibs; | 765 std::vector<OutputFile> solibs; |
758 for (const Target* cur : linkable_deps) { | 766 for (const Target* cur : linkable_deps) { |
759 // All linkable deps should have a link output file. | 767 // All linkable deps should have a link output file. |
760 DCHECK(!cur->link_output_file().value().empty()) | 768 DCHECK(!cur->link_output_file().value().empty()) |
761 << "No link output file for " | 769 << "No link output file for " |
762 << target_->label().GetUserVisibleName(false); | 770 << target_->label().GetUserVisibleName(false); |
763 | 771 |
764 if (cur->dependency_output_file().value() != | 772 if (cur->dependency_output_file().value() != |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 | 858 |
851 out_ << std::endl; | 859 out_ << std::endl; |
852 } | 860 } |
853 | 861 |
854 void NinjaBinaryTargetWriter::WriteLibs() { | 862 void NinjaBinaryTargetWriter::WriteLibs() { |
855 out_ << " libs ="; | 863 out_ << " libs ="; |
856 | 864 |
857 // Libraries that have been recursively pushed through the dependency tree. | 865 // Libraries that have been recursively pushed through the dependency tree. |
858 EscapeOptions lib_escape_opts; | 866 EscapeOptions lib_escape_opts; |
859 lib_escape_opts.mode = ESCAPE_NINJA_COMMAND; | 867 lib_escape_opts.mode = ESCAPE_NINJA_COMMAND; |
860 const OrderedSet<std::string> all_libs = target_->all_libs(); | 868 const OrderedSet<LibFile> all_libs = target_->all_libs(); |
861 const std::string framework_ending(".framework"); | 869 const std::string framework_ending(".framework"); |
862 for (size_t i = 0; i < all_libs.size(); i++) { | 870 for (size_t i = 0; i < all_libs.size(); i++) { |
863 if (base::EndsWith(all_libs[i], framework_ending, | 871 const LibFile& lib_file = all_libs[i]; |
864 base::CompareCase::INSENSITIVE_ASCII)) { | 872 std::string value = lib_file.value(); |
brettw
2015/12/18 00:04:55
Can this be a const ref? I think it would also be
agrieve
2015/12/18 15:39:08
Done.
| |
873 if (lib_file.is_source_file()) { | |
874 out_ << " "; | |
875 path_output_.WriteFile(out_, lib_file.source_file()); | |
876 } else if (base::EndsWith(value, framework_ending, | |
877 base::CompareCase::INSENSITIVE_ASCII)) { | |
865 // Special-case libraries ending in ".framework" to support Mac: Add the | 878 // Special-case libraries ending in ".framework" to support Mac: Add the |
866 // -framework switch and don't add the extension to the output. | 879 // -framework switch and don't add the extension to the output. |
867 out_ << " -framework "; | 880 out_ << " -framework "; |
868 EscapeStringToStream(out_, | 881 EscapeStringToStream( |
869 all_libs[i].substr(0, all_libs[i].size() - framework_ending.size()), | 882 out_, value.substr(0, value.size() - framework_ending.size()), |
870 lib_escape_opts); | 883 lib_escape_opts); |
871 } else { | 884 } else { |
872 out_ << " " << tool_->lib_switch(); | 885 out_ << " " << tool_->lib_switch(); |
873 EscapeStringToStream(out_, all_libs[i], lib_escape_opts); | 886 EscapeStringToStream(out_, value, lib_escape_opts); |
874 } | 887 } |
875 } | 888 } |
876 out_ << std::endl; | 889 out_ << std::endl; |
877 } | 890 } |
878 | 891 |
879 void NinjaBinaryTargetWriter::WriteOutputExtension() { | 892 void NinjaBinaryTargetWriter::WriteOutputExtension() { |
880 out_ << " output_extension = "; | 893 out_ << " output_extension = "; |
881 if (target_->output_extension().empty()) { | 894 if (target_->output_extension().empty()) { |
882 // Use the default from the tool. | 895 // Use the default from the tool. |
883 out_ << tool_->default_output_extension(); | 896 out_ << tool_->default_output_extension(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 "\n" | 1040 "\n" |
1028 "In the latter case, either rename one of the files or move one of\n" | 1041 "In the latter case, either rename one of the files or move one of\n" |
1029 "the sources to a separate source_set to avoid them both being in\n" | 1042 "the sources to a separate source_set to avoid them both being in\n" |
1030 "the same target."); | 1043 "the same target."); |
1031 g_scheduler->FailWithError(err); | 1044 g_scheduler->FailWithError(err); |
1032 return false; | 1045 return false; |
1033 } | 1046 } |
1034 } | 1047 } |
1035 return true; | 1048 return true; |
1036 } | 1049 } |
OLD | NEW |