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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/binary_target_generator.h" 5 #include "tools/gn/binary_target_generator.h"
6 6
7 #include "tools/gn/config_values_generator.h" 7 #include "tools/gn/config_values_generator.h"
8 #include "tools/gn/deps_iterator.h" 8 #include "tools/gn/deps_iterator.h"
9 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
10 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/functions.h" 11 #include "tools/gn/functions.h"
11 #include "tools/gn/scope.h" 12 #include "tools/gn/scope.h"
13 #include "tools/gn/settings.h"
12 #include "tools/gn/value_extractors.h" 14 #include "tools/gn/value_extractors.h"
13 #include "tools/gn/variables.h" 15 #include "tools/gn/variables.h"
14 16
15 BinaryTargetGenerator::BinaryTargetGenerator( 17 BinaryTargetGenerator::BinaryTargetGenerator(
16 Target* target, 18 Target* target,
17 Scope* scope, 19 Scope* scope,
18 const FunctionCallNode* function_call, 20 const FunctionCallNode* function_call,
19 Target::OutputType type, 21 Target::OutputType type,
20 Err* err) 22 Err* err)
21 : TargetGenerator(target, scope, function_call, err), 23 : TargetGenerator(target, scope, function_call, err),
22 output_type_(type) { 24 output_type_(type) {
23 } 25 }
24 26
25 BinaryTargetGenerator::~BinaryTargetGenerator() { 27 BinaryTargetGenerator::~BinaryTargetGenerator() {
26 } 28 }
27 29
28 void BinaryTargetGenerator::DoRun() { 30 void BinaryTargetGenerator::DoRun() {
29 target_->set_output_type(output_type_); 31 target_->set_output_type(output_type_);
30 32
31 if (!FillOutputName()) 33 if (!FillOutputName())
32 return; 34 return;
33 35
34 if (!FillOutputPrefixOverride()) 36 if (!FillOutputPrefixOverride())
35 return; 37 return;
36 38
39 if (!FillOutputDir())
40 return;
41
37 if (!FillOutputExtension()) 42 if (!FillOutputExtension())
38 return; 43 return;
39 44
40 if (!FillSources()) 45 if (!FillSources())
41 return; 46 return;
42 47
43 if (!FillPublic()) 48 if (!FillPublic())
44 return; 49 return;
45 50
46 if (!FillCheckIncludes()) 51 if (!FillCheckIncludes())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 bool BinaryTargetGenerator::FillOutputPrefixOverride() { 96 bool BinaryTargetGenerator::FillOutputPrefixOverride() {
92 const Value* value = scope_->GetValue(variables::kOutputPrefixOverride, true); 97 const Value* value = scope_->GetValue(variables::kOutputPrefixOverride, true);
93 if (!value) 98 if (!value)
94 return true; 99 return true;
95 if (!value->VerifyTypeIs(Value::BOOLEAN, err_)) 100 if (!value->VerifyTypeIs(Value::BOOLEAN, err_))
96 return false; 101 return false;
97 target_->set_output_prefix_override(value->boolean_value()); 102 target_->set_output_prefix_override(value->boolean_value());
98 return true; 103 return true;
99 } 104 }
100 105
106 bool BinaryTargetGenerator::FillOutputDir() {
107 const Value* value = scope_->GetValue(variables::kOutputDir, true);
108 if (!value)
109 return true;
110 if (!value->VerifyTypeIs(Value::STRING, err_))
111 return false;
112
113 if (value->string_value().empty())
114 return true; // Treat empty string as the default and do nothing.
115
116 const BuildSettings* build_settings = scope_->settings()->build_settings();
117 SourceDir dir = scope_->GetSourceDir().ResolveRelativeDir(
118 *value, err_, build_settings->root_path_utf8());
119 if (err_->has_error())
120 return false;
121
122 if (!EnsureStringIsInOutputDir(build_settings->build_dir(),
123 dir.value(), value->origin(), err_))
124 return false;
125 target_->set_output_dir(dir);
126 return true;
127 }
128
101 bool BinaryTargetGenerator::FillOutputExtension() { 129 bool BinaryTargetGenerator::FillOutputExtension() {
102 const Value* value = scope_->GetValue(variables::kOutputExtension, true); 130 const Value* value = scope_->GetValue(variables::kOutputExtension, true);
103 if (!value) 131 if (!value)
104 return true; 132 return true;
105 if (!value->VerifyTypeIs(Value::STRING, err_)) 133 if (!value->VerifyTypeIs(Value::STRING, err_))
106 return false; 134 return false;
107 target_->set_output_extension(value->string_value()); 135 target_->set_output_extension(value->string_value());
108 return true; 136 return true;
109 } 137 }
110 138
(...skipping 26 matching lines...) Expand all
137 "deps."); 165 "deps.");
138 return false; 166 return false;
139 } 167 }
140 } 168 }
141 169
142 // Add to the set. 170 // Add to the set.
143 for (const auto& cur : circular) 171 for (const auto& cur : circular)
144 target_->allow_circular_includes_from().insert(cur); 172 target_->allow_circular_includes_from().insert(cur);
145 return true; 173 return true;
146 } 174 }
OLDNEW
« 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