[IC] Handle custom source set located outside project directory
To support build cache relocatability, we need to convert absolute paths into relative paths before storing them in IC caches. Before this commit, we computed relative paths based on the (root) project directory and FAIL if some source files are located outside the project directory. With this commit, we will NOT FAIL in that case. This means relative paths may start with "../". It's not "clean", but it can work. Test: New test in BuildCacheRelocationIT ^KT-61852 Fixed
This commit is contained in:
+2
-5
@@ -16,12 +16,9 @@ import java.io.File
|
||||
*/
|
||||
class RelocatableFileToPathConverter(private val baseDir: File) : FileToPathConverter {
|
||||
|
||||
private val unixStyleBaseDirPathPrefix = "${baseDir.invariantSeparatorsPath}/"
|
||||
|
||||
override fun toPath(file: File): String {
|
||||
check(file.invariantSeparatorsPath.startsWith(unixStyleBaseDirPathPrefix)) {
|
||||
"The given file '${file.path}' is located outside the base directory '${baseDir.path}'"
|
||||
}
|
||||
// Note: If the given file is located outside `baseDir`, the relative path will start with "../". It's not "clean", but it can work.
|
||||
// TODO: Re-design the code such that `baseDir` always contains the given file (also add a precondition check here).
|
||||
return file.relativeTo(baseDir).invariantSeparatorsPath
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user