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.
5 #include "tools/gn/build_settings.h"
7 #include "base/file_util.h"
8 #include "tools/gn/filesystem_utils.h"
10 BuildSettings::BuildSettings()
11 : using_external_generator_(false),
13 target_manager_(this),
14 toolchain_manager_(this) {
17 BuildSettings::BuildSettings(const BuildSettings
& other
)
18 : root_path_(other
.root_path_
),
19 root_path_utf8_(other
.root_path_utf8_
),
20 secondary_source_path_(other
.secondary_source_path_
),
21 using_external_generator_(other
.using_external_generator_
),
22 python_path_(other
.python_path_
),
23 build_config_file_(other
.build_config_file_
),
24 build_dir_(other
.build_dir_
),
25 build_to_source_dir_string_(other
.build_to_source_dir_string_
),
26 build_args_(other
.build_args_
),
27 target_resolved_callback_(), // Don't copy.
29 target_manager_(this),
30 toolchain_manager_(this) {
33 BuildSettings::~BuildSettings() {
36 void BuildSettings::SetRootPath(const base::FilePath
& r
) {
37 DCHECK(r
.value()[r
.value().size() - 1] != base::FilePath::kSeparators
[0]);
39 root_path_utf8_
= FilePathToUTF8(root_path_
);
42 void BuildSettings::SetSecondarySourcePath(const SourceDir
& d
) {
43 secondary_source_path_
= GetFullPath(d
);
46 void BuildSettings::SetBuildDir(const SourceDir
& d
) {
48 build_to_source_dir_string_
= InvertDir(d
);
51 base::FilePath
BuildSettings::GetFullPath(const SourceFile
& file
) const {
52 return file
.Resolve(root_path_
);
55 base::FilePath
BuildSettings::GetFullPath(const SourceDir
& dir
) const {
56 return dir
.Resolve(root_path_
);
59 base::FilePath
BuildSettings::GetFullPathSecondary(
60 const SourceFile
& file
) const {
61 return file
.Resolve(secondary_source_path_
);
64 base::FilePath
BuildSettings::GetFullPathSecondary(
65 const SourceDir
& dir
) const {
66 return dir
.Resolve(secondary_source_path_
);