| 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_toolchain_writer.h" | 5 #include "tools/gn/ninja_toolchain_writer.h" |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 bool NinjaToolchainWriter::RunAndWriteFile( | 40 bool NinjaToolchainWriter::RunAndWriteFile( |
| 41 const Settings* settings, | 41 const Settings* settings, |
| 42 const Toolchain* toolchain, | 42 const Toolchain* toolchain, |
| 43 const std::vector<const Target*>& targets) { | 43 const std::vector<const Target*>& targets) { |
| 44 NinjaHelper helper(settings->build_settings()); | 44 NinjaHelper helper(settings->build_settings()); |
| 45 base::FilePath ninja_file(settings->build_settings()->GetFullPath( | 45 base::FilePath ninja_file(settings->build_settings()->GetFullPath( |
| 46 helper.GetNinjaFileForToolchain(settings).GetSourceFile( | 46 helper.GetNinjaFileForToolchain(settings).GetSourceFile( |
| 47 settings->build_settings()))); | 47 settings->build_settings()))); |
| 48 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, FilePathToUTF8(ninja_file)); | 48 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, FilePathToUTF8(ninja_file)); |
| 49 | 49 |
| 50 file_util::CreateDirectory(ninja_file.DirName()); | 50 base::CreateDirectory(ninja_file.DirName()); |
| 51 | 51 |
| 52 std::ofstream file; | 52 std::ofstream file; |
| 53 file.open(FilePathToUTF8(ninja_file).c_str(), | 53 file.open(FilePathToUTF8(ninja_file).c_str(), |
| 54 std::ios_base::out | std::ios_base::binary); | 54 std::ios_base::out | std::ios_base::binary); |
| 55 if (file.fail()) | 55 if (file.fail()) |
| 56 return false; | 56 return false; |
| 57 | 57 |
| 58 NinjaToolchainWriter gen(settings, toolchain, targets, file); | 58 NinjaToolchainWriter gen(settings, toolchain, targets, file); |
| 59 gen.Run(); | 59 gen.Run(); |
| 60 return true; | 60 return true; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void NinjaToolchainWriter::WriteSubninjas() { | 94 void NinjaToolchainWriter::WriteSubninjas() { |
| 95 // Write subninja commands for each generated target. | 95 // Write subninja commands for each generated target. |
| 96 for (size_t i = 0; i < targets_.size(); i++) { | 96 for (size_t i = 0; i < targets_.size(); i++) { |
| 97 OutputFile ninja_file = helper_.GetNinjaFileForTarget(targets_[i]); | 97 OutputFile ninja_file = helper_.GetNinjaFileForTarget(targets_[i]); |
| 98 out_ << "subninja "; | 98 out_ << "subninja "; |
| 99 path_output_.WriteFile(out_, ninja_file); | 99 path_output_.WriteFile(out_, ninja_file); |
| 100 out_ << std::endl; | 100 out_ << std::endl; |
| 101 } | 101 } |
| 102 out_ << std::endl; | 102 out_ << std::endl; |
| 103 } | 103 } |
| OLD | NEW |