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 3 // found in the LICENSE file. 4 5 #include "tools/gn/binary_target_generator.h" 6 7 #include "tools/gn/config_values_generator.h" 8 #include "tools/gn/err.h" 9 #include "tools/gn/scope.h" 10 #include "tools/gn/variables.h" 11 12 BinaryTargetGenerator::BinaryTargetGenerator( 13 Target* target, 14 Scope* scope, 15 const FunctionCallNode* function_call, 16 Target::OutputType type, 17 Err* err) 18 : TargetGenerator(target, scope, function_call, err), 19 output_type_(type) { 20 } 21 22 BinaryTargetGenerator::~BinaryTargetGenerator() { 23 } 24 25 void BinaryTargetGenerator::DoRun() { 26 target_->set_output_type(output_type_); 27 28 FillOutputName(); 29 if (err_->has_error()) 30 return; 31 32 FillExternal(); 33 if (err_->has_error()) 34 return; 35 36 FillSources(); 37 if (err_->has_error()) 38 return; 39 40 FillSourcePrereqs(); 41 if (err_->has_error()) 42 return; 43 44 FillConfigs(); 45 if (err_->has_error()) 46 return; 47 48 // Config values (compiler flags, etc.) set directly on this target. 49 ConfigValuesGenerator gen(&target_->config_values(), scope_, 50 scope_->GetSourceDir(), err_); 51 gen.Run(); 52 if (err_->has_error()) 53 return; 54 } 55 56 void BinaryTargetGenerator::FillOutputName() { 57 const Value* value = scope_->GetValue(variables::kOutputName, true); 58 if (!value) 59 return; 60 if (!value->VerifyTypeIs(Value::STRING, err_)) 61 return; 62 target_->set_output_name(value->string_value()); 63 } 64