OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "tools/gn/pool.h" |
| 6 |
| 7 #include <sstream> |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 Pool::Pool(const Settings* settings, const Label& label) |
| 12 : Item(settings, label) {} |
| 13 |
| 14 Pool::~Pool() {} |
| 15 |
| 16 Pool* Pool::AsPool() { |
| 17 return this; |
| 18 } |
| 19 |
| 20 const Pool* Pool::AsPool() const { |
| 21 return this; |
| 22 } |
| 23 |
| 24 std::string Pool::GetNinjaName(const Label& default_toolchain) const { |
| 25 bool include_toolchain = label().toolchain_dir() != default_toolchain.dir() || |
| 26 label().toolchain_name() != default_toolchain.name(); |
| 27 return GetNinjaName(include_toolchain); |
| 28 } |
| 29 |
| 30 std::string Pool::GetNinjaName(bool include_toolchain) const { |
| 31 std::ostringstream buffer; |
| 32 if (include_toolchain) { |
| 33 DCHECK(label().toolchain_dir().is_source_absolute()); |
| 34 std::string toolchain_dir = label().toolchain_dir().value(); |
| 35 for (std::string::size_type i = 2; i < toolchain_dir.size(); ++i) { |
| 36 buffer << (toolchain_dir[i] == '/' ? '_' : toolchain_dir[i]); |
| 37 } |
| 38 buffer << label().toolchain_name() << "_"; |
| 39 } |
| 40 |
| 41 DCHECK(label().dir().is_source_absolute()); |
| 42 std::string label_dir = label().dir().value(); |
| 43 for (std::string::size_type i = 2; i < label_dir.size(); ++i) { |
| 44 buffer << (label_dir[i] == '/' ? '_' : label_dir[i]); |
| 45 } |
| 46 buffer << label().name(); |
| 47 return buffer.str(); |
| 48 } |
OLD | NEW |