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 ScopePerFileProvider(Scope* scope); |
18 virtual ~ScopePerFileProvider(); | 18 virtual ~ScopePerFileProvider(); |
19 | 19 |
20 // ProgrammaticProvider implementation. | 20 // ProgrammaticProvider implementation. |
21 virtual const Value* GetProgrammaticValue( | 21 virtual const Value* GetProgrammaticValue( |
22 const base::StringPiece& ident) OVERRIDE; | 22 const base::StringPiece& ident) OVERRIDE; |
23 | 23 |
24 private: | 24 private: |
25 const Value* GetCurrentToolchain(); | 25 const Value* GetCurrentToolchain(); |
26 const Value* GetDefaultToolchain(); | 26 const Value* GetDefaultToolchain(); |
27 const Value* GetPythonPath(); | 27 const Value* GetPythonPath(); |
28 const Value* GetRelativeBuildToSourceRootDir(); | |
29 const Value* GetRelativeRootOutputDir(); | |
30 const Value* GetRelativeRootGenDir(); | |
31 const Value* GetRelativeSourceRootDir(); | |
32 const Value* GetRelativeTargetOutputDir(); | |
33 const Value* GetRelativeTargetGenDir(); | |
34 const Value* GetRootGenDir(); | 28 const Value* GetRootGenDir(); |
| 29 const Value* GetRootOutDir(); |
35 const Value* GetTargetGenDir(); | 30 const Value* GetTargetGenDir(); |
| 31 const Value* GetTargetOutDir(); |
36 | 32 |
37 static std::string GetRootOutputDirWithNoLastSlash(const Settings* settings); | 33 static std::string GetRootOutputDirWithNoLastSlash(const Settings* settings); |
38 static std::string GetRootGenDirWithNoLastSlash(const Settings* settings); | 34 static std::string GetRootGenDirWithNoLastSlash(const Settings* settings); |
39 | 35 |
40 std::string GetFileDirWithNoLastSlash() const; | 36 std::string GetFileDirWithNoLastSlash() const; |
41 std::string GetRelativeRootWithNoLastSlash() const; | |
42 | |
43 // Inverts the given directory, returning it with no trailing slash. If the | |
44 // result would be empty, "." is returned to indicate the current dir. | |
45 static std::string InvertDirWithNoLastSlash(const SourceDir& dir); | |
46 | 37 |
47 // All values are lazily created. | 38 // All values are lazily created. |
48 scoped_ptr<Value> current_toolchain_; | 39 scoped_ptr<Value> current_toolchain_; |
49 scoped_ptr<Value> default_toolchain_; | 40 scoped_ptr<Value> default_toolchain_; |
50 scoped_ptr<Value> python_path_; | 41 scoped_ptr<Value> python_path_; |
51 scoped_ptr<Value> relative_build_to_source_root_dir_; | |
52 scoped_ptr<Value> relative_root_output_dir_; | |
53 scoped_ptr<Value> relative_root_gen_dir_; | |
54 scoped_ptr<Value> relative_source_root_dir_; | |
55 scoped_ptr<Value> relative_target_output_dir_; | |
56 scoped_ptr<Value> relative_target_gen_dir_; | |
57 scoped_ptr<Value> root_gen_dir_; | 42 scoped_ptr<Value> root_gen_dir_; |
| 43 scoped_ptr<Value> root_out_dir_; |
58 scoped_ptr<Value> target_gen_dir_; | 44 scoped_ptr<Value> target_gen_dir_; |
| 45 scoped_ptr<Value> target_out_dir_; |
59 | 46 |
60 DISALLOW_COPY_AND_ASSIGN(ScopePerFileProvider); | 47 DISALLOW_COPY_AND_ASSIGN(ScopePerFileProvider); |
61 }; | 48 }; |
62 | 49 |
63 #endif // TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ | 50 #endif // TOOLS_GN_SCOPE_PER_FILE_PROVIDER_H_ |
OLD | NEW |