Index: tools/gn/filesystem_utils.cc |
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc |
index 4cfefa9dc7ee658448233ae08a5af04473e69c2b..ca4562574df561a23ba4f6ecefdecfba422e8404 100644 |
--- a/tools/gn/filesystem_utils.cc |
+++ b/tools/gn/filesystem_utils.cc |
@@ -720,10 +720,12 @@ SourceDir GetOutputDirForSourceDir(const Settings* settings, |
toolchain.SwapValue(&ret); |
ret.append("obj/"); |
- // The source dir should be source-absolute, so we trim off the two leading |
- // slashes to append to the toolchain object directory. |
- DCHECK(source_dir.is_source_absolute()); |
- ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
+ if (source_dir.is_source_absolute()) { |
+ // The source dir is source-absolute, so we trim off the two leading |
+ // slashes to append to the toolchain object directory. |
+ ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
+ } |
+ // (Put system-absolute stuff in the root obj directory.) |
return SourceDir(SourceDir::SWAP_IN, &ret); |
} |
@@ -735,10 +737,13 @@ SourceDir GetGenDirForSourceDir(const Settings* settings, |
std::string ret; |
toolchain.SwapValue(&ret); |
- // The source dir should be source-absolute, so we trim off the two leading |
- // slashes to append to the toolchain object directory. |
- DCHECK(source_dir.is_source_absolute()); |
- ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
+ if (source_dir.is_source_absolute()) { |
+ // The source dir should be source-absolute, so we trim off the two leading |
+ // slashes to append to the toolchain object directory. |
+ DCHECK(source_dir.is_source_absolute()); |
+ ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
+ } |
+ // (Put system-absolute stuff in the root gen directory.) |
return SourceDir(SourceDir::SWAP_IN, &ret); |
} |