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/err.h" | 8 #include "tools/gn/err.h" |
8 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
9 #include "tools/gn/scope.h" | 10 #include "tools/gn/scope.h" |
10 #include "tools/gn/value.h" | 11 #include "tools/gn/value.h" |
11 #include "tools/gn/value_extractors.h" | 12 #include "tools/gn/value_extractors.h" |
12 #include "tools/gn/variables.h" | 13 #include "tools/gn/variables.h" |
13 | 14 |
14 ScriptTargetGenerator::ScriptTargetGenerator(Target* target, | 15 ScriptTargetGenerator::ScriptTargetGenerator(Target* target, |
15 Scope* scope, | 16 Scope* scope, |
16 const Token& function_token, | 17 const Token& function_token, |
(...skipping 24 matching lines...) Expand all Loading... |
41 return; | 42 return; |
42 | 43 |
43 FillScriptArgs(); | 44 FillScriptArgs(); |
44 if (err_->has_error()) | 45 if (err_->has_error()) |
45 return; | 46 return; |
46 | 47 |
47 FillOutputs(); | 48 FillOutputs(); |
48 if (err_->has_error()) | 49 if (err_->has_error()) |
49 return; | 50 return; |
50 | 51 |
| 52 FillDepfile(); |
| 53 if (err_->has_error()) |
| 54 return; |
| 55 |
51 // Script outputs don't depend on the current toolchain so we can skip adding | 56 // Script outputs don't depend on the current toolchain so we can skip adding |
52 // that dependency. | 57 // that dependency. |
53 } | 58 } |
54 | 59 |
55 void ScriptTargetGenerator::FillScript() { | 60 void ScriptTargetGenerator::FillScript() { |
56 // If this gets called, the target type requires a script, so error out | 61 // If this gets called, the target type requires a script, so error out |
57 // if it doesn't have one. | 62 // if it doesn't have one. |
58 const Value* value = scope_->GetValue(variables::kScript, true); | 63 const Value* value = scope_->GetValue(variables::kScript, true); |
59 if (!value) { | 64 if (!value) { |
60 *err_ = Err(function_token_, "This target type requires a \"script\"."); | 65 *err_ = Err(function_token_, "This target type requires a \"script\"."); |
61 return; | 66 return; |
62 } | 67 } |
63 if (!value->VerifyTypeIs(Value::STRING, err_)) | 68 if (!value->VerifyTypeIs(Value::STRING, err_)) |
64 return; | 69 return; |
65 | 70 |
66 target_->script_values().set_script( | 71 target_->script_values().set_script( |
67 scope_->GetSourceDir().ResolveRelativeFile(value->string_value())); | 72 scope_->GetSourceDir().ResolveRelativeFile(value->string_value())); |
68 } | 73 } |
69 | 74 |
70 void ScriptTargetGenerator::FillScriptArgs() { | 75 void ScriptTargetGenerator::FillScriptArgs() { |
71 const Value* value = scope_->GetValue(variables::kArgs, true); | 76 const Value* value = scope_->GetValue(variables::kArgs, true); |
72 if (!value) | 77 if (!value) |
73 return; | 78 return; |
74 | 79 |
75 std::vector<std::string> args; | 80 std::vector<std::string> args; |
76 if (!ExtractListOfStringValues(*value, &args, err_)) | 81 if (!ExtractListOfStringValues(*value, &args, err_)) |
77 return; | 82 return; |
78 target_->script_values().swap_in_args(&args); | 83 target_->script_values().swap_in_args(&args); |
79 } | 84 } |
| 85 |
| 86 void ScriptTargetGenerator::FillDepfile() { |
| 87 const Value* value = scope_->GetValue(variables::kDepfile, true); |
| 88 if (!value) |
| 89 return; |
| 90 target_->script_values().set_depfile( |
| 91 scope_->settings()->build_settings()->build_dir().ResolveRelativeFile( |
| 92 value->string_value())); |
| 93 } |
OLD | NEW |