Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 if (!FillScriptArgs()) | 48 if (!FillScriptArgs()) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) | 51 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 if (!FillDepfile()) | 54 if (!FillDepfile()) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 if (!FillCheckIncludes()) | |
| 58 return; | |
| 59 | |
| 57 if (!CheckOutputs()) | 60 if (!CheckOutputs()) |
| 58 return; | 61 return; |
| 59 | 62 |
| 60 // Action outputs don't depend on the current toolchain so we can skip adding | 63 // Action outputs don't depend on the current toolchain so we can skip adding |
| 61 // that dependency. | 64 // that dependency. |
| 62 } | 65 } |
| 63 | 66 |
| 64 bool ActionTargetGenerator::FillScript() { | 67 bool ActionTargetGenerator::FillScript() { |
| 65 // If this gets called, the target type requires a script, so error out | 68 // If this gets called, the target type requires a script, so error out |
| 66 // if it doesn't have one. | 69 // if it doesn't have one. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 SubstitutionPattern depfile; | 101 SubstitutionPattern depfile; |
| 99 if (!depfile.Parse(*value, err_)) | 102 if (!depfile.Parse(*value, err_)) |
| 100 return false; | 103 return false; |
| 101 if (!EnsureSubstitutionIsInOutputDir(depfile, *value)) | 104 if (!EnsureSubstitutionIsInOutputDir(depfile, *value)) |
| 102 return false; | 105 return false; |
| 103 | 106 |
| 104 target_->action_values().set_depfile(depfile); | 107 target_->action_values().set_depfile(depfile); |
| 105 return true; | 108 return true; |
| 106 } | 109 } |
| 107 | 110 |
| 111 bool ActionTargetGenerator::FillCheckIncludes() { | |
|
brettw
2015/01/30 23:08:55
To avoid duplication with the binary target genera
tfarina
2015/01/30 23:18:29
Done.
| |
| 112 const Value* value = scope_->GetValue(variables::kCheckIncludes, true); | |
| 113 if (!value) | |
| 114 return true; | |
| 115 if (!value->VerifyTypeIs(Value::BOOLEAN, err_)) | |
| 116 return false; | |
| 117 target_->set_check_includes(value->boolean_value()); | |
| 118 return true; | |
| 119 } | |
| 120 | |
| 108 bool ActionTargetGenerator::CheckOutputs() { | 121 bool ActionTargetGenerator::CheckOutputs() { |
| 109 const SubstitutionList& outputs = target_->action_values().outputs(); | 122 const SubstitutionList& outputs = target_->action_values().outputs(); |
| 110 if (outputs.list().empty()) { | 123 if (outputs.list().empty()) { |
| 111 *err_ = Err(function_call_, "Action has no outputs.", | 124 *err_ = Err(function_call_, "Action has no outputs.", |
| 112 "If you have no outputs, the build system can not tell when your\n" | 125 "If you have no outputs, the build system can not tell when your\n" |
| 113 "script needs to be run."); | 126 "script needs to be run."); |
| 114 return false; | 127 return false; |
| 115 } | 128 } |
| 116 | 129 |
| 117 if (output_type_ == Target::ACTION) { | 130 if (output_type_ == Target::ACTION) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 128 *err_ = Err(function_call_, | 141 *err_ = Err(function_call_, |
| 129 "action_foreach should have a pattern in the output.", | 142 "action_foreach should have a pattern in the output.", |
| 130 "An action_foreach target should have a source expansion pattern in\n" | 143 "An action_foreach target should have a source expansion pattern in\n" |
| 131 "it to map source file to unique output file name. Otherwise, the\n" | 144 "it to map source file to unique output file name. Otherwise, the\n" |
| 132 "build system can't determine when your script needs to be run."); | 145 "build system can't determine when your script needs to be run."); |
| 133 return false; | 146 return false; |
| 134 } | 147 } |
| 135 } | 148 } |
| 136 return true; | 149 return true; |
| 137 } | 150 } |
| OLD | NEW |