Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: tools/gn/filesystem_utils.cc

Issue 1420973003: Make sure abs-path gn labels have separate target_gen_dirs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/function_get_path_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/filesystem_utils.cc
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc
index 44de5adaa221492bd11c505317e4d392205be1d6..a3455fdf088b6829e63fa94e2551699694879858 100644
--- a/tools/gn/filesystem_utils.cc
+++ b/tools/gn/filesystem_utils.cc
@@ -686,6 +686,32 @@ SourceDir GetOutputDirForSourceDir(const Settings* settings,
settings->toolchain_label(), settings->is_default());
}
+void AppendFixedAbsolutePathSuffix(const BuildSettings* build_settings,
+ const SourceDir& source_dir,
+ OutputFile* result) {
+ const std::string& build_dir = build_settings->build_dir().value();
+
+ if (base::StartsWith(source_dir.value(), build_dir,
+ base::CompareCase::SENSITIVE)) {
+ size_t build_dir_size = build_dir.size();
+ result->value().append(&source_dir.value()[build_dir_size],
+ source_dir.value().size() - build_dir_size);
+ } else {
+ result->value().append("ABS_PATH");
+#if defined(OS_WIN)
+ // Windows absolute path contains ':' after drive letter. Remove it to
+ // avoid inserting ':' in the middle of path (eg. "ABS_PATH/C:/").
+ std::string src_dir_value = source_dir.value();
+ const auto colon_pos = src_dir_value.find(':');
+ if (colon_pos != std::string::npos)
+ src_dir_value.erase(src_dir_value.begin() + colon_pos);
+#else
+ const std::string& src_dir_value = source_dir.value();
+#endif
+ result->value().append(src_dir_value);
+ }
+}
+
SourceDir GetOutputDirForSourceDir(
const BuildSettings* build_settings,
const SourceDir& source_dir,
@@ -711,27 +737,7 @@ OutputFile GetOutputDirForSourceDirAsOutputFile(
source_dir.value().size() - 2);
} else {
// System-absolute.
- const std::string& build_dir = build_settings->build_dir().value();
-
- if (base::StartsWith(source_dir.value(), build_dir,
- base::CompareCase::SENSITIVE)) {
- size_t build_dir_size = build_dir.size();
- result.value().append(&source_dir.value()[build_dir_size],
- source_dir.value().size() - build_dir_size);
- } else {
- result.value().append("ABS_PATH");
-#if defined(OS_WIN)
- // Windows absolute path contains ':' after drive letter. Remove it to
- // avoid inserting ':' in the middle of path (eg. "ABS_PATH/C:/").
- std::string src_dir_value = source_dir.value();
- const auto colon_pos = src_dir_value.find(':');
- if (colon_pos != std::string::npos)
- src_dir_value.erase(src_dir_value.begin() + colon_pos);
-#else
- const std::string& src_dir_value = source_dir.value();
-#endif
- result.value().append(src_dir_value);
- }
+ AppendFixedAbsolutePathSuffix(build_settings, source_dir, &result);
}
return result;
}
@@ -759,6 +765,10 @@ OutputFile GetGenDirForSourceDirAsOutputFile(const Settings* settings,
DCHECK(source_dir.is_source_absolute());
result.value().append(&source_dir.value()[2],
source_dir.value().size() - 2);
+ } else {
+ // System-absolute.
+ AppendFixedAbsolutePathSuffix(settings->build_settings(), source_dir,
+ &result);
}
return result;
}
« no previous file with comments | « no previous file | tools/gn/function_get_path_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698