Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/gn/scope_per_file_provider.cc

Issue 226223006: Template invocation fixes in GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "tools/gn/scope_per_file_provider.h" 5 #include "tools/gn/scope_per_file_provider.h"
6 6
7 #include "tools/gn/filesystem_utils.h" 7 #include "tools/gn/filesystem_utils.h"
8 #include "tools/gn/settings.h" 8 #include "tools/gn/settings.h"
9 #include "tools/gn/source_file.h" 9 #include "tools/gn/source_file.h"
10 #include "tools/gn/value.h" 10 #include "tools/gn/value.h"
11 #include "tools/gn/variables.h" 11 #include "tools/gn/variables.h"
12 12
13 ScopePerFileProvider::ScopePerFileProvider(Scope* scope) 13 ScopePerFileProvider::ScopePerFileProvider(Scope* scope,
14 : ProgrammaticProvider(scope) { 14 bool allow_target_vars)
15 : ProgrammaticProvider(scope),
16 allow_target_vars_(allow_target_vars) {
15 } 17 }
16 18
17 ScopePerFileProvider::~ScopePerFileProvider() { 19 ScopePerFileProvider::~ScopePerFileProvider() {
18 } 20 }
19 21
20 const Value* ScopePerFileProvider::GetProgrammaticValue( 22 const Value* ScopePerFileProvider::GetProgrammaticValue(
21 const base::StringPiece& ident) { 23 const base::StringPiece& ident) {
22 if (ident == variables::kCurrentToolchain) 24 if (ident == variables::kCurrentToolchain)
23 return GetCurrentToolchain(); 25 return GetCurrentToolchain();
24 if (ident == variables::kDefaultToolchain) 26 if (ident == variables::kDefaultToolchain)
25 return GetDefaultToolchain(); 27 return GetDefaultToolchain();
26 if (ident == variables::kPythonPath) 28 if (ident == variables::kPythonPath)
27 return GetPythonPath(); 29 return GetPythonPath();
28 30
29 if (ident == variables::kRootBuildDir) 31 if (ident == variables::kRootBuildDir)
30 return GetRootBuildDir(); 32 return GetRootBuildDir();
31 if (ident == variables::kRootGenDir) 33 if (ident == variables::kRootGenDir)
32 return GetRootGenDir(); 34 return GetRootGenDir();
33 if (ident == variables::kRootOutDir) 35 if (ident == variables::kRootOutDir)
34 return GetRootOutDir(); 36 return GetRootOutDir();
35 if (ident == variables::kTargetGenDir) 37
36 return GetTargetGenDir(); 38 if (allow_target_vars_) {
37 if (ident == variables::kTargetOutDir) 39 if (ident == variables::kTargetGenDir)
38 return GetTargetOutDir(); 40 return GetTargetGenDir();
41 if (ident == variables::kTargetOutDir)
42 return GetTargetOutDir();
43 }
39 return NULL; 44 return NULL;
40 } 45 }
41 46
42 const Value* ScopePerFileProvider::GetCurrentToolchain() { 47 const Value* ScopePerFileProvider::GetCurrentToolchain() {
43 if (!current_toolchain_) { 48 if (!current_toolchain_) {
44 current_toolchain_.reset(new Value(NULL, 49 current_toolchain_.reset(new Value(NULL,
45 scope_->settings()->toolchain_label().GetUserVisibleName(false))); 50 scope_->settings()->toolchain_label().GetUserVisibleName(false)));
46 } 51 }
47 return current_toolchain_.get(); 52 return current_toolchain_.get();
48 } 53 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return target_gen_dir_.get(); 101 return target_gen_dir_.get();
97 } 102 }
98 103
99 const Value* ScopePerFileProvider::GetTargetOutDir() { 104 const Value* ScopePerFileProvider::GetTargetOutDir() {
100 if (!target_out_dir_) { 105 if (!target_out_dir_) {
101 target_out_dir_.reset(new Value(NULL, 106 target_out_dir_.reset(new Value(NULL,
102 DirectoryWithNoLastSlash(GetCurrentOutputDir(scope_)))); 107 DirectoryWithNoLastSlash(GetCurrentOutputDir(scope_))));
103 } 108 }
104 return target_out_dir_.get(); 109 return target_out_dir_.get();
105 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698