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

Unified Diff: tools/gn/binary_target_generator.cc

Issue 1887533003: Add an output_dir override to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const Created 4 years, 8 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/binary_target_generator.h ('k') | tools/gn/docs/reference.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/binary_target_generator.cc
diff --git a/tools/gn/binary_target_generator.cc b/tools/gn/binary_target_generator.cc
index 7c81232dacc2de445f9451bed52a953d84cd3964..78280132bed7d3222aa653a8f1a13af4fd4fc4e9 100644
--- a/tools/gn/binary_target_generator.cc
+++ b/tools/gn/binary_target_generator.cc
@@ -7,8 +7,10 @@
#include "tools/gn/config_values_generator.h"
#include "tools/gn/deps_iterator.h"
#include "tools/gn/err.h"
+#include "tools/gn/filesystem_utils.h"
#include "tools/gn/functions.h"
#include "tools/gn/scope.h"
+#include "tools/gn/settings.h"
#include "tools/gn/value_extractors.h"
#include "tools/gn/variables.h"
@@ -34,6 +36,9 @@ void BinaryTargetGenerator::DoRun() {
if (!FillOutputPrefixOverride())
return;
+ if (!FillOutputDir())
+ return;
+
if (!FillOutputExtension())
return;
@@ -98,6 +103,29 @@ bool BinaryTargetGenerator::FillOutputPrefixOverride() {
return true;
}
+bool BinaryTargetGenerator::FillOutputDir() {
+ const Value* value = scope_->GetValue(variables::kOutputDir, true);
+ if (!value)
+ return true;
+ if (!value->VerifyTypeIs(Value::STRING, err_))
+ return false;
+
+ if (value->string_value().empty())
+ return true; // Treat empty string as the default and do nothing.
+
+ const BuildSettings* build_settings = scope_->settings()->build_settings();
+ SourceDir dir = scope_->GetSourceDir().ResolveRelativeDir(
+ *value, err_, build_settings->root_path_utf8());
+ if (err_->has_error())
+ return false;
+
+ if (!EnsureStringIsInOutputDir(build_settings->build_dir(),
+ dir.value(), value->origin(), err_))
+ return false;
+ target_->set_output_dir(dir);
+ return true;
+}
+
bool BinaryTargetGenerator::FillOutputExtension() {
const Value* value = scope_->GetValue(variables::kOutputExtension, true);
if (!value)
« no previous file with comments | « tools/gn/binary_target_generator.h ('k') | tools/gn/docs/reference.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698