build: Add Xcode version check (#3543)

This commit is contained in:
Ilya Matveev
2019-11-07 12:19:40 +07:00
committed by GitHub
parent 045b20a36b
commit 7e52c96f2f
5 changed files with 63 additions and 2 deletions
@@ -37,5 +37,24 @@ object PlatformInfo {
return platformManager.targetManager(targetName).target
}
@JvmStatic
fun checkXcodeVersion(project: Project) {
val properties = PropertiesProvider(project)
val requiredMajorVersion = properties.xcodeMajorVersion
if (!DependencyProcessor.isInternalSeverAvailable
&& properties.checkXcodeVersion
&& requiredMajorVersion != null
) {
val currentXcodeVersion = Xcode.current.version
val currentMajorVersion = currentXcodeVersion.splitToSequence('.').first()
if (currentMajorVersion != requiredMajorVersion) {
throw IllegalStateException(
"Incorrect Xcode version: ${currentXcodeVersion}. Required major Xcode version is ${requiredMajorVersion}."
)
}
}
}
fun unsupportedPlatformException() = TargetSupportException()
}
@@ -0,0 +1,31 @@
package org.jetbrains.kotlin
import org.gradle.api.Project
import java.util.*
class PropertiesProvider(val project: Project) {
private val localProperties by lazy {
Properties().apply {
project.file("local.properties").takeIf { it.isFile }?.inputStream()?.use {
load(it)
}
}
}
fun findProperty(name: String): Any? =
project.findProperty(name) ?: localProperties.getProperty(name)
fun getProperty(name: String): Any =
findProperty(name) ?: throw IllegalArgumentException("No such property: $name")
fun hasProperty(name: String): Boolean =
project.hasProperty(name) || localProperties.containsKey(name)
val xcodeMajorVersion: String?
get() = findProperty("xcodeMajorVersion") as String?
val checkXcodeVersion: Boolean
get() = findProperty("checkXcodeVersion")?.let {
it == "true"
} ?: true
}
+4
View File
@@ -55,6 +55,10 @@ defaultTasks 'clean', 'dist'
convention.plugins.platformInfo = PlatformInfo
if (isMac()) {
checkXcodeVersion(project)
}
ext {
distDir = file('dist')
dependenciesDir = DependencyProcessor.defaultDependenciesRoot
+5 -1
View File
@@ -14,7 +14,7 @@
# limitations under the License.
#
# A version of the Kotlin "toolchain" (compiler, runtime, stdlib etc) used by the build script.
# A version of the Kotlin compiler that is used to build Kotlin/Native.
buildKotlinVersion=1.3.70-dev-1070
buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1070,branch:default:any,pinned:true/artifacts/content/maven
remoteRoot=konan_tests
@@ -25,6 +25,10 @@ kotlinStdlibVersion=1.3.70-dev-1244
kotlinStdlibTestsVersion=1.3.70-dev-1244
testKotlinCompilerVersion=1.3.70-dev-1244
konanVersion=1.3.70
# A version of Xcode required to build the Kotlin/Native compiler.
xcodeMajorVersion=11
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.workers.max=4
@@ -220,6 +220,9 @@ class DependencyProcessor(dependenciesRoot: File,
val defaultDependencyCacheDir: File
get() = localKonanDir.resolve("cache")
val isInternalSeverAvailable: Boolean
get() = InternalServer.isAvailable
}
private val resolvedDependencies = dependencyToCandidates.map { (dependency, candidates) ->
@@ -278,7 +281,7 @@ class DependencyProcessor(dependenciesRoot: File,
internal object InternalServer {
private val host = "repo.labs.intellij.net"
val url = "http://$host/kotlin-native"
val url = "https://$host/kotlin-native"
private val internalDomain = "labs.intellij.net"