Chromium Code Reviews| 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 #include "tools/gn/functions.h" | 5 #include "tools/gn/functions.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 R"*(pool: Defines a pool object. | 726 R"*(pool: Defines a pool object. |
| 727 | 727 |
| 728 Pool objects can be applied to a tool to limit the parallelism of the | 728 Pool objects can be applied to a tool to limit the parallelism of the |
| 729 build. This object has a single property "depth" corresponding to | 729 build. This object has a single property "depth" corresponding to |
| 730 the number of tasks that may run simultaneously. | 730 the number of tasks that may run simultaneously. |
| 731 | 731 |
| 732 As the file containing the pool definition may be executed in the | 732 As the file containing the pool definition may be executed in the |
| 733 context of more than one toolchain it is recommended to specify an | 733 context of more than one toolchain it is recommended to specify an |
| 734 explicit toolchain when defining and referencing a pool. | 734 explicit toolchain when defining and referencing a pool. |
| 735 | 735 |
| 736 A pool is referenced by its label just like a target. | 736 A pool is referenced by its label just like a target. |
|
brettw
2017/06/08 18:36:20
Can you have a section here about the meaning of t
Petr Hosek
2017/06/13 02:16:58
Done.
| |
| 737 | 737 |
| 738 Variables | 738 Variables |
| 739 | 739 |
| 740 depth* | 740 console, depth* |
| 741 * = required | 741 * = required |
| 742 | 742 |
| 743 Example | 743 Example |
| 744 | 744 |
| 745 if (current_toolchain == default_toolchain) { | 745 if (current_toolchain == default_toolchain) { |
| 746 pool("link_pool") { | 746 pool("link_pool") { |
| 747 depth = 1 | 747 depth = 1 |
| 748 } | 748 } |
| 749 } | 749 } |
| 750 | 750 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 768 | 768 |
| 769 if (!EnsureSingleStringArg(function, args, err) || | 769 if (!EnsureSingleStringArg(function, args, err) || |
| 770 !EnsureNotProcessingImport(function, scope, err)) | 770 !EnsureNotProcessingImport(function, scope, err)) |
| 771 return Value(); | 771 return Value(); |
| 772 | 772 |
| 773 Label label(MakeLabelForScope(scope, function, args[0].string_value())); | 773 Label label(MakeLabelForScope(scope, function, args[0].string_value())); |
| 774 | 774 |
| 775 if (g_scheduler->verbose_logging()) | 775 if (g_scheduler->verbose_logging()) |
| 776 g_scheduler->Log("Defining pool", label.GetUserVisibleName(true)); | 776 g_scheduler->Log("Defining pool", label.GetUserVisibleName(true)); |
| 777 | 777 |
| 778 // Get the pool depth. It is an error to define a pool without a depth, | 778 // Create the new pool. |
| 779 // so check first for the presence of the value. | 779 std::unique_ptr<Pool> pool(new Pool(scope->settings(), label)); |
| 780 const Value* depth = scope->GetValue(kDepth, true); | 780 |
| 781 if (!depth) { | 781 // Check the value of console. |
| 782 *err = Err(function, "Can't define a pool without depth."); | 782 const Value* console = scope->GetValue(variables::kConsole, true); |
| 783 return Value(); | 783 if (console) { |
| 784 if (!console->VerifyTypeIs(Value::BOOLEAN, err)) | |
| 785 return Value(); | |
| 784 } | 786 } |
| 785 | 787 |
| 786 if (!depth->VerifyTypeIs(Value::INTEGER, err)) | 788 // Get the pool depth. Pool must hae a depth or be a console pool. |
| 787 return Value(); | 789 const Value* depth = scope->GetValue(kDepth, true); |
| 790 if (console && console->boolean_value()) { | |
| 791 if (depth) { | |
| 792 *err = Err(function, "Can't define a console pool with depth."); | |
| 793 return Value(); | |
| 794 } | |
| 788 | 795 |
| 789 if (depth->int_value() < 0) { | 796 pool->set_console(console->boolean_value()); |
| 790 *err = Err(function, "depth must be positive or nul."); | 797 } else { |
| 791 return Value(); | 798 if (!depth) { |
| 799 *err = Err(function, "Can't define a pool without depth."); | |
| 800 return Value(); | |
| 801 } | |
| 802 | |
| 803 if (!depth->VerifyTypeIs(Value::INTEGER, err)) | |
| 804 return Value(); | |
| 805 | |
| 806 if (depth->int_value() < 0) { | |
| 807 *err = Err(function, "depth must be positive or nul."); | |
| 808 return Value(); | |
| 809 } | |
| 810 | |
| 811 pool->set_depth(depth->int_value()); | |
| 792 } | 812 } |
| 793 | 813 |
| 794 // Create the new pool. | |
| 795 std::unique_ptr<Pool> pool(new Pool(scope->settings(), label)); | |
| 796 pool->set_depth(depth->int_value()); | |
| 797 | |
| 798 // Save the generated item. | 814 // Save the generated item. |
| 799 Scope::ItemVector* collector = scope->GetItemCollector(); | 815 Scope::ItemVector* collector = scope->GetItemCollector(); |
| 800 if (!collector) { | 816 if (!collector) { |
| 801 *err = Err(function, "Can't define a pool in this context."); | 817 *err = Err(function, "Can't define a pool in this context."); |
| 802 return Value(); | 818 return Value(); |
| 803 } | 819 } |
| 804 collector->push_back(pool.release()); | 820 collector->push_back(pool.release()); |
| 805 | 821 |
| 806 return Value(); | 822 return Value(); |
| 807 } | 823 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 } | 1153 } |
| 1138 | 1154 |
| 1139 // Otherwise it's a no-block function. | 1155 // Otherwise it's a no-block function. |
| 1140 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 1156 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
| 1141 return Value(); | 1157 return Value(); |
| 1142 return found_function->second.no_block_runner(scope, function, | 1158 return found_function->second.no_block_runner(scope, function, |
| 1143 args.list_value(), err); | 1159 args.list_value(), err); |
| 1144 } | 1160 } |
| 1145 | 1161 |
| 1146 } // namespace functions | 1162 } // namespace functions |
| OLD | NEW |