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/copy_target_generator.h" | 5 #include "tools/gn/copy_target_generator.h" |
6 | 6 |
7 #include "tools/gn/build_settings.h" | 7 #include "tools/gn/build_settings.h" |
8 #include "tools/gn/filesystem_utils.h" | 8 #include "tools/gn/filesystem_utils.h" |
| 9 #include "tools/gn/parse_tree.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 | 12 |
12 CopyTargetGenerator::CopyTargetGenerator(Target* target, | 13 CopyTargetGenerator::CopyTargetGenerator(Target* target, |
13 Scope* scope, | 14 Scope* scope, |
14 const Token& function_token, | 15 const FunctionCallNode* function_call, |
15 Err* err) | 16 Err* err) |
16 : TargetGenerator(target, scope, function_token, err) { | 17 : TargetGenerator(target, scope, function_call, err) { |
17 } | 18 } |
18 | 19 |
19 CopyTargetGenerator::~CopyTargetGenerator() { | 20 CopyTargetGenerator::~CopyTargetGenerator() { |
20 } | 21 } |
21 | 22 |
22 void CopyTargetGenerator::DoRun() { | 23 void CopyTargetGenerator::DoRun() { |
23 target_->set_output_type(Target::COPY_FILES); | 24 target_->set_output_type(Target::COPY_FILES); |
24 | 25 |
25 FillExternal(); | 26 FillExternal(); |
26 if (err_->has_error()) | 27 if (err_->has_error()) |
27 return; | 28 return; |
28 FillSources(); | 29 FillSources(); |
29 if (err_->has_error()) | 30 if (err_->has_error()) |
30 return; | 31 return; |
31 FillOutputs(); | 32 FillOutputs(); |
32 if (err_->has_error()) | 33 if (err_->has_error()) |
33 return; | 34 return; |
34 | 35 |
35 if (target_->sources().empty()) { | 36 if (target_->sources().empty()) { |
36 *err_ = Err(function_token_, "Empty sources for copy command.", | 37 *err_ = Err(function_call_, "Empty sources for copy command.", |
37 "You have to specify at least one file to copy in the \"sources\"."); | 38 "You have to specify at least one file to copy in the \"sources\"."); |
38 return; | 39 return; |
39 } | 40 } |
40 if (target_->script_values().outputs().size() != 1) { | 41 if (target_->script_values().outputs().size() != 1) { |
41 *err_ = Err(function_token_, "Copy command must have exactly one output.", | 42 *err_ = Err(function_call_, "Copy command must have exactly one output.", |
42 "You must specify exactly one value in the \"outputs\" array for the " | 43 "You must specify exactly one value in the \"outputs\" array for the " |
43 "destination of the copy\n(see \"gn help copy\"). If there are " | 44 "destination of the copy\n(see \"gn help copy\"). If there are " |
44 "multiple sources to copy, use source expansion\n(see \"gn help " | 45 "multiple sources to copy, use source expansion\n(see \"gn help " |
45 "source_expansion\")."); | 46 "source_expansion\")."); |
46 return; | 47 return; |
47 } | 48 } |
48 | |
49 SetToolchainDependency(); | |
50 } | 49 } |
OLD | NEW |