Allow setting test binary linker options using a test compilation

#KT-29254 Fixed
This commit is contained in:
Ilya Matveev
2019-01-14 17:13:09 +07:00
parent 2157c777b3
commit ac1b4cf6b2
7 changed files with 38 additions and 7 deletions
@@ -134,7 +134,7 @@ open class KotlinNativeBinaryContainer @Inject constructor(
internal fun defaultTestExecutable(
configure: Executable.() -> Unit
) = createBinaries(
"test",
DEFAULT_TEST_NAME_PREFIX,
"test",
NativeOutputKind.EXECUTABLE,
listOf(DEFAULT_TEST_BUILD_TYPE),
@@ -144,8 +144,12 @@ open class KotlinNativeBinaryContainer @Inject constructor(
configure
)
internal fun getDefaultTestExecutable(): Executable =
getExecutable(DEFAULT_TEST_NAME_PREFIX, DEFAULT_TEST_BUILD_TYPE)
companion object {
internal val DEFAULT_TEST_BUILD_TYPE = NativeBuildType.DEBUG
internal val DEFAULT_TEST_NAME_PREFIX = "test"
internal fun generateBinaryName(prefix: String, buildType: NativeBuildType, outputKindClassifier: String) =
lowerCamelCaseName(prefix, buildType.getName(), outputKindClassifier)
@@ -664,6 +664,11 @@ open class KotlinNativeTargetConfigurator(
}
}
}
// Allow setting linker options for the default test executable using the
// corresponding properties of the test compilation.
target.binaries.getDefaultTestExecutable().apply {
linkerOpts.addAll(target.compilations.getByName(TEST_COMPILATION_NAME).linkerOpts)
}
}
}