OLD | NEW |
(Empty) | |
| 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 #ifndef TOOLS_GN_TARGET_GENERATOR_H_ |
| 6 #define TOOLS_GN_TARGET_GENERATOR_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "tools/gn/source_dir.h" |
| 15 #include "tools/gn/target.h" |
| 16 |
| 17 class BuildSettings; |
| 18 class Err; |
| 19 class Location; |
| 20 class Scope; |
| 21 class Token; |
| 22 class Value; |
| 23 |
| 24 // Creates Target objects from a Scope (the result of a script execution). |
| 25 class TargetGenerator { |
| 26 public: |
| 27 TargetGenerator(Target* target, |
| 28 Scope* scope, |
| 29 const Token& function_token, |
| 30 const std::vector<Value>& args, |
| 31 const std::string& output_type, |
| 32 Err* err); |
| 33 ~TargetGenerator(); |
| 34 |
| 35 void Run(); |
| 36 |
| 37 // The function token is the token of the function name of the generator for |
| 38 // this target. err() will be set on failure. |
| 39 static void GenerateTarget(Scope* scope, |
| 40 const Token& function_token, |
| 41 const std::vector<Value>& args, |
| 42 const std::string& output_type, |
| 43 Err* err); |
| 44 |
| 45 private: |
| 46 // Sets err_ on failure. |
| 47 Target::OutputType GetOutputType() const; |
| 48 |
| 49 // Reads configs from the given var name, and uses the given setting on the |
| 50 // target to save them |
| 51 void FillGenericConfigs(const char* var_name, |
| 52 void (Target::*setter)(std::vector<const Config*>*)); |
| 53 |
| 54 void FillConfigs(); |
| 55 void FillAllDependentConfigs(); |
| 56 void FillDirectDependentConfigs(); |
| 57 void FillSources(); |
| 58 void FillData(); |
| 59 void FillDependencies(); |
| 60 void FillDestDir(); |
| 61 void FillScript(); |
| 62 void FillScriptArgs(); |
| 63 void FillOutputs(); |
| 64 |
| 65 const BuildSettings* GetBuildSettings() const; |
| 66 |
| 67 Target* target_; |
| 68 Scope* scope_; |
| 69 const Token& function_token_; |
| 70 std::vector<Value> args_; |
| 71 std::string output_type_; |
| 72 Err* err_; |
| 73 |
| 74 // Sources are relative to this. This comes from the input file which doesn't |
| 75 // get freed so we don't acautlly have to make a copy. |
| 76 const SourceDir& input_directory_; |
| 77 |
| 78 FRIEND_TEST_ALL_PREFIXES(TargetGenerator, ResolveInputPath); |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(TargetGenerator); |
| 81 }; |
| 82 |
| 83 #endif // TOOLS_GN_TARGET_GENERATOR_H_ |
OLD | NEW |