[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / gn / build_settings.cc
blob63ff35845cb7db16e87141ab9fd2d8fc867875f8
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()
11 : check_for_bad_items_(true) {
14 BuildSettings::BuildSettings(const BuildSettings& other)
15 : root_path_(other.root_path_),
16 root_path_utf8_(other.root_path_utf8_),
17 secondary_source_path_(other.secondary_source_path_),
18 python_path_(other.python_path_),
19 build_config_file_(other.build_config_file_),
20 build_dir_(other.build_dir_),
21 build_args_(other.build_args_),
22 check_for_bad_items_(true) {
25 BuildSettings::~BuildSettings() {
28 void BuildSettings::SetRootPath(const base::FilePath& r) {
29 DCHECK(r.value()[r.value().size() - 1] != base::FilePath::kSeparators[0]);
30 root_path_ = r.NormalizePathSeparatorsTo('/');
31 root_path_utf8_ = FilePathToUTF8(root_path_);
34 void BuildSettings::SetSecondarySourcePath(const SourceDir& d) {
35 secondary_source_path_ = GetFullPath(d).NormalizePathSeparatorsTo('/');
38 void BuildSettings::SetBuildDir(const SourceDir& d) {
39 build_dir_ = d;
42 base::FilePath BuildSettings::GetFullPath(const SourceFile& file) const {
43 return file.Resolve(root_path_).NormalizePathSeparatorsTo('/');
46 base::FilePath BuildSettings::GetFullPath(const SourceDir& dir) const {
47 return dir.Resolve(root_path_).NormalizePathSeparatorsTo('/');
50 base::FilePath BuildSettings::GetFullPathSecondary(
51 const SourceFile& file) const {
52 return file.Resolve(secondary_source_path_).NormalizePathSeparatorsTo('/');
55 base::FilePath BuildSettings::GetFullPathSecondary(
56 const SourceDir& dir) const {
57 return dir.Resolve(secondary_source_path_).NormalizePathSeparatorsTo('/');
60 void BuildSettings::ItemDefined(scoped_ptr<Item> item) const {
61 DCHECK(item);
62 if (!item_defined_callback_.is_null())
63 item_defined_callback_.Run(item.Pass());