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

Unified Diff: tools/gn/config_values_generator.cc

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_generator.h ('k') | tools/gn/err.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/config_values_generator.cc
diff --git a/tools/gn/config_values_generator.cc b/tools/gn/config_values_generator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..34c3f678f8093508e3e7aa9a16d1606f25fc8688
--- /dev/null
+++ b/tools/gn/config_values_generator.cc
@@ -0,0 +1,89 @@
+// 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.
+
+#include "tools/gn/config_values_generator.h"
+
+#include "tools/gn/config_values.h"
+#include "tools/gn/scope.h"
+#include "tools/gn/value.h"
+#include "tools/gn/value_extractors.h"
+
+namespace {
+
+void GetStringList(
+ const Scope* scope,
+ const char* var_name,
+ ConfigValues* config_values,
+ void (ConfigValues::* swapper_inner)(std::vector<std::string>*),
+ Err* err) {
+ const Value* value = scope->GetValue(var_name);
+ if (!value)
+ return; // No value, empty input and succeed.
+
+ std::vector<std::string> result;
+ ExtractListOfStringValues(*value, &result, err);
+ (config_values->*swapper_inner)(&result);
+}
+
+} // namespace
+
+ConfigValuesGenerator::ConfigValuesGenerator(ConfigValues* dest_values,
+ const Scope* scope,
+ const Token& function_token,
+ const SourceDir& input_dir,
+ Err* err)
+ : config_values_(dest_values),
+ scope_(scope),
+ function_token_(function_token),
+ input_dir_(input_dir),
+ err_(err) {
+}
+
+ConfigValuesGenerator::~ConfigValuesGenerator() {
+}
+
+void ConfigValuesGenerator::Run() {
+ FillDefines();
+ FillIncludes();
+ FillCflags();
+ FillCflags_C();
+ FillCflags_CC();
+ FillLdflags();
+}
+
+void ConfigValuesGenerator::FillDefines() {
+ GetStringList(scope_, "defines", config_values_,
+ &ConfigValues::swap_in_defines, err_);
+}
+
+void ConfigValuesGenerator::FillIncludes() {
+ const Value* value = scope_->GetValue("includes");
+ if (!value)
+ return; // No value, empty input and succeed.
+
+ std::vector<SourceDir> includes;
+ if (!ExtractListOfRelativeDirs(*value, input_dir_, &includes, err_))
+ return;
+ config_values_->swap_in_includes(&includes);
+}
+
+void ConfigValuesGenerator::FillCflags() {
+ GetStringList(scope_, "cflags", config_values_,
+ &ConfigValues::swap_in_cflags, err_);
+}
+
+void ConfigValuesGenerator::FillCflags_C() {
+ GetStringList(scope_, "cflags_c", config_values_,
+ &ConfigValues::swap_in_cflags_c, err_);
+}
+
+void ConfigValuesGenerator::FillCflags_CC() {
+ GetStringList(scope_, "cflags_cc", config_values_,
+ &ConfigValues::swap_in_cflags_cc, err_);
+}
+
+void ConfigValuesGenerator::FillLdflags() {
+ GetStringList(scope_, "ldflags", config_values_,
+ &ConfigValues::swap_in_ldflags, err_);
+}
« no previous file with comments | « tools/gn/config_values_generator.h ('k') | tools/gn/err.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698