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

Unified Diff: tools/gn/config_values_extractors.h

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 5 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
« no previous file with comments | « tools/gn/config_values.cc ('k') | tools/gn/config_values_extractors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/config_values_extractors.h
diff --git a/tools/gn/config_values_extractors.h b/tools/gn/config_values_extractors.h
new file mode 100644
index 0000000000000000000000000000000000000000..0eaa2c9263b61509e7f595384700866a8bcab655
--- /dev/null
+++ b/tools/gn/config_values_extractors.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 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.
+
+#ifndef TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_
+#define TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_
+
+#include <ostream>
+#include <string>
+#include <vector>
+
+#include "tools/gn/config.h"
+#include "tools/gn/config_values.h"
+#include "tools/gn/target.h"
+
+template<typename T, class Writer>
+inline void ConfigValuesToStream(
+ const ConfigValues& values,
+ const std::vector<T>& (ConfigValues::* getter)() const,
+ const Writer& writer,
+ std::ostream& out) {
+ const std::vector<T>& v = (values.*getter)();
+ for (size_t i = 0; i < v.size(); i++)
+ writer(v[i], out);
+};
+
+template<typename T, class Writer>
+inline void RecursiveTargetConfigToStream(
+ const Target* target,
+ const std::vector<T>& (ConfigValues::* getter)() const,
+ const Writer& writer,
+ std::ostream& out) {
+ // Write all configs in reverse order (to get oldest first, which will look
+ // more normal in the output).
+ for (int i = static_cast<int>(target->configs().size() - 1); i >= 0; i--) {
+ ConfigValuesToStream(target->configs()[i]->config_values(), getter,
+ writer, out);
+ }
+
+ // Last write from the config from the Target itself, if any.
+ ConfigValuesToStream(target->config_values(), getter, writer, out);
+}
+
+// Writes the values out as strings with no transformation.
+void RecursiveTargetConfigStringsToStream(
+ const Target* target,
+ const std::vector<std::string>& (ConfigValues::* getter)() const,
+ std::ostream& out);
+
+#endif // TOOLS_GN_CONFIG_VALUES_EXTRACTORS_H_
« no previous file with comments | « tools/gn/config_values.cc ('k') | tools/gn/config_values_extractors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698