| 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/build_settings.h" | 5 #include "tools/gn/build_settings.h" |
| 6 #include "tools/gn/functions.h" | 6 #include "tools/gn/functions.h" |
| 7 #include "tools/gn/loader.h" | 7 #include "tools/gn/loader.h" |
| 8 #include "tools/gn/parse_tree.h" | 8 #include "tools/gn/parse_tree.h" |
| 9 #include "tools/gn/scope.h" | 9 #include "tools/gn/scope.h" |
| 10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
| 11 | 11 |
| 12 namespace functions { | 12 namespace functions { |
| 13 | 13 |
| 14 const char kSetDefaultToolchain[] = "set_default_toolchain"; | 14 const char kSetDefaultToolchain[] = "set_default_toolchain"; |
| 15 const char kSetDefaultToolchain_HelpShort[] = | 15 const char kSetDefaultToolchain_HelpShort[] = |
| 16 "set_default_toolchain: Sets the default toolchain name."; | 16 "set_default_toolchain: Sets the default toolchain name."; |
| 17 const char kSetDefaultToolchain_Help[] = | 17 const char kSetDefaultToolchain_Help[] = |
| 18 "set_default_toolchain: Sets the default toolchain name.\n" | 18 R"(set_default_toolchain: Sets the default toolchain name. |
| 19 "\n" | 19 |
| 20 " set_default_toolchain(toolchain_label)\n" | 20 set_default_toolchain(toolchain_label) |
| 21 "\n" | 21 |
| 22 " The given label should identify a toolchain definition (see\n" | 22 The given label should identify a toolchain definition (see "gn help |
| 23 " \"help toolchain\"). This toolchain will be used for all targets\n" | 23 toolchain"). This toolchain will be used for all targets unless otherwise |
| 24 " unless otherwise specified.\n" | 24 specified. |
| 25 "\n" | 25 |
| 26 " This function is only valid to call during the processing of the build\n" | 26 This function is only valid to call during the processing of the build |
| 27 " configuration file. Since the build configuration file is processed\n" | 27 configuration file. Since the build configuration file is processed |
| 28 " separately for each toolchain, this function will be a no-op when\n" | 28 separately for each toolchain, this function will be a no-op when called |
| 29 " called under any non-default toolchains.\n" | 29 under any non-default toolchains. |
| 30 "\n" | 30 |
| 31 " For example, the default toolchain should be appropriate for the\n" | 31 For example, the default toolchain should be appropriate for the current |
| 32 " current environment. If the current environment is 32-bit and \n" | 32 environment. If the current environment is 32-bit and somebody references a |
| 33 " somebody references a target with a 64-bit toolchain, we wouldn't\n" | 33 target with a 64-bit toolchain, we wouldn't want processing of the build |
| 34 " want processing of the build config file for the 64-bit toolchain to\n" | 34 config file for the 64-bit toolchain to reset the default toolchain to |
| 35 " reset the default toolchain to 64-bit, we want to keep it 32-bits.\n" | 35 64-bit, we want to keep it 32-bits. |
| 36 "\n" | 36 |
| 37 "Argument:\n" | 37 Argument |
| 38 "\n" | 38 |
| 39 " toolchain_label\n" | 39 toolchain_label |
| 40 " Toolchain name.\n" | 40 Toolchain name. |
| 41 "\n" | 41 |
| 42 "Example:\n" | 42 Example |
| 43 "\n" | 43 |
| 44 " set_default_toolchain(\"//build/config/win:vs32\")"; | 44 set_default_toolchain("//build/config/win:vs32"))"; |
| 45 | 45 |
| 46 Value RunSetDefaultToolchain(Scope* scope, | 46 Value RunSetDefaultToolchain(Scope* scope, |
| 47 const FunctionCallNode* function, | 47 const FunctionCallNode* function, |
| 48 const std::vector<Value>& args, | 48 const std::vector<Value>& args, |
| 49 Err* err) { | 49 Err* err) { |
| 50 if (!scope->IsProcessingBuildConfig()) { | 50 if (!scope->IsProcessingBuildConfig()) { |
| 51 *err = Err(function->function(), "Must be called from build config.", | 51 *err = Err(function->function(), "Must be called from build config.", |
| 52 "set_default_toolchain can only be called from the build configuration " | 52 "set_default_toolchain can only be called from the build configuration " |
| 53 "file."); | 53 "file."); |
| 54 return Value(); | 54 return Value(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 Label toolchain_label( | 69 Label toolchain_label( |
| 70 Label::Resolve(current_dir, default_toolchain, args[0], err)); | 70 Label::Resolve(current_dir, default_toolchain, args[0], err)); |
| 71 if (toolchain_label.is_null()) | 71 if (toolchain_label.is_null()) |
| 72 return Value(); | 72 return Value(); |
| 73 | 73 |
| 74 *default_toolchain_dest = toolchain_label; | 74 *default_toolchain_dest = toolchain_label; |
| 75 return Value(); | 75 return Value(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace functions | 78 } // namespace functions |
| OLD | NEW |