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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // End of the link "build" line. | 773 // End of the link "build" line. |
774 out_ << std::endl; | 774 out_ << std::endl; |
775 | 775 |
776 // The remaining things go in the inner scope of the link line. | 776 // The remaining things go in the inner scope of the link line. |
777 if (target_->output_type() == Target::EXECUTABLE || | 777 if (target_->output_type() == Target::EXECUTABLE || |
778 target_->output_type() == Target::SHARED_LIBRARY || | 778 target_->output_type() == Target::SHARED_LIBRARY || |
779 target_->output_type() == Target::LOADABLE_MODULE) { | 779 target_->output_type() == Target::LOADABLE_MODULE) { |
780 WriteLinkerFlags(optional_def_file); | 780 WriteLinkerFlags(optional_def_file); |
781 WriteLibs(); | 781 WriteLibs(); |
782 } | 782 } |
783 WriteOutputExtension(); | 783 WriteOutputSubstitutions(); |
784 WriteSolibs(solibs); | 784 WriteSolibs(solibs); |
785 } | 785 } |
786 | 786 |
787 void NinjaBinaryTargetWriter::WriteLinkerFlags( | 787 void NinjaBinaryTargetWriter::WriteLinkerFlags( |
788 const SourceFile* optional_def_file) { | 788 const SourceFile* optional_def_file) { |
789 out_ << " ldflags ="; | 789 out_ << " ldflags ="; |
790 | 790 |
791 // First the ldflags from the target and its config. | 791 // First the ldflags from the target and its config. |
792 EscapeOptions flag_options = GetFlagOptions(); | 792 EscapeOptions flag_options = GetFlagOptions(); |
793 RecursiveTargetConfigStringsToStream(target_, &ConfigValues::ldflags, | 793 RecursiveTargetConfigStringsToStream(target_, &ConfigValues::ldflags, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 out_, lib_value.substr(0, lib_value.size() - framework_ending.size()), | 840 out_, lib_value.substr(0, lib_value.size() - framework_ending.size()), |
841 lib_escape_opts); | 841 lib_escape_opts); |
842 } else { | 842 } else { |
843 out_ << " " << tool_->lib_switch(); | 843 out_ << " " << tool_->lib_switch(); |
844 EscapeStringToStream(out_, lib_value, lib_escape_opts); | 844 EscapeStringToStream(out_, lib_value, lib_escape_opts); |
845 } | 845 } |
846 } | 846 } |
847 out_ << std::endl; | 847 out_ << std::endl; |
848 } | 848 } |
849 | 849 |
850 void NinjaBinaryTargetWriter::WriteOutputExtension() { | 850 void NinjaBinaryTargetWriter::WriteOutputSubstitutions() { |
851 out_ << " output_extension = " | 851 out_ << " output_extension = " |
852 << SubstitutionWriter::GetLinkerSubstitution( | 852 << SubstitutionWriter::GetLinkerSubstitution( |
853 target_, tool_, SUBSTITUTION_OUTPUT_EXTENSION); | 853 target_, tool_, SUBSTITUTION_OUTPUT_EXTENSION); |
854 out_ << std::endl; | 854 out_ << std::endl; |
| 855 out_ << " output_dir = " |
| 856 << SubstitutionWriter::GetLinkerSubstitution( |
| 857 target_, tool_, SUBSTITUTION_OUTPUT_DIR); |
| 858 out_ << std::endl; |
855 } | 859 } |
856 | 860 |
857 void NinjaBinaryTargetWriter::WriteSolibs( | 861 void NinjaBinaryTargetWriter::WriteSolibs( |
858 const std::vector<OutputFile>& solibs) { | 862 const std::vector<OutputFile>& solibs) { |
859 if (solibs.empty()) | 863 if (solibs.empty()) |
860 return; | 864 return; |
861 | 865 |
862 out_ << " solibs ="; | 866 out_ << " solibs ="; |
863 path_output_.WriteFiles(out_, solibs); | 867 path_output_.WriteFiles(out_, solibs); |
864 out_ << std::endl; | 868 out_ << std::endl; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 "\n" | 996 "\n" |
993 "In the latter case, either rename one of the files or move one of\n" | 997 "In the latter case, either rename one of the files or move one of\n" |
994 "the sources to a separate source_set to avoid them both being in\n" | 998 "the sources to a separate source_set to avoid them both being in\n" |
995 "the same target."); | 999 "the same target."); |
996 g_scheduler->FailWithError(err); | 1000 g_scheduler->FailWithError(err); |
997 return false; | 1001 return false; |
998 } | 1002 } |
999 } | 1003 } |
1000 return true; | 1004 return true; |
1001 } | 1005 } |
OLD | NEW |