| Index: tools/gn/scope_per_file_provider.cc
|
| diff --git a/tools/gn/scope_per_file_provider.cc b/tools/gn/scope_per_file_provider.cc
|
| index c2fdd3eef6cfbc3a5b559bf42af51c702dce5396..c6a0cd7f635b6d799709379c4139090eecbd44b3 100644
|
| --- a/tools/gn/scope_per_file_provider.cc
|
| +++ b/tools/gn/scope_per_file_provider.cc
|
| @@ -66,8 +66,8 @@ const Value* ScopePerFileProvider::GetPythonPath() {
|
|
|
| const Value* ScopePerFileProvider::GetRootBuildDir() {
|
| if (!root_build_dir_) {
|
| - root_build_dir_.reset(new Value(NULL,
|
| - "/" + GetRootOutputDirWithNoLastSlash(scope_->settings())));
|
| + root_build_dir_.reset(new Value(NULL, DirectoryWithNoLastSlash(
|
| + scope_->settings()->build_settings()->build_dir())));
|
| }
|
| return root_build_dir_.get();
|
| }
|
| @@ -75,7 +75,7 @@ const Value* ScopePerFileProvider::GetRootBuildDir() {
|
| const Value* ScopePerFileProvider::GetRootGenDir() {
|
| if (!root_gen_dir_) {
|
| root_gen_dir_.reset(new Value(NULL,
|
| - "/" + GetToolchainGenDirWithNoLastSlash(scope_->settings())));
|
| + DirectoryWithNoLastSlash(GetToolchainGenDir(scope_->settings()))));
|
| }
|
| return root_gen_dir_.get();
|
| }
|
| @@ -83,7 +83,7 @@ const Value* ScopePerFileProvider::GetRootGenDir() {
|
| const Value* ScopePerFileProvider::GetRootOutDir() {
|
| if (!root_out_dir_) {
|
| root_out_dir_.reset(new Value(NULL,
|
| - "/" + GetToolchainOutputDirWithNoLastSlash(scope_->settings())));
|
| + DirectoryWithNoLastSlash(GetToolchainOutputDir(scope_->settings()))));
|
| }
|
| return root_out_dir_.get();
|
| }
|
| @@ -91,9 +91,7 @@ const Value* ScopePerFileProvider::GetRootOutDir() {
|
| const Value* ScopePerFileProvider::GetTargetGenDir() {
|
| if (!target_gen_dir_) {
|
| target_gen_dir_.reset(new Value(NULL,
|
| - "/" +
|
| - GetToolchainGenDirWithNoLastSlash(scope_->settings()) +
|
| - GetFileDirWithNoLastSlash()));
|
| + DirectoryWithNoLastSlash(GetCurrentGenDir(scope_))));
|
| }
|
| return target_gen_dir_.get();
|
| }
|
| @@ -101,61 +99,7 @@ const Value* ScopePerFileProvider::GetTargetGenDir() {
|
| const Value* ScopePerFileProvider::GetTargetOutDir() {
|
| if (!target_out_dir_) {
|
| target_out_dir_.reset(new Value(NULL,
|
| - "/" +
|
| - GetToolchainOutputDirWithNoLastSlash(scope_->settings()) + "/obj" +
|
| - GetFileDirWithNoLastSlash()));
|
| + DirectoryWithNoLastSlash(GetCurrentOutputDir(scope_))));
|
| }
|
| return target_out_dir_.get();
|
| }
|
| -
|
| -// static
|
| -std::string ScopePerFileProvider::GetRootOutputDirWithNoLastSlash(
|
| - const Settings* settings) {
|
| - const std::string& output_dir =
|
| - settings->build_settings()->build_dir().value();
|
| -
|
| - if (output_dir == "//")
|
| - return "//.";
|
| -
|
| - // Trim off a leading and trailing slash. So "//foo/bar/" -> /foo/bar".
|
| - DCHECK(output_dir.size() > 2 && output_dir[0] == '/' &&
|
| - output_dir[output_dir.size() - 1] == '/');
|
| - return output_dir.substr(1, output_dir.size() - 2);
|
| -}
|
| -
|
| -// static
|
| -std::string ScopePerFileProvider::GetToolchainOutputDirWithNoLastSlash(
|
| - const Settings* settings) {
|
| - const OutputFile& toolchain_subdir = settings->toolchain_output_subdir();
|
| -
|
| - std::string result;
|
| - if (toolchain_subdir.value().empty()) {
|
| - result = GetRootOutputDirWithNoLastSlash(settings);
|
| - } else {
|
| - // The toolchain subdir ends in a slash, trim it.
|
| - result = GetRootOutputDirWithNoLastSlash(settings) + "/" +
|
| - toolchain_subdir.value();
|
| - DCHECK(toolchain_subdir.value()[toolchain_subdir.value().size() - 1] ==
|
| - '/');
|
| - result.resize(result.size() - 1);
|
| - }
|
| - return result;
|
| -}
|
| -
|
| -// static
|
| -std::string ScopePerFileProvider::GetToolchainGenDirWithNoLastSlash(
|
| - const Settings* settings) {
|
| - return GetToolchainOutputDirWithNoLastSlash(settings) + "/gen";
|
| -}
|
| -
|
| -std::string ScopePerFileProvider::GetFileDirWithNoLastSlash() const {
|
| - const std::string& dir_value = scope_->GetSourceDir().value();
|
| -
|
| - if (dir_value == "//")
|
| - return "//.";
|
| -
|
| - // Trim off a leading and trailing slash. So "//foo/bar/" -> /foo/bar".
|
| - DCHECK(dir_value.size() > 2 && dir_value[0] == '/' &&
|
| - dir_value[dir_value.size() - 1] == '/');
|
| - return dir_value.substr(1, dir_value.size() - 2);
|
| -}
|
|
|