Index: tools/gn/filesystem_utils.cc |
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc |
index 6279964914f96f150eeea9baed64b361c143fcf2..ca9aae13e6a536d1474c49a5bce3ecdd83cf7734 100644 |
--- a/tools/gn/filesystem_utils.cc |
+++ b/tools/gn/filesystem_utils.cc |
@@ -667,6 +667,16 @@ SourceDir SourceDirForCurrentDirectory(const base::FilePath& source_root) { |
return SourceDirForPath(source_root, cd); |
} |
+std::string GetOutputSubdirName(const Label& toolchain_label, bool is_default) { |
+ // The default toolchain has no subdir. |
+ if (is_default) |
+ return std::string(); |
+ |
+ // For now just assume the toolchain name is always a valid dir name. We may |
+ // want to clean up the in the future. |
+ return toolchain_label.name(); |
+} |
+ |
SourceDir GetToolchainOutputDir(const Settings* settings) { |
const OutputFile& toolchain_subdir = settings->toolchain_output_subdir(); |
@@ -677,6 +687,19 @@ SourceDir GetToolchainOutputDir(const Settings* settings) { |
return SourceDir(SourceDir::SWAP_IN, &result); |
} |
+SourceDir GetToolchainOutputDir(const BuildSettings* build_settings, |
+ const Label& toolchain_label, bool is_default) { |
+ std::string toolchain_subdir = |
+ GetOutputSubdirName(toolchain_label, is_default); |
+ |
+ std::string result = build_settings->build_dir().value(); |
+ if (!toolchain_subdir.empty()) { |
+ result.append(toolchain_subdir); |
+ result.push_back('/'); |
+ } |
+ return SourceDir(SourceDir::SWAP_IN, &result); |
+} |
+ |
SourceDir GetToolchainGenDir(const Settings* settings) { |
const OutputFile& toolchain_subdir = settings->toolchain_output_subdir(); |
@@ -688,6 +711,14 @@ SourceDir GetToolchainGenDir(const Settings* settings) { |
return SourceDir(SourceDir::SWAP_IN, &result); |
} |
+SourceDir GetToolchainGenDir(const BuildSettings* build_settings, |
+ const Label& toolchain_label, bool is_default) { |
+ std::string result = GetToolchainOutputDir( |
+ build_settings, toolchain_label, is_default).value(); |
+ result.append("gen/"); |
+ return SourceDir(SourceDir::SWAP_IN, &result); |
+} |
+ |
SourceDir GetOutputDirForSourceDir(const Settings* settings, |
const SourceDir& source_dir) { |
SourceDir toolchain = GetToolchainOutputDir(settings); |