| 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/action_target_generator.h" | 5 #include "tools/gn/action_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/parse_tree.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 if (!FillInputs()) | 42 if (!FillInputs()) |
| 43 return; | 43 return; |
| 44 | 44 |
| 45 if (!FillScript()) | 45 if (!FillScript()) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 if (!FillScriptArgs()) | 48 if (!FillScriptArgs()) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 if (!FillResponseFileContents()) |
| 52 return; |
| 53 |
| 51 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) | 54 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) |
| 52 return; | 55 return; |
| 53 | 56 |
| 54 if (!FillDepfile()) | 57 if (!FillDepfile()) |
| 55 return; | 58 return; |
| 56 | 59 |
| 57 if (!FillConsole()) | 60 if (!FillConsole()) |
| 58 return; | 61 return; |
| 59 | 62 |
| 60 if (!FillCheckIncludes()) | 63 if (!FillCheckIncludes()) |
| 61 return; | 64 return; |
| 62 | 65 |
| 63 if (!CheckOutputs()) | 66 if (!CheckOutputs()) |
| 64 return; | 67 return; |
| 65 | 68 |
| 66 // Action outputs don't depend on the current toolchain so we can skip adding | 69 // Action outputs don't depend on the current toolchain so we can skip adding |
| 67 // that dependency. | 70 // that dependency. |
| 71 |
| 72 // response_file_contents and {{response_file_name}} in the args must go |
| 73 // together. |
| 74 const auto& required_args_substitutions = |
| 75 target_->action_values().args().required_types(); |
| 76 bool has_rsp_file_name = std::find(required_args_substitutions.begin(), |
| 77 required_args_substitutions.end(), |
| 78 SUBSTITUTION_RSP_FILE_NAME) != |
| 79 required_args_substitutions.end(); |
| 80 if (target_->action_values().uses_rsp_file() && !has_rsp_file_name) { |
| 81 *err_ = Err(function_call_, "Missing {{response_file_name}} in args.", |
| 82 "This target defines response_file_contents but doesn't use\n" |
| 83 "{{response_file_name}} in the args, which means the response file\n" |
| 84 "will be unused."); |
| 85 return; |
| 86 } |
| 87 if (!target_->action_values().uses_rsp_file() && has_rsp_file_name) { |
| 88 *err_ = Err(function_call_, "Missing response_file_content definition.", |
| 89 "This target uses {{response_file_name}} in the args, but does not\n" |
| 90 "define response_file_content which means the response file\n" |
| 91 "will be empty."); |
| 92 return; |
| 93 } |
| 68 } | 94 } |
| 69 | 95 |
| 70 bool ActionTargetGenerator::FillScript() { | 96 bool ActionTargetGenerator::FillScript() { |
| 71 // If this gets called, the target type requires a script, so error out | 97 // If this gets called, the target type requires a script, so error out |
| 72 // if it doesn't have one. | 98 // if it doesn't have one. |
| 73 const Value* value = scope_->GetValue(variables::kScript, true); | 99 const Value* value = scope_->GetValue(variables::kScript, true); |
| 74 if (!value) { | 100 if (!value) { |
| 75 *err_ = Err(function_call_, "This target type requires a \"script\"."); | 101 *err_ = Err(function_call_, "This target type requires a \"script\"."); |
| 76 return false; | 102 return false; |
| 77 } | 103 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 return true; | 114 return true; |
| 89 } | 115 } |
| 90 | 116 |
| 91 bool ActionTargetGenerator::FillScriptArgs() { | 117 bool ActionTargetGenerator::FillScriptArgs() { |
| 92 const Value* value = scope_->GetValue(variables::kArgs, true); | 118 const Value* value = scope_->GetValue(variables::kArgs, true); |
| 93 if (!value) | 119 if (!value) |
| 94 return true; | 120 return true; |
| 95 return target_->action_values().args().Parse(*value, err_); | 121 return target_->action_values().args().Parse(*value, err_); |
| 96 } | 122 } |
| 97 | 123 |
| 124 bool ActionTargetGenerator::FillResponseFileContents() { |
| 125 const Value* value = scope_->GetValue(variables::kResponseFileContents, true); |
| 126 if (!value) |
| 127 return true; |
| 128 return target_->action_values().rsp_file_contents().Parse(*value, err_); |
| 129 } |
| 130 |
| 98 bool ActionTargetGenerator::FillDepfile() { | 131 bool ActionTargetGenerator::FillDepfile() { |
| 99 const Value* value = scope_->GetValue(variables::kDepfile, true); | 132 const Value* value = scope_->GetValue(variables::kDepfile, true); |
| 100 if (!value) | 133 if (!value) |
| 101 return true; | 134 return true; |
| 102 | 135 |
| 103 SubstitutionPattern depfile; | 136 SubstitutionPattern depfile; |
| 104 if (!depfile.Parse(*value, err_)) | 137 if (!depfile.Parse(*value, err_)) |
| 105 return false; | 138 return false; |
| 106 if (!EnsureSubstitutionIsInOutputDir(depfile, *value)) | 139 if (!EnsureSubstitutionIsInOutputDir(depfile, *value)) |
| 107 return false; | 140 return false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 *err_ = Err(function_call_, | 176 *err_ = Err(function_call_, |
| 144 "action_foreach should have a pattern in the output.", | 177 "action_foreach should have a pattern in the output.", |
| 145 "An action_foreach target should have a source expansion pattern in\n" | 178 "An action_foreach target should have a source expansion pattern in\n" |
| 146 "it to map source file to unique output file name. Otherwise, the\n" | 179 "it to map source file to unique output file name. Otherwise, the\n" |
| 147 "build system can't determine when your script needs to be run."); | 180 "build system can't determine when your script needs to be run."); |
| 148 return false; | 181 return false; |
| 149 } | 182 } |
| 150 } | 183 } |
| 151 return true; | 184 return true; |
| 152 } | 185 } |
| OLD | NEW |