Index: tools/gn/action_target_generator.cc |
diff --git a/tools/gn/action_target_generator.cc b/tools/gn/action_target_generator.cc |
index 40523fe08b94ecd12bf00cf4dac9ee1994f74db4..b2d7e2757a5059397cf32089b2ddecd028f8114c 100644 |
--- a/tools/gn/action_target_generator.cc |
+++ b/tools/gn/action_target_generator.cc |
@@ -48,6 +48,9 @@ void ActionTargetGenerator::DoRun() { |
if (!FillScriptArgs()) |
return; |
+ if (!FillResponseFileContents()) |
+ return; |
+ |
if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) |
return; |
@@ -65,6 +68,29 @@ void ActionTargetGenerator::DoRun() { |
// Action outputs don't depend on the current toolchain so we can skip adding |
// that dependency. |
+ |
+ // response_file_contents and {{response_file_name}} in the args must go |
+ // together. |
+ const auto& required_args_substitutions = |
+ target_->action_values().args().required_types(); |
+ bool has_rsp_file_name = std::find(required_args_substitutions.begin(), |
+ required_args_substitutions.end(), |
+ SUBSTITUTION_RSP_FILE_NAME) != |
+ required_args_substitutions.end(); |
+ if (target_->action_values().uses_rsp_file() && !has_rsp_file_name) { |
+ *err_ = Err(function_call_, "Missing {{response_file_name}} in args.", |
+ "This target defines response_file_contents but doesn't use\n" |
+ "{{response_file_name}} in the args, which means the response file\n" |
+ "will be unused."); |
+ return; |
+ } |
+ if (!target_->action_values().uses_rsp_file() && has_rsp_file_name) { |
+ *err_ = Err(function_call_, "Missing response_file_content definition.", |
+ "This target uses {{response_file_name}} in the args, but does not\n" |
+ "define response_file_content which means the response file\n" |
+ "will be empty."); |
+ return; |
+ } |
} |
bool ActionTargetGenerator::FillScript() { |
@@ -95,6 +121,13 @@ bool ActionTargetGenerator::FillScriptArgs() { |
return target_->action_values().args().Parse(*value, err_); |
} |
+bool ActionTargetGenerator::FillResponseFileContents() { |
+ const Value* value = scope_->GetValue(variables::kResponseFileContents, true); |
+ if (!value) |
+ return true; |
+ return target_->action_values().rsp_file_contents().Parse(*value, err_); |
+} |
+ |
bool ActionTargetGenerator::FillDepfile() { |
const Value* value = scope_->GetValue(variables::kDepfile, true); |
if (!value) |