Update V8 to version 4.6.61.
[chromium-blink-merge.git] / tools / gn / output_file.cc
blob12845fbfaadf0739125049be427da23cc6a50f12
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(std::string&& v)
14 : value_(v) {
17 OutputFile::OutputFile(const std::string& v)
18 : value_(v) {
21 OutputFile::OutputFile(const BuildSettings* build_settings,
22 const SourceFile& source_file)
23 : value_(RebasePath(source_file.value(),
24 build_settings->build_dir(),
25 build_settings->root_path_utf8())) {
28 OutputFile::~OutputFile() {
31 SourceFile OutputFile::AsSourceFile(const BuildSettings* build_settings) const {
32 DCHECK(!value_.empty());
33 DCHECK(value_[value_.size() - 1] != '/');
35 std::string path = build_settings->build_dir().value();
36 path.append(value_);
37 NormalizePath(&path);
38 return SourceFile(path);
41 SourceDir OutputFile::AsSourceDir(const BuildSettings* build_settings) const {
42 if (!value_.empty()) {
43 // Empty means the root build dir. Otherwise, we expect it to end in a
44 // slash.
45 DCHECK(value_[value_.size() - 1] == '/');
47 std::string path = build_settings->build_dir().value();
48 path.append(value_);
49 NormalizePath(&path);
50 return SourceDir(path);