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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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
« no previous file with comments | « tools/gn/function_read_file.cc ('k') | tools/gn/function_template.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "tools/gn/build_settings.h"
6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h"
9 #include "tools/gn/settings.h"
10 #include "tools/gn/toolchain_manager.h"
11
12 /*
13 set_default_toolchain: Sets the default toolchain name.
14
15 set_default_toolchain(toolchain_label)
16
17 The given label should identify a toolchain definition (see "toolchain").
18 This toolchain will be used for all targets unless otherwise specified.
19
20 This function is only valid to call during the processing of the build
21 configuration file. Since the build configuration file is processed
22 separately for each toolchain, this function will be a no-op when called
23 under any non-default toolchains.
24
25 For example, the default toolchain should be appropriate for the current
26 environment. If the current environment is 32-bit and somebody references
27 a target with a 64-bit toolchain, we wouldn't want processing of the build
28 config file for the 64-bit toolchain to reset the default toolchain to
29 64-bit, we want to keep it 32-bits.
30
31 Argument:
32
33 toolchain_label:
34 Toolchain name.
35
36 Example:
37
38 set_default_toolchain("//build/config/win:vs32")
39 */
40
41 Value ExecuteSetDefaultToolchain(Scope* scope,
42 const FunctionCallNode* function,
43 const std::vector<Value>& args,
44 Err* err) {
45 if (!scope->IsProcessingBuildConfig()) {
46 *err = Err(function->function(), "Must be called from build config.",
47 "set_default_toolchain can only be called from the build configuration "
48 "file.");
49 return Value();
50 }
51
52 // Ignore non-default-build-config invocations.
53 if (!scope->IsProcessingDefaultBuildConfig())
54 return Value();
55
56 const SourceDir& current_dir = SourceDirForFunctionCall(function);
57 const Label& default_toolchain = ToolchainLabelForScope(scope);
58
59 if (!EnsureSingleStringArg(function, args, err))
60 return Value();
61 Label toolchain_label(
62 Label::Resolve(current_dir, default_toolchain, args[0], err));
63 if (toolchain_label.is_null())
64 return Value();
65
66 ToolchainManager& mgr =
67 scope->settings()->build_settings()->toolchain_manager();
68 mgr.SetDefaultToolchainUnlocked(toolchain_label, function->GetRange(), err);
69 return Value();
70 }
OLDNEW
« no previous file with comments | « tools/gn/function_read_file.cc ('k') | tools/gn/function_template.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698