| 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/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void NinjaToolchainWriter::WriteToolRule(const Toolchain::ToolType type, | 80 void NinjaToolchainWriter::WriteToolRule(const Toolchain::ToolType type, |
| 81 const Tool* tool, | 81 const Tool* tool, |
| 82 const std::string& rule_prefix) { | 82 const std::string& rule_prefix) { |
| 83 out_ << "rule " << rule_prefix << Toolchain::ToolTypeToName(type) | 83 out_ << "rule " << rule_prefix << Toolchain::ToolTypeToName(type) |
| 84 << std::endl; | 84 << std::endl; |
| 85 | 85 |
| 86 // Rules explicitly include shell commands, so don't try to escape. | 86 // Rules explicitly include shell commands, so don't try to escape. |
| 87 EscapeOptions options; | 87 EscapeOptions options; |
| 88 options.mode = ESCAPE_NINJA_PREFORMATTED_COMMAND; | 88 options.mode = ESCAPE_NINJA_PREFORMATTED_COMMAND; |
| 89 | 89 |
| 90 CHECK(!tool->command().empty()) << "Command should not be empty"; | 90 // Command should not be empty |
| 91 CHECK(!tool->command().empty()); |
| 91 WriteRulePattern("command", tool->command(), options); | 92 WriteRulePattern("command", tool->command(), options); |
| 92 | 93 |
| 93 WriteRulePattern("description", tool->description(), options); | 94 WriteRulePattern("description", tool->description(), options); |
| 94 WriteRulePattern("rspfile", tool->rspfile(), options); | 95 WriteRulePattern("rspfile", tool->rspfile(), options); |
| 95 WriteRulePattern("rspfile_content", tool->rspfile_content(), options); | 96 WriteRulePattern("rspfile_content", tool->rspfile_content(), options); |
| 96 | 97 |
| 97 if (tool->depsformat() == Tool::DEPS_GCC) { | 98 if (tool->depsformat() == Tool::DEPS_GCC) { |
| 98 // GCC-style deps require a depfile. | 99 // GCC-style deps require a depfile. |
| 99 if (!tool->depfile().empty()) { | 100 if (!tool->depfile().empty()) { |
| 100 WriteRulePattern("depfile", tool->depfile(), options); | 101 WriteRulePattern("depfile", tool->depfile(), options); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 | 119 |
| 119 void NinjaToolchainWriter::WriteRulePattern(const char* name, | 120 void NinjaToolchainWriter::WriteRulePattern(const char* name, |
| 120 const SubstitutionPattern& pattern, | 121 const SubstitutionPattern& pattern, |
| 121 const EscapeOptions& options) { | 122 const EscapeOptions& options) { |
| 122 if (pattern.empty()) | 123 if (pattern.empty()) |
| 123 return; | 124 return; |
| 124 out_ << kIndent << name << " = "; | 125 out_ << kIndent << name << " = "; |
| 125 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); | 126 SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_); |
| 126 out_ << std::endl; | 127 out_ << std::endl; |
| 127 } | 128 } |
| OLD | NEW |