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) |