Revert "[Gradle] Propagate offline mode to Native platform libs generator"

This reverts commit fa951f8f9c.
This commit is contained in:
Svyatoslav Scherbina
2022-06-22 09:24:13 +02:00
committed by Space
parent b3848811e6
commit 146564718e
2 changed files with 5 additions and 70 deletions
@@ -20,9 +20,9 @@ import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.presetName
import org.jetbrains.kotlin.konan.util.DependencyDirectories
import org.junit.*
import org.junit.rules.TemporaryFolder
import kotlin.test.assertFalse
import org.junit.Assume
import org.junit.BeforeClass
import org.junit.Test
import kotlin.test.assertTrue
class NativePlatformLibsIT : BaseGradleIT() {
@@ -35,16 +35,6 @@ class NativePlatformLibsIT : BaseGradleIT() {
// We temporary disable it for windows until a proper fix is found.
Assume.assumeFalse(HostManager.hostIsMingw)
}
@field:ClassRule
@JvmField
val tempDir = TemporaryFolder()
@JvmStatic
@AfterClass
fun deleteTempDir() {
tempDir.delete()
}
}
override val defaultGradleVersion: GradleVersionRequired
@@ -85,11 +75,8 @@ class NativePlatformLibsIT : BaseGradleIT() {
}
}
private fun Project.buildWithLightDist(
vararg tasks: String,
options: BuildOptions = defaultBuildOptions(),
check: CompiledProject.() -> Unit
) = build(*tasks, "-Pkotlin.native.distribution.type=light", options = options, check = check)
private fun Project.buildWithLightDist(vararg tasks: String, check: CompiledProject.() -> Unit) =
build(*tasks, "-Pkotlin.native.distribution.type=light", check = check)
@Test
fun testNoGenerationForOldCompiler() = with(platformLibrariesProject("linuxX64")) {
@@ -319,49 +306,4 @@ class NativePlatformLibsIT : BaseGradleIT() {
assertContains("Generate platform libraries for linux_x64")
}
}
@Test
fun `check offline mode is propagated to the platform libs generator`() = with(platformLibrariesProject("linuxX64")) {
deleteInstalledCompilers()
// Install the compiler at the first time. Don't build to reduce execution time.
buildWithLightDist("tasks") {
assertSuccessful()
assertContains("Generate platform libraries for linux_x64")
}
deleteInstalledCompilers()
// Check that --offline works when all the dependencies are already downloaded:
val buildOptionsOffline = defaultBuildOptions()
.let { it.copy(freeCommandLineArgs = it.freeCommandLineArgs + "--offline") }
buildWithLightDist("tasks", options = buildOptionsOffline) {
assertSuccessful()
assertContains("Generate platform libraries for linux_x64")
}
// 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)
)
buildWithLightDist("tasks", options = buildOptionsOfflineWithCustomKonanDataDir) {
assertFailed()
assertContains("Generate platform libraries for linux_x64")
}
// The build above have extracted the cached compiler to the custom KONAN_DATA_DIR; remove it:
assertTrue(customKonanDataDir.deleteRecursively())
// Check that the compiler is not extracted if it is not cached:
buildWithLightDist("tasks", "-Pkotlin.native.version=1.6.20-M1-9999", options = buildOptionsOfflineWithCustomKonanDataDir) {
assertFailed()
assertNotContains("Generate platform libraries for linux_x64")
}
assertFalse(customKonanDataDir.exists())
}
}
@@ -196,11 +196,4 @@ internal class KotlinNativeLibraryGenerationRunner(project: Project) :
AbstractKotlinNativeCInteropRunner("generatePlatformLibraries", project) {
// The library generator works for a long time so enabling C2 can improve performance.
override val disableC2: Boolean = false
override val defaultArguments: List<String>
get() = mutableListOf<String>().apply {
if (project.gradle.startParameter.isOffline) {
addAll(listOf("-Xoverride-konan-properties", "airplaneMode=true"))
}
}
}