diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-29 23:30:07 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-29 23:30:07 +0000 |
commit | c88bd8f2c08838c6730b946dc4a50d4386ef43f9 (patch) | |
tree | e9264e0a99f419ab9d52e864acd38bb06a579c3a /tools/gn/target_generator.h | |
parent | 6e778e0ad540ff7abf5252c8af25346aec6b3371 (diff) | |
download | chromium_src-c88bd8f2c08838c6730b946dc4a50d4386ef43f9.zip chromium_src-c88bd8f2c08838c6730b946dc4a50d4386ef43f9.tar.gz chromium_src-c88bd8f2c08838c6730b946dc4a50d4386ef43f9.tar.bz2 |
Add initial prototype for the GN meta-buildsystem.
This is currently not hooked into the build. To build, add a reference to the
gn.gyp file to build/all.gyp
R=darin@chromium.org, scottmg@chromium.org
Review URL: https://codereview.chromium.org/21114002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/target_generator.h')
-rw-r--r-- | tools/gn/target_generator.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tools/gn/target_generator.h b/tools/gn/target_generator.h new file mode 100644 index 0000000..11e920c --- /dev/null +++ b/tools/gn/target_generator.h @@ -0,0 +1,83 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TOOLS_GN_TARGET_GENERATOR_H_ +#define TOOLS_GN_TARGET_GENERATOR_H_ + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/gtest_prod_util.h" +#include "base/memory/scoped_ptr.h" +#include "tools/gn/source_dir.h" +#include "tools/gn/target.h" + +class BuildSettings; +class Err; +class Location; +class Scope; +class Token; +class Value; + +// Creates Target objects from a Scope (the result of a script execution). +class TargetGenerator { + public: + TargetGenerator(Target* target, + Scope* scope, + const Token& function_token, + const std::vector<Value>& args, + const std::string& output_type, + Err* err); + ~TargetGenerator(); + + void Run(); + + // The function token is the token of the function name of the generator for + // this target. err() will be set on failure. + static void GenerateTarget(Scope* scope, + const Token& function_token, + const std::vector<Value>& args, + const std::string& output_type, + Err* err); + + private: + // Sets err_ on failure. + Target::OutputType GetOutputType() const; + + // Reads configs from the given var name, and uses the given setting on the + // target to save them + void FillGenericConfigs(const char* var_name, + void (Target::*setter)(std::vector<const Config*>*)); + + void FillConfigs(); + void FillAllDependentConfigs(); + void FillDirectDependentConfigs(); + void FillSources(); + void FillData(); + void FillDependencies(); + void FillDestDir(); + void FillScript(); + void FillScriptArgs(); + void FillOutputs(); + + const BuildSettings* GetBuildSettings() const; + + Target* target_; + Scope* scope_; + const Token& function_token_; + std::vector<Value> args_; + std::string output_type_; + Err* err_; + + // Sources are relative to this. This comes from the input file which doesn't + // get freed so we don't acautlly have to make a copy. + const SourceDir& input_directory_; + + FRIEND_TEST_ALL_PREFIXES(TargetGenerator, ResolveInputPath); + + DISALLOW_COPY_AND_ASSIGN(TargetGenerator); +}; + +#endif // TOOLS_GN_TARGET_GENERATOR_H_ |