OLD | NEW |
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/script_target_generator.h" | 5 #include "tools/gn/script_target_generator.h" |
6 | 6 |
7 #include "tools/gn/build_settings.h" | 7 #include "tools/gn/build_settings.h" |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
| 10 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/scope.h" | 11 #include "tools/gn/scope.h" |
11 #include "tools/gn/value.h" | 12 #include "tools/gn/value.h" |
12 #include "tools/gn/value_extractors.h" | 13 #include "tools/gn/value_extractors.h" |
13 #include "tools/gn/variables.h" | 14 #include "tools/gn/variables.h" |
14 | 15 |
15 ScriptTargetGenerator::ScriptTargetGenerator(Target* target, | 16 ScriptTargetGenerator::ScriptTargetGenerator( |
16 Scope* scope, | 17 Target* target, |
17 const Token& function_token, | 18 Scope* scope, |
18 Err* err) | 19 const FunctionCallNode* function_call, |
19 : TargetGenerator(target, scope, function_token, err) { | 20 Err* err) |
| 21 : TargetGenerator(target, scope, function_call, err) { |
20 } | 22 } |
21 | 23 |
22 ScriptTargetGenerator::~ScriptTargetGenerator() { | 24 ScriptTargetGenerator::~ScriptTargetGenerator() { |
23 } | 25 } |
24 | 26 |
25 void ScriptTargetGenerator::DoRun() { | 27 void ScriptTargetGenerator::DoRun() { |
26 target_->set_output_type(Target::CUSTOM); | 28 target_->set_output_type(Target::CUSTOM); |
27 | 29 |
28 FillExternal(); | 30 FillExternal(); |
29 if (err_->has_error()) | 31 if (err_->has_error()) |
(...skipping 25 matching lines...) Expand all Loading... |
55 | 57 |
56 // Script outputs don't depend on the current toolchain so we can skip adding | 58 // Script outputs don't depend on the current toolchain so we can skip adding |
57 // that dependency. | 59 // that dependency. |
58 } | 60 } |
59 | 61 |
60 void ScriptTargetGenerator::FillScript() { | 62 void ScriptTargetGenerator::FillScript() { |
61 // If this gets called, the target type requires a script, so error out | 63 // If this gets called, the target type requires a script, so error out |
62 // if it doesn't have one. | 64 // if it doesn't have one. |
63 const Value* value = scope_->GetValue(variables::kScript, true); | 65 const Value* value = scope_->GetValue(variables::kScript, true); |
64 if (!value) { | 66 if (!value) { |
65 *err_ = Err(function_token_, "This target type requires a \"script\"."); | 67 *err_ = Err(function_call_, "This target type requires a \"script\"."); |
66 return; | 68 return; |
67 } | 69 } |
68 if (!value->VerifyTypeIs(Value::STRING, err_)) | 70 if (!value->VerifyTypeIs(Value::STRING, err_)) |
69 return; | 71 return; |
70 | 72 |
71 target_->script_values().set_script( | 73 target_->script_values().set_script( |
72 scope_->GetSourceDir().ResolveRelativeFile(value->string_value())); | 74 scope_->GetSourceDir().ResolveRelativeFile(value->string_value())); |
73 } | 75 } |
74 | 76 |
75 void ScriptTargetGenerator::FillScriptArgs() { | 77 void ScriptTargetGenerator::FillScriptArgs() { |
76 const Value* value = scope_->GetValue(variables::kArgs, true); | 78 const Value* value = scope_->GetValue(variables::kArgs, true); |
77 if (!value) | 79 if (!value) |
78 return; | 80 return; |
79 | 81 |
80 std::vector<std::string> args; | 82 std::vector<std::string> args; |
81 if (!ExtractListOfStringValues(*value, &args, err_)) | 83 if (!ExtractListOfStringValues(*value, &args, err_)) |
82 return; | 84 return; |
83 target_->script_values().swap_in_args(&args); | 85 target_->script_values().swap_in_args(&args); |
84 } | 86 } |
85 | 87 |
86 void ScriptTargetGenerator::FillDepfile() { | 88 void ScriptTargetGenerator::FillDepfile() { |
87 const Value* value = scope_->GetValue(variables::kDepfile, true); | 89 const Value* value = scope_->GetValue(variables::kDepfile, true); |
88 if (!value) | 90 if (!value) |
89 return; | 91 return; |
90 target_->script_values().set_depfile( | 92 target_->script_values().set_depfile( |
91 scope_->settings()->build_settings()->build_dir().ResolveRelativeFile( | 93 scope_->settings()->build_settings()->build_dir().ResolveRelativeFile( |
92 value->string_value())); | 94 value->string_value())); |
93 } | 95 } |
OLD | NEW |