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

Side by Side Diff: tools/gn/functions.h

Issue 1314773005: Throw errors for nested targets in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « tools/gn/function_toolchain.cc ('k') | tools/gn/functions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef TOOLS_GN_FUNCTIONS_H_ 5 #ifndef TOOLS_GN_FUNCTIONS_H_
6 #define TOOLS_GN_FUNCTIONS_H_ 6 #define TOOLS_GN_FUNCTIONS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 // Returns the name of the toolchain for the given scope. 424 // Returns the name of the toolchain for the given scope.
425 const Label& ToolchainLabelForScope(const Scope* scope); 425 const Label& ToolchainLabelForScope(const Scope* scope);
426 426
427 // Generates a label for the given scope, using the current directory and 427 // Generates a label for the given scope, using the current directory and
428 // toolchain, and the given name. 428 // toolchain, and the given name.
429 Label MakeLabelForScope(const Scope* scope, 429 Label MakeLabelForScope(const Scope* scope,
430 const FunctionCallNode* function, 430 const FunctionCallNode* function,
431 const std::string& name); 431 const std::string& name);
432 432
433 // Some tyesp of blocks can't be nested inside other ones. For such cases,
434 // instantiate this object upon entering the block and Enter() will fail if
435 // there is already another non-nestable block on the stack.
436 class NonNestableBlock {
437 public:
438 enum Type {
439 CONFIG,
440 DECLARE_ARGS,
441 TARGET,
442 TEMPLATE,
443 TOOLCHAIN,
444 };
445
446 // type_description is a string that will be used in error messages
447 // describing the type of the block, for example, "template" or "config".
448 NonNestableBlock(Scope* scope,
449 const FunctionCallNode* function,
450 const char* type_description);
451 ~NonNestableBlock();
452
453 bool Enter(Err* err);
454
455 private:
456 // Used as a void* key for the Scope to track our property. The actual value
457 // is never used.
458 static const int kKey;
459
460 Scope* scope_;
461 const FunctionCallNode* function_;
462 const char* type_description_;
463
464 // Set to true when the key is added to the scope so we don't try to
465 // delete nonexistant keys which will cause assertions.
466 bool key_added_;
467 };
468
433 #endif // TOOLS_GN_FUNCTIONS_H_ 469 #endif // TOOLS_GN_FUNCTIONS_H_
OLDNEW
« no previous file with comments | « tools/gn/function_toolchain.cc ('k') | tools/gn/functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698