| 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_SCOPE_PER_FILE_PROVIDER_H_ | |
| 6 #define TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "tools/gn/scope.h" | |
| 11 #include "tools/gn/source_file.h" | |
| 12 | |
| 13 // ProgrammaticProvider for a scope to provide it with per-file built-in | |
| 14 // variable support. | |
| 15 class ScopePerFileProvider : public Scope::ProgrammaticProvider { | |
| 16 public: | |
| 17 ScopePerFileProvider(Scope* scope, const SourceFile& source_file); | |
| 18 virtual ~ScopePerFileProvider(); | |
| 19 | |
| 20 // ProgrammaticProvider implementation. | |
| 21 virtual const Value* GetProgrammaticValue( | |
| 22 const base::StringPiece& ident) OVERRIDE; | |
| 23 | |
| 24 // Returns the value to expose to script for the given thing. These values | |
| 25 // are acually set globally, but are put here so we can keep all logic | |
| 26 // for converting paths to built-in values in this one file. | |
| 27 static Value GetRootOutputDir(const Settings* settings); | |
| 28 static Value GetRootGenDir(const Settings* settings); | |
| 29 | |
| 30 // Variable names. These two should be set globally independent of the file | |
| 31 // being processed. | |
| 32 static const char* kRootOutputDirName; | |
| 33 static const char* kRootGenDirName; | |
| 34 | |
| 35 // Variable names. These are provided by this class as needed. | |
| 36 static const char* kDefaultToolchain; | |
| 37 static const char* kPythonPath; | |
| 38 static const char* kToolchain; | |
| 39 static const char* kTargetOutputDirName; | |
| 40 static const char* kTargetGenDirName; | |
| 41 static const char* kRelativeRootOutputDirName; | |
| 42 static const char* kRelativeRootGenDirName; | |
| 43 static const char* kRelativeTargetOutputDirName; | |
| 44 static const char* kRelativeTargetGenDirName; | |
| 45 | |
| 46 private: | |
| 47 const Value* GetDefaultToolchain(); | |
| 48 const Value* GetPythonPath(); | |
| 49 const Value* GetToolchain(); | |
| 50 const Value* GetTargetOutputDir(); | |
| 51 const Value* GetTargetGenDir(); | |
| 52 const Value* GetRelativeRootOutputDir(); | |
| 53 const Value* GetRelativeRootGenDir(); | |
| 54 const Value* GetRelativeTargetOutputDir(); | |
| 55 const Value* GetRelativeTargetGenDir(); | |
| 56 | |
| 57 static std::string GetRootOutputDirWithNoLastSlash(const Settings* settings); | |
| 58 static std::string GetRootGenDirWithNoLastSlash(const Settings* settings); | |
| 59 | |
| 60 std::string GetFileDirWithNoLastSlash() const; | |
| 61 std::string GetRelativeRootWithNoLastSlash() const; | |
| 62 | |
| 63 SourceFile source_file_; | |
| 64 | |
| 65 // All values are lazily created. | |
| 66 scoped_ptr<Value> default_toolchain_; | |
| 67 scoped_ptr<Value> python_path_; | |
| 68 scoped_ptr<Value> toolchain_; | |
| 69 scoped_ptr<Value> target_output_dir_; | |
| 70 scoped_ptr<Value> target_gen_dir_; | |
| 71 scoped_ptr<Value> relative_root_output_dir_; | |
| 72 scoped_ptr<Value> relative_root_gen_dir_; | |
| 73 scoped_ptr<Value> relative_target_output_dir_; | |
| 74 scoped_ptr<Value> relative_target_gen_dir_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ScopePerFileProvider); | |
| 77 }; | |
| 78 | |
| 79 #endif // TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | |
| OLD | NEW |