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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 for (const SourceFile& src_file : other_files) { | 779 for (const SourceFile& src_file : other_files) { |
780 if (GetSourceFileType(src_file) == SOURCE_DEF) { | 780 if (GetSourceFileType(src_file) == SOURCE_DEF) { |
781 optional_def_file = &src_file; | 781 optional_def_file = &src_file; |
782 implicit_deps.push_back( | 782 implicit_deps.push_back( |
783 OutputFile(settings_->build_settings(), src_file)); | 783 OutputFile(settings_->build_settings(), src_file)); |
784 break; // Only one def file is allowed. | 784 break; // Only one def file is allowed. |
785 } | 785 } |
786 } | 786 } |
787 } | 787 } |
788 | 788 |
| 789 // Libraries specified by paths. |
| 790 const OrderedSet<LibFile>& libs = target_->all_libs(); |
| 791 for (size_t i = 0; i < libs.size(); i++) { |
| 792 if (libs[i].is_source_file()) { |
| 793 implicit_deps.push_back( |
| 794 OutputFile(settings_->build_settings(), libs[i].source_file())); |
| 795 } |
| 796 } |
| 797 |
789 // Append implicit dependencies collected above. | 798 // Append implicit dependencies collected above. |
790 if (!implicit_deps.empty()) { | 799 if (!implicit_deps.empty()) { |
791 out_ << " |"; | 800 out_ << " |"; |
792 path_output_.WriteFiles(out_, implicit_deps); | 801 path_output_.WriteFiles(out_, implicit_deps); |
793 } | 802 } |
794 | 803 |
795 // Append data dependencies as order-only dependencies. | 804 // Append data dependencies as order-only dependencies. |
796 // | 805 // |
797 // This will include data dependencies and input dependencies (like when | 806 // This will include data dependencies and input dependencies (like when |
798 // this target depends on an action). Having the data dependencies in this | 807 // this target depends on an action). Having the data dependencies in this |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 859 |
851 out_ << std::endl; | 860 out_ << std::endl; |
852 } | 861 } |
853 | 862 |
854 void NinjaBinaryTargetWriter::WriteLibs() { | 863 void NinjaBinaryTargetWriter::WriteLibs() { |
855 out_ << " libs ="; | 864 out_ << " libs ="; |
856 | 865 |
857 // Libraries that have been recursively pushed through the dependency tree. | 866 // Libraries that have been recursively pushed through the dependency tree. |
858 EscapeOptions lib_escape_opts; | 867 EscapeOptions lib_escape_opts; |
859 lib_escape_opts.mode = ESCAPE_NINJA_COMMAND; | 868 lib_escape_opts.mode = ESCAPE_NINJA_COMMAND; |
860 const OrderedSet<std::string> all_libs = target_->all_libs(); | 869 const OrderedSet<LibFile> all_libs = target_->all_libs(); |
861 const std::string framework_ending(".framework"); | 870 const std::string framework_ending(".framework"); |
862 for (size_t i = 0; i < all_libs.size(); i++) { | 871 for (size_t i = 0; i < all_libs.size(); i++) { |
863 if (base::EndsWith(all_libs[i], framework_ending, | 872 const LibFile& lib_file = all_libs[i]; |
864 base::CompareCase::INSENSITIVE_ASCII)) { | 873 const std::string& lib_value = lib_file.value(); |
| 874 if (lib_file.is_source_file()) { |
| 875 out_ << " "; |
| 876 path_output_.WriteFile(out_, lib_file.source_file()); |
| 877 } else if (base::EndsWith(lib_value, framework_ending, |
| 878 base::CompareCase::INSENSITIVE_ASCII)) { |
865 // Special-case libraries ending in ".framework" to support Mac: Add the | 879 // Special-case libraries ending in ".framework" to support Mac: Add the |
866 // -framework switch and don't add the extension to the output. | 880 // -framework switch and don't add the extension to the output. |
867 out_ << " -framework "; | 881 out_ << " -framework "; |
868 EscapeStringToStream(out_, | 882 EscapeStringToStream( |
869 all_libs[i].substr(0, all_libs[i].size() - framework_ending.size()), | 883 out_, lib_value.substr(0, lib_value.size() - framework_ending.size()), |
870 lib_escape_opts); | 884 lib_escape_opts); |
871 } else { | 885 } else { |
872 out_ << " " << tool_->lib_switch(); | 886 out_ << " " << tool_->lib_switch(); |
873 EscapeStringToStream(out_, all_libs[i], lib_escape_opts); | 887 EscapeStringToStream(out_, lib_value, lib_escape_opts); |
874 } | 888 } |
875 } | 889 } |
876 out_ << std::endl; | 890 out_ << std::endl; |
877 } | 891 } |
878 | 892 |
879 void NinjaBinaryTargetWriter::WriteOutputExtension() { | 893 void NinjaBinaryTargetWriter::WriteOutputExtension() { |
880 out_ << " output_extension = "; | 894 out_ << " output_extension = "; |
881 if (target_->output_extension().empty()) { | 895 if (target_->output_extension().empty()) { |
882 // Use the default from the tool. | 896 // Use the default from the tool. |
883 out_ << tool_->default_output_extension(); | 897 out_ << tool_->default_output_extension(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 "\n" | 1041 "\n" |
1028 "In the latter case, either rename one of the files or move one of\n" | 1042 "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" | 1043 "the sources to a separate source_set to avoid them both being in\n" |
1030 "the same target."); | 1044 "the same target."); |
1031 g_scheduler->FailWithError(err); | 1045 g_scheduler->FailWithError(err); |
1032 return false; | 1046 return false; |
1033 } | 1047 } |
1034 } | 1048 } |
1035 return true; | 1049 return true; |
1036 } | 1050 } |
OLD | NEW |