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/files/file_util.h"
8 #include "tools/gn/filesystem_utils.h"
10 BuildSettings::BuildSettings() {
13 BuildSettings::BuildSettings(const BuildSettings
& other
)
14 : root_path_(other
.root_path_
),
15 root_path_utf8_(other
.root_path_utf8_
),
16 secondary_source_path_(other
.secondary_source_path_
),
17 python_path_(other
.python_path_
),
18 build_config_file_(other
.build_config_file_
),
19 build_dir_(other
.build_dir_
),
20 build_args_(other
.build_args_
) {
23 BuildSettings::~BuildSettings() {
26 void BuildSettings::SetRootPath(const base::FilePath
& r
) {
27 DCHECK(r
.value()[r
.value().size() - 1] != base::FilePath::kSeparators
[0]);
28 root_path_
= r
.NormalizePathSeparatorsTo('/');
29 root_path_utf8_
= FilePathToUTF8(root_path_
);
32 void BuildSettings::SetSecondarySourcePath(const SourceDir
& d
) {
33 secondary_source_path_
= GetFullPath(d
).NormalizePathSeparatorsTo('/');
36 void BuildSettings::SetBuildDir(const SourceDir
& d
) {
40 base::FilePath
BuildSettings::GetFullPath(const SourceFile
& file
) const {
41 return file
.Resolve(root_path_
).NormalizePathSeparatorsTo('/');
44 base::FilePath
BuildSettings::GetFullPath(const SourceDir
& dir
) const {
45 return dir
.Resolve(root_path_
).NormalizePathSeparatorsTo('/');
48 base::FilePath
BuildSettings::GetFullPathSecondary(
49 const SourceFile
& file
) const {
50 return file
.Resolve(secondary_source_path_
).NormalizePathSeparatorsTo('/');
53 base::FilePath
BuildSettings::GetFullPathSecondary(
54 const SourceDir
& dir
) const {
55 return dir
.Resolve(secondary_source_path_
).NormalizePathSeparatorsTo('/');
58 void BuildSettings::ItemDefined(scoped_ptr
<Item
> item
) const {
60 if (!item_defined_callback_
.is_null())
61 item_defined_callback_
.Run(item
.Pass());