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

Side by Side Diff: tools/gn/ninja_binary_target_writer.cc

Issue 1530183005: Special-case paths that appear in libs by not prefixing them with -l. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implicit deps Created 5 years 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 unified diff | Download patch
OLDNEW
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
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(
brettw 2015/12/21 22:39:28 This one's multi-line so we would always use a {}
agrieve 2015/12/22 01:17:05 Done.
794 OutputFile(settings_->build_settings(), libs[i].source_file()));
795 }
796
789 // Append implicit dependencies collected above. 797 // Append implicit dependencies collected above.
790 if (!implicit_deps.empty()) { 798 if (!implicit_deps.empty()) {
791 out_ << " |"; 799 out_ << " |";
792 path_output_.WriteFiles(out_, implicit_deps); 800 path_output_.WriteFiles(out_, implicit_deps);
793 } 801 }
794 802
795 // Append data dependencies as order-only dependencies. 803 // Append data dependencies as order-only dependencies.
796 // 804 //
797 // This will include data dependencies and input dependencies (like when 805 // This will include data dependencies and input dependencies (like when
798 // this target depends on an action). Having the data dependencies in this 806 // this target depends on an action). Having the data dependencies in this
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const std::string& lib_value = lib_file.value();
873 if (lib_file.is_source_file()) {
874 out_ << " ";
875 path_output_.WriteFile(out_, lib_file.source_file());
876 } else if (base::EndsWith(lib_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_, lib_value.substr(0, lib_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_, lib_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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698