blob: 1b6db62298bebcac2c7f33fb88cb4a56e7293d08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/gn/output_file.h"
#include "tools/gn/filesystem_utils.h"
#include "tools/gn/source_file.h"
OutputFile::OutputFile() : value_() {
}
OutputFile::OutputFile(const base::StringPiece& str)
: value_(str.data(), str.size()) {
}
OutputFile::OutputFile(const BuildSettings* build_settings,
const SourceFile& source_file)
: value_(RebasePath(source_file.value(),
build_settings->build_dir(),
build_settings->root_path_utf8())) {
}
OutputFile::~OutputFile() {
}
SourceFile OutputFile::AsSourceFile(const BuildSettings* build_settings) const {
DCHECK(!value_.empty());
DCHECK(value_[value_.size() - 1] != '/');
std::string path = build_settings->build_dir().value();
path.append(value_);
NormalizePath(&path);
return SourceFile(path);
}
SourceDir OutputFile::AsSourceDir(const BuildSettings* build_settings) const {
if (!value_.empty()) {
// Empty means the root build dir. Otherwise, we expect it to end in a
// slash.
DCHECK(value_[value_.size() - 1] == '/');
}
std::string path = build_settings->build_dir().value();
path.append(value_);
NormalizePath(&path);
return SourceDir(path);
}
|