Skip to content

Commit

Permalink
Use a comma to separate friends-paths, as kotlinc extracts friends pa…
Browse files Browse the repository at this point in the history
…th elements using that separator, not the usual system path separator. (#222)

> Note: This differs between the js and jvm backends [KT34277]

Fixes #210

[KT34277]: https://youtrack.jetbrains.com/issue/KT-34277
  • Loading branch information
cgruber authored Oct 28, 2019
1 parent 0b7723c commit a954e2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kotlin/internal/repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ _BAZEL_JAVA_LAUNCHER_VERSION = "0.28.1"

_KOTLIN_CURRENT_COMPILER_RELEASE = {
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v1.3.21/kotlin-compiler-1.3.21.zip",
"https://github.com/JetBrains/kotlin/releases/download/v1.3.50/kotlin-compiler-1.3.50.zip",
],
"sha256": "dbc7fbed67e0fa9a2f2ef6efd89fc1ef8d92daa38bb23c1f23914869084deb56",
"sha256": "69424091a6b7f52d93eed8bba2ace921b02b113dbb71388d704f8180a6bdc6ec",
}

def github_archive(name, repo, commit, build_file_content = None, sha256 = None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import java.nio.file.Paths
import javax.inject.Inject
import javax.inject.Singleton

/**
* Due to an inconsistency in the handling of -Xfriends-path, jvm uses a comma (property list
* separator), js uses the system path separator.
*/
const val X_FRIENDS_PATH_SEPARATOR = ","

@Singleton
class KotlinJvmTaskExecutor @Inject internal constructor(
private val compiler: KotlinToolchain.KotlincInvoker,
Expand Down Expand Up @@ -57,7 +63,6 @@ class KotlinJvmTaskExecutor @Inject internal constructor(

private fun JvmCompilationTask.produceSourceJar() {
Paths.get(outputs.srcjar).also { sourceJarPath ->
Files.deleteIfExists(sourceJarPath)
Files.createFile(sourceJarPath)
SourceJarCreator(
sourceJarPath
Expand Down Expand Up @@ -98,14 +103,17 @@ class KotlinJvmTaskExecutor @Inject internal constructor(
private fun JvmCompilationTask.getCommonArgs(): MutableList<String> {
val args = mutableListOf<String>()
val friendPaths = info.friendPathsList.map { Paths.get(it).toAbsolutePath() }
val cp = inputs.joinedClasspath
.split(File.pathSeparator)
.map { Paths.get(it).toAbsolutePath() }
.joinToString(File.pathSeparator)
args.addAll(
"-cp", inputs.joinedClasspath,
"-cp", cp,
"-api-version", info.toolchainInfo.common.apiVersion,
"-language-version", info.toolchainInfo.common.languageVersion,
"-jvm-target", info.toolchainInfo.jvm.jvmTarget,
"-Xfriend-paths=${friendPaths.joinToString(File.pathSeparator)}"
"-Xfriend-paths=${friendPaths.joinToString(X_FRIENDS_PATH_SEPARATOR)}"
)

args
.addAll("-module-name", info.moduleName)
.addAll("-d", directories.classes)
Expand Down

0 comments on commit a954e2b

Please sign in to comment.