| 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_target_writer.h" | 5 #include "tools/gn/ninja_target_writer.h" |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 target->label().GetUserVisibleName(false)); | 44 target->label().GetUserVisibleName(false)); |
| 45 trace.SetToolchain(settings->toolchain_label()); | 45 trace.SetToolchain(settings->toolchain_label()); |
| 46 | 46 |
| 47 base::FilePath ninja_file(settings->build_settings()->GetFullPath( | 47 base::FilePath ninja_file(settings->build_settings()->GetFullPath( |
| 48 helper.GetNinjaFileForTarget(target).GetSourceFile( | 48 helper.GetNinjaFileForTarget(target).GetSourceFile( |
| 49 settings->build_settings()))); | 49 settings->build_settings()))); |
| 50 | 50 |
| 51 if (g_scheduler->verbose_logging()) | 51 if (g_scheduler->verbose_logging()) |
| 52 g_scheduler->Log("Writing", FilePathToUTF8(ninja_file)); | 52 g_scheduler->Log("Writing", FilePathToUTF8(ninja_file)); |
| 53 | 53 |
| 54 file_util::CreateDirectory(ninja_file.DirName()); | 54 base::CreateDirectory(ninja_file.DirName()); |
| 55 | 55 |
| 56 // It's rediculously faster to write to a string and then write that to | 56 // It's rediculously faster to write to a string and then write that to |
| 57 // disk in one operation than to use an fstream here. | 57 // disk in one operation than to use an fstream here. |
| 58 std::stringstream file; | 58 std::stringstream file; |
| 59 | 59 |
| 60 // Call out to the correct sub-type of writer. | 60 // Call out to the correct sub-type of writer. |
| 61 if (target->output_type() == Target::COPY_FILES) { | 61 if (target->output_type() == Target::COPY_FILES) { |
| 62 NinjaCopyTargetWriter writer(target, toolchain, file); | 62 NinjaCopyTargetWriter writer(target, toolchain, file); |
| 63 writer.Run(); | 63 writer.Run(); |
| 64 } else if (target->output_type() == Target::CUSTOM) { | 64 } else if (target->output_type() == Target::CUSTOM) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const Target::FileList& outputs = target_->script_values().outputs(); | 113 const Target::FileList& outputs = target_->script_values().outputs(); |
| 114 std::vector<std::string> output_template_args; | 114 std::vector<std::string> output_template_args; |
| 115 for (size_t i = 0; i < outputs.size(); i++) { | 115 for (size_t i = 0; i < outputs.size(); i++) { |
| 116 // All outputs should be in the output dir. | 116 // All outputs should be in the output dir. |
| 117 output_template_args.push_back( | 117 output_template_args.push_back( |
| 118 RemovePrefix(outputs[i].value(), | 118 RemovePrefix(outputs[i].value(), |
| 119 settings_->build_settings()->build_dir().value())); | 119 settings_->build_settings()->build_dir().value())); |
| 120 } | 120 } |
| 121 return FileTemplate(output_template_args); | 121 return FileTemplate(output_template_args); |
| 122 } | 122 } |
| OLD | NEW |