Roll src/third_party/skia ff271c2:b679ca8
[chromium-blink-merge.git] / tools / gn / output_file.cc
blob1b6db62298bebcac2c7f33fb88cb4a56e7293d08
1 // Copyright 2014 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/output_file.h"
7 #include "tools/gn/filesystem_utils.h"
8 #include "tools/gn/source_file.h"
10 OutputFile::OutputFile() : value_() {
13 OutputFile::OutputFile(const base::StringPiece& str)
14 : value_(str.data(), str.size()) {
17 OutputFile::OutputFile(const BuildSettings* build_settings,
18 const SourceFile& source_file)
19 : value_(RebasePath(source_file.value(),
20 build_settings->build_dir(),
21 build_settings->root_path_utf8())) {
24 OutputFile::~OutputFile() {
27 SourceFile OutputFile::AsSourceFile(const BuildSettings* build_settings) const {
28 DCHECK(!value_.empty());
29 DCHECK(value_[value_.size() - 1] != '/');
31 std::string path = build_settings->build_dir().value();
32 path.append(value_);
33 NormalizePath(&path);
34 return SourceFile(path);
37 SourceDir OutputFile::AsSourceDir(const BuildSettings* build_settings) const {
38 if (!value_.empty()) {
39 // Empty means the root build dir. Otherwise, we expect it to end in a
40 // slash.
41 DCHECK(value_[value_.size() - 1] == '/');
43 std::string path = build_settings->build_dir().value();
44 path.append(value_);
45 NormalizePath(&path);
46 return SourceDir(path);