diff --git a/build-tools/src/main/kotlin/org/jetbrains/kotlin/PlatformInfo.kt b/build-tools/src/main/kotlin/org/jetbrains/kotlin/PlatformInfo.kt index 67a5e16ee57..4d77f67f85b 100644 --- a/build-tools/src/main/kotlin/org/jetbrains/kotlin/PlatformInfo.kt +++ b/build-tools/src/main/kotlin/org/jetbrains/kotlin/PlatformInfo.kt @@ -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() } \ No newline at end of file diff --git a/build-tools/src/main/kotlin/org/jetbrains/kotlin/PropertiesProvider.kt b/build-tools/src/main/kotlin/org/jetbrains/kotlin/PropertiesProvider.kt new file mode 100644 index 00000000000..8dfc98583c9 --- /dev/null +++ b/build-tools/src/main/kotlin/org/jetbrains/kotlin/PropertiesProvider.kt @@ -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 +} diff --git a/build.gradle b/build.gradle index d90e89a3fa4..8b3e9c8de68 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,10 @@ defaultTasks 'clean', 'dist' convention.plugins.platformInfo = PlatformInfo +if (isMac()) { + checkXcodeVersion(project) +} + ext { distDir = file('dist') dependenciesDir = DependencyProcessor.defaultDependenciesRoot diff --git a/gradle.properties b/gradle.properties index cdc5356dc4a..04432e7ba6e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt index 171d5d2a319..29d3b7543a1 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt @@ -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"