Revert "[Gradle] Propagate offline mode to Native compiler"
This reverts commit 15a52f33
This commit is contained in:
committed by
Space
parent
0fe4c6217c
commit
a3ee2d7349
+5
-87
@@ -21,8 +21,11 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
|||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.konan.target.presetName
|
import org.jetbrains.kotlin.konan.target.presetName
|
||||||
import org.junit.*
|
import org.junit.Assume
|
||||||
import org.junit.rules.TemporaryFolder
|
import org.junit.Ignore
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.rules.ErrorCollector
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -1121,81 +1124,6 @@ class GeneralNativeIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `check offline mode is propagated to the compiler`() = with(
|
|
||||||
transformNativeTestProjectWithPluginDsl(
|
|
||||||
"executables",
|
|
||||||
directoryPrefix = "native-binaries"
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
val buildOptions = defaultBuildOptions()
|
|
||||||
|
|
||||||
val linkTask = ":linkDebugExecutableHost"
|
|
||||||
val compileTask = ":compileKotlinHost"
|
|
||||||
|
|
||||||
build(linkTask, options = buildOptions) {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that --offline works when all the dependencies are already downloaded:
|
|
||||||
val buildOptionsOffline = buildOptions.copy(freeCommandLineArgs = buildOptions.freeCommandLineArgs + "--offline")
|
|
||||||
|
|
||||||
build("clean", linkTask, options = buildOptionsOffline) {
|
|
||||||
assertSuccessful()
|
|
||||||
withNativeCommandLineArguments(compileTask, linkTask) {
|
|
||||||
assertTrue(it.contains("-Xoverride-konan-properties=airplaneMode=true"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that --offline fails when there are no downloaded dependencies:
|
|
||||||
val customKonanDataDir = tempDir.newFolder("konanOffline")
|
|
||||||
val buildOptionsOfflineWithCustomKonanDataDir = buildOptionsOffline.copy(
|
|
||||||
customEnvironmentVariables = buildOptionsOffline.customEnvironmentVariables +
|
|
||||||
("KONAN_DATA_DIR" to customKonanDataDir.absolutePath)
|
|
||||||
)
|
|
||||||
|
|
||||||
build("clean", linkTask, options = buildOptionsOfflineWithCustomKonanDataDir) {
|
|
||||||
assertFailed()
|
|
||||||
assertTasksNotExecuted(listOf(linkTask))
|
|
||||||
}
|
|
||||||
|
|
||||||
checkNoDependenciesDownloaded(customKonanDataDir)
|
|
||||||
|
|
||||||
// Check that the compiler is not extracted if it is not cached:
|
|
||||||
assertTrue(customKonanDataDir.deleteRecursively())
|
|
||||||
build(
|
|
||||||
"clean", linkTask, "-Pkotlin.native.version=1.6.20-M1-9999",
|
|
||||||
options = buildOptionsOfflineWithCustomKonanDataDir
|
|
||||||
) {
|
|
||||||
assertFailed()
|
|
||||||
assertTasksNotExecuted(listOf(linkTask, compileTask))
|
|
||||||
}
|
|
||||||
|
|
||||||
assertFalse(customKonanDataDir.exists())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkNoDependenciesDownloaded(customKonanDataDir: File) {
|
|
||||||
// Check that no files have actually been downloaded or extracted,
|
|
||||||
// except for maybe the compiler itself, which can be extracted from the Gradle cache
|
|
||||||
// (see NativeCompilerDownloader, it uses regular dependency resolution,
|
|
||||||
// so supports --offline properly by default).
|
|
||||||
val cacheDirName = "cache"
|
|
||||||
val dependenciesDirName = "dependencies"
|
|
||||||
|
|
||||||
fun assertDirectoryHasNothingButMaybe(directory: File, vararg names: String) {
|
|
||||||
assertEquals(emptyList(), directory.listFiles().orEmpty().map { it.name } - names)
|
|
||||||
}
|
|
||||||
|
|
||||||
assertDirectoryHasNothingButMaybe(File(customKonanDataDir, cacheDirName), ".lock")
|
|
||||||
assertDirectoryHasNothingButMaybe(File(customKonanDataDir, dependenciesDirName), ".extracted")
|
|
||||||
|
|
||||||
val customKonanDataDirFiles = customKonanDataDir.listFiles().orEmpty().map { it.name } - setOf(cacheDirName, dependenciesDirName)
|
|
||||||
if (customKonanDataDirFiles.isNotEmpty()) {
|
|
||||||
assertEquals(1, customKonanDataDirFiles.size, message = customKonanDataDirFiles.toString())
|
|
||||||
assertTrue(customKonanDataDirFiles.single().startsWith("kotlin-native-"), message = customKonanDataDirFiles.single())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allowToOverrideDownloadUrl() {
|
fun allowToOverrideDownloadUrl() {
|
||||||
with(transformNativeTestProjectWithPluginDsl("native-parallel")) {
|
with(transformNativeTestProjectWithPluginDsl("native-parallel")) {
|
||||||
@@ -1291,15 +1219,5 @@ class GeneralNativeIT : BaseGradleIT() {
|
|||||||
toolName: String = "konanc",
|
toolName: String = "konanc",
|
||||||
check: (Map<String, String>) -> Unit
|
check: (Map<String, String>) -> Unit
|
||||||
) = taskPaths.forEach { taskPath -> check(extractNativeCustomEnvironment(taskPath, toolName)) }
|
) = taskPaths.forEach { taskPath -> check(extractNativeCustomEnvironment(taskPath, toolName)) }
|
||||||
|
|
||||||
@field:ClassRule
|
|
||||||
@JvmField
|
|
||||||
val tempDir = TemporaryFolder()
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@AfterClass
|
|
||||||
fun deleteTempDir() {
|
|
||||||
tempDir.delete()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-5
@@ -55,9 +55,6 @@ abstract class KotlinToolRunner(
|
|||||||
abstract val mustRunViaExec: Boolean
|
abstract val mustRunViaExec: Boolean
|
||||||
open fun transformArgs(args: List<String>): List<String> = args
|
open fun transformArgs(args: List<String>): List<String> = args
|
||||||
|
|
||||||
internal open val defaultArguments: List<String>
|
|
||||||
get() = emptyList()
|
|
||||||
|
|
||||||
// for the purpose if there is a way to specify JVM args, for instance, straight in project configs
|
// for the purpose if there is a way to specify JVM args, for instance, straight in project configs
|
||||||
open fun getCustomJvmArgs(): List<String> = emptyList()
|
open fun getCustomJvmArgs(): List<String> = emptyList()
|
||||||
|
|
||||||
@@ -81,9 +78,8 @@ abstract class KotlinToolRunner(
|
|||||||
|
|
||||||
fun run(args: List<String>) {
|
fun run(args: List<String>) {
|
||||||
checkClasspath()
|
checkClasspath()
|
||||||
val argsWithDefault = args + defaultArguments
|
|
||||||
|
|
||||||
if (mustRunViaExec) runViaExec(argsWithDefault) else runInProcess(argsWithDefault)
|
if (mustRunViaExec) runViaExec(args) else runInProcess(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runViaExec(args: List<String>) {
|
private fun runViaExec(args: List<String>) {
|
||||||
|
|||||||
-7
@@ -175,13 +175,6 @@ internal class KotlinNativeCompilerRunner(project: Project) : KotlinNativeToolRu
|
|||||||
|
|
||||||
return listOf(toolName, "@${argFile.absolutePath}")
|
return listOf(toolName, "@${argFile.absolutePath}")
|
||||||
}
|
}
|
||||||
|
|
||||||
override val defaultArguments: List<String>
|
|
||||||
get() = mutableListOf<String>().apply {
|
|
||||||
if (project.gradle.startParameter.isOffline) {
|
|
||||||
add("-Xoverride-konan-properties=airplaneMode=true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Platform libraries generation tool. Runs the cinterop tool under the hood. */
|
/** Platform libraries generation tool. Runs the cinterop tool under the hood. */
|
||||||
|
|||||||
Reference in New Issue
Block a user