| 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 #ifndef TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | 5 #ifndef TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ |
| 6 #define TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | 6 #define TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "tools/gn/scope.h" | 10 #include "tools/gn/scope.h" |
| 11 #include "tools/gn/source_file.h" | 11 #include "tools/gn/source_file.h" |
| 12 | 12 |
| 13 // ProgrammaticProvider for a scope to provide it with per-file built-in | 13 // ProgrammaticProvider for a scope to provide it with per-file built-in |
| 14 // variable support. | 14 // variable support. |
| 15 class ScopePerFileProvider : public Scope::ProgrammaticProvider { | 15 class ScopePerFileProvider : public Scope::ProgrammaticProvider { |
| 16 public: | 16 public: |
| 17 ScopePerFileProvider(Scope* scope); | 17 // allow_target_vars allows the target-related variables to get resolved. |
| 18 // When allow_target_vars is unset, the target-related values will be |
| 19 // undefined to GN script. |
| 20 ScopePerFileProvider(Scope* scope, bool allow_target_vars); |
| 18 virtual ~ScopePerFileProvider(); | 21 virtual ~ScopePerFileProvider(); |
| 19 | 22 |
| 20 // ProgrammaticProvider implementation. | 23 // ProgrammaticProvider implementation. |
| 21 virtual const Value* GetProgrammaticValue( | 24 virtual const Value* GetProgrammaticValue( |
| 22 const base::StringPiece& ident) OVERRIDE; | 25 const base::StringPiece& ident) OVERRIDE; |
| 23 | 26 |
| 24 private: | 27 private: |
| 25 const Value* GetCurrentToolchain(); | 28 const Value* GetCurrentToolchain(); |
| 26 const Value* GetDefaultToolchain(); | 29 const Value* GetDefaultToolchain(); |
| 27 const Value* GetPythonPath(); | 30 const Value* GetPythonPath(); |
| 28 const Value* GetRootBuildDir(); | 31 const Value* GetRootBuildDir(); |
| 29 const Value* GetRootGenDir(); | 32 const Value* GetRootGenDir(); |
| 30 const Value* GetRootOutDir(); | 33 const Value* GetRootOutDir(); |
| 31 const Value* GetTargetGenDir(); | 34 const Value* GetTargetGenDir(); |
| 32 const Value* GetTargetOutDir(); | 35 const Value* GetTargetOutDir(); |
| 33 | 36 |
| 37 bool allow_target_vars_; |
| 38 |
| 34 // All values are lazily created. | 39 // All values are lazily created. |
| 35 scoped_ptr<Value> current_toolchain_; | 40 scoped_ptr<Value> current_toolchain_; |
| 36 scoped_ptr<Value> default_toolchain_; | 41 scoped_ptr<Value> default_toolchain_; |
| 37 scoped_ptr<Value> python_path_; | 42 scoped_ptr<Value> python_path_; |
| 38 scoped_ptr<Value> root_build_dir_; | 43 scoped_ptr<Value> root_build_dir_; |
| 39 scoped_ptr<Value> root_gen_dir_; | 44 scoped_ptr<Value> root_gen_dir_; |
| 40 scoped_ptr<Value> root_out_dir_; | 45 scoped_ptr<Value> root_out_dir_; |
| 41 scoped_ptr<Value> target_gen_dir_; | 46 scoped_ptr<Value> target_gen_dir_; |
| 42 scoped_ptr<Value> target_out_dir_; | 47 scoped_ptr<Value> target_out_dir_; |
| 43 | 48 |
| 44 DISALLOW_COPY_AND_ASSIGN(ScopePerFileProvider); | 49 DISALLOW_COPY_AND_ASSIGN(ScopePerFileProvider); |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 #endif // TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | 52 #endif // TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ |
| OLD | NEW |