Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1758)

Unified Diff: tools/gn/pool.cc

Issue 2006923004: Add support for user defined "pool" to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/gn/functions.cc ('K') | « tools/gn/pool.h ('k') | tools/gn/tool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/pool.cc
diff --git a/tools/gn/pool.cc b/tools/gn/pool.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e4fc2062f19f2ef526e4f3c2336328c2ab4607d8
--- /dev/null
+++ b/tools/gn/pool.cc
@@ -0,0 +1,48 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/gn/pool.h"
+
+#include <sstream>
+
+#include "base/logging.h"
+
+Pool::Pool(const Settings* settings, const Label& label)
+ : Item(settings, label) {}
+
+Pool::~Pool() {}
+
+Pool* Pool::AsPool() {
+ return this;
+}
+
+const Pool* Pool::AsPool() const {
+ return this;
+}
+
+std::string Pool::GetNinjaName(const Label& default_toolchain) const {
+ bool include_toolchain = label().toolchain_dir() != default_toolchain.dir() ||
+ label().toolchain_name() != default_toolchain.name();
+ return GetNinjaName(include_toolchain);
+}
+
+std::string Pool::GetNinjaName(bool include_toolchain) const {
+ std::ostringstream buffer;
+ if (include_toolchain) {
+ DCHECK(label().toolchain_dir().is_source_absolute());
+ std::string toolchain_dir = label().toolchain_dir().value();
+ for (std::string::size_type i = 2; i < toolchain_dir.size(); ++i) {
+ buffer << (toolchain_dir[i] == '/' ? '_' : toolchain_dir[i]);
+ }
+ buffer << label().toolchain_name() << "_";
+ }
+
+ DCHECK(label().dir().is_source_absolute());
+ std::string label_dir = label().dir().value();
+ for (std::string::size_type i = 2; i < label_dir.size(); ++i) {
+ buffer << (label_dir[i] == '/' ? '_' : label_dir[i]);
+ }
+ buffer << label().name();
+ return buffer.str();
+}
« tools/gn/functions.cc ('K') | « tools/gn/pool.h ('k') | tools/gn/tool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698