Add support for custom Xcode location (#1273)
This commit is contained in:
committed by
GitHub
parent
19cc8c6bee
commit
c09fd4d355
@@ -50,35 +50,24 @@ osVersionMinFlagLd.osx = -macosx_version_min
|
|||||||
osVersionMinFlagClang.osx = -mmacosx-version-min
|
osVersionMinFlagClang.osx = -mmacosx-version-min
|
||||||
osVersionMin.osx = 10.11
|
osVersionMin.osx = 10.11
|
||||||
entrySelector.osx = -alias _Konan_main _main
|
entrySelector.osx = -alias _Konan_main _main
|
||||||
dependencies.osx = target-sysroot-2-darwin-macos \
|
dependencies.osx = \
|
||||||
libffi-3.2.1-2-darwin-macos \
|
libffi-3.2.1-2-darwin-macos \
|
||||||
clang-llvm-5.0.0-darwin-macos \
|
clang-llvm-5.0.0-darwin-macos
|
||||||
target-toolchain-1-osx
|
|
||||||
|
|
||||||
target-sysroot-2-darwin-macos.default = \
|
target-sysroot-2-darwin-macos.default = \
|
||||||
remote:internal \
|
remote:internal
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
|
|
||||||
|
|
||||||
target-sysroot-2-darwin-macos.alt = \
|
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
|
|
||||||
|
|
||||||
target-toolchain-1-osx.default = \
|
target-toolchain-1-osx.default = \
|
||||||
remote:internal \
|
remote:internal
|
||||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
|
|
||||||
|
|
||||||
# Apple iOS.
|
# Apple iOS.
|
||||||
targetToolchain.osx-ios = target-toolchain-1-osx
|
targetToolchain.osx-ios = target-toolchain-1-osx
|
||||||
dependencies.osx-ios = target-toolchain-1-osx \
|
dependencies.osx-ios = \
|
||||||
libffi-3.2.1-2-darwin-ios \
|
libffi-3.2.1-2-darwin-ios \
|
||||||
clang-llvm-5.0.0-darwin-macos \
|
clang-llvm-5.0.0-darwin-macos
|
||||||
target-sysroot-3-darwin-ios
|
|
||||||
|
|
||||||
target-sysroot-3-darwin-ios.default = \
|
target-sysroot-3-darwin-ios.default = \
|
||||||
remote:internal \
|
remote:internal
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk
|
|
||||||
|
|
||||||
target-sysroot-3-darwin-ios.alt = \
|
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
|
|
||||||
|
|
||||||
arch.ios = arm64
|
arch.ios = arm64
|
||||||
entrySelector.ios = -alias _Konan_main _main
|
entrySelector.ios = -alias _Konan_main _main
|
||||||
@@ -98,17 +87,12 @@ osVersionMin.ios = 8.0
|
|||||||
|
|
||||||
# Apple iOS simulator.
|
# Apple iOS simulator.
|
||||||
targetToolchain.osx-ios_sim = target-toolchain-1-osx
|
targetToolchain.osx-ios_sim = target-toolchain-1-osx
|
||||||
dependencies.osx-ios_sim = target-toolchain-1-osx \
|
dependencies.osx-ios_sim = \
|
||||||
libffi-3.2.1-1-darwin-ios_sim \
|
libffi-3.2.1-1-darwin-ios_sim \
|
||||||
clang-llvm-5.0.0-darwin-macos \
|
clang-llvm-5.0.0-darwin-macos
|
||||||
target-sysroot-2-darwin-ios_sim
|
|
||||||
|
|
||||||
target-sysroot-2-darwin-ios_sim.default = \
|
target-sysroot-2-darwin-ios_sim.default = \
|
||||||
remote:internal \
|
remote:internal
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk
|
|
||||||
|
|
||||||
target-sysroot-2-darwin-ios_sim.alt = \
|
|
||||||
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
|
|
||||||
|
|
||||||
arch.ios_sim = x86_64
|
arch.ios_sim = x86_64
|
||||||
entrySelector.ios_sim = -alias _Konan_main _main
|
entrySelector.ios_sim = -alias _Konan_main _main
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ ext {
|
|||||||
|
|
||||||
// Force build to use only 'default' profile:
|
// Force build to use only 'default' profile:
|
||||||
konanProperties.setProperty(DEPENDENCY_PROFILES_KEY, "default")
|
konanProperties.setProperty(DEPENDENCY_PROFILES_KEY, "default")
|
||||||
|
// Force build to use fixed Xcode version:
|
||||||
|
konanProperties.setProperty("useFixedXcodeVersion", "9.2")
|
||||||
// TODO: it actually affects only resolution made in :dependencies,
|
// TODO: it actually affects only resolution made in :dependencies,
|
||||||
// that's why we assume that 'default' profile comes first (and check this above).
|
// that's why we assume that 'default' profile comes first (and check this above).
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-5
@@ -210,10 +210,7 @@ class HelperNativeDep extends TgzNativeDep {
|
|||||||
|
|
||||||
enum DependencyKind {
|
enum DependencyKind {
|
||||||
LLVM( "llvm", { it.llvmHome }, { "llvmDir" } ),
|
LLVM( "llvm", { it.llvmHome }, { "llvmDir" } ),
|
||||||
GCC_TOOLCHAIN( "gccToolchain", { (it instanceof LinuxBasedConfigurables) ? it.gccToolchain : null }, { "gccToolchainDir" }),
|
LIBFFI( "libffi", { it.libffiDir } )
|
||||||
SYSROOT( "sysroot", { it.targetSysRoot } ),
|
|
||||||
LIBFFI( "libffi", { it.libffiDir } ),
|
|
||||||
TARGET_TOOLCHAIN("targetToolchain", { it.targetToolchain } )
|
|
||||||
|
|
||||||
|
|
||||||
DependencyKind(String name,
|
DependencyKind(String name,
|
||||||
@@ -241,7 +238,8 @@ enum DependencyKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TargetManager.enabled.each { target ->
|
TargetManager.enabled.each { target ->
|
||||||
def konanProperties = new KonanPropertiesLoader(target,
|
def konanProperties = ConfigurablesImplKt.loadConfigurables(
|
||||||
|
target,
|
||||||
rootProject.ext.konanProperties,
|
rootProject.ext.konanProperties,
|
||||||
rootProject.ext.dependenciesDir.canonicalPath
|
rootProject.ext.dependenciesDir.canonicalPath
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -60,9 +60,43 @@ open class Command(initialCommand: List<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun execute() {
|
open fun execute() {
|
||||||
if (logger != null) logger!! { command.toList<String>().joinToString(" ") }
|
log()
|
||||||
|
|
||||||
val code = runProcess()
|
val code = runProcess()
|
||||||
|
handleExitCode(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOutputLines(): List<String> {
|
||||||
|
log()
|
||||||
|
|
||||||
|
val outputFile = createTempFile()
|
||||||
|
outputFile.deleteOnExit()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val builder = ProcessBuilder(command)
|
||||||
|
|
||||||
|
builder.redirectInput(Redirect.INHERIT)
|
||||||
|
builder.redirectError(Redirect.INHERIT)
|
||||||
|
builder.redirectOutput(ProcessBuilder.Redirect.to(outputFile))
|
||||||
|
// Note: getting process output could be done without redirecting to temporary file,
|
||||||
|
// however this would require managing a thread to read `process.inputStream` because
|
||||||
|
// it may have limited capacity.
|
||||||
|
|
||||||
|
val process = builder.start()
|
||||||
|
val code = process.waitFor()
|
||||||
|
handleExitCode(code)
|
||||||
|
|
||||||
|
return outputFile.readLines()
|
||||||
|
} finally {
|
||||||
|
outputFile.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleExitCode(code: Int) {
|
||||||
if (code != 0) throw KonanExternalToolFailure("The ${command[0]} command returned non-zero exit code: $code.", command[0])
|
if (code != 0) throw KonanExternalToolFailure("The ${command[0]} command returned non-zero exit code: $code.", command[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun log() {
|
||||||
|
if (logger != null) logger!! { command.toList<String>().joinToString(" ") }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed -> in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.target
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.properties.KonanPropertiesLoader
|
||||||
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
|
import org.jetbrains.kotlin.konan.util.InternalServer
|
||||||
|
|
||||||
|
class AppleConfigurablesImpl(
|
||||||
|
target: KonanTarget,
|
||||||
|
properties: Properties,
|
||||||
|
baseDir: String?
|
||||||
|
) : AppleConfigurables, KonanPropertiesLoader(target, properties, baseDir) {
|
||||||
|
|
||||||
|
private val sdkDependency = this.targetSysRoot!!
|
||||||
|
private val toolchainDependency = this.targetToolchain!!
|
||||||
|
|
||||||
|
override val absoluteTargetSysRoot: String get() = when (xcodePartsProvider) {
|
||||||
|
is XcodePartsProvider.Local -> when (target) {
|
||||||
|
KonanTarget.MACBOOK -> xcodePartsProvider.xcode.macosxSdk
|
||||||
|
KonanTarget.IPHONE -> xcodePartsProvider.xcode.iphoneosSdk
|
||||||
|
KonanTarget.IPHONE_SIM -> xcodePartsProvider.xcode.iphonesimulatorSdk
|
||||||
|
else -> error(target)
|
||||||
|
}
|
||||||
|
XcodePartsProvider.InternalServer -> absolute(sdkDependency)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val absoluteTargetToolchain: String get() = when (xcodePartsProvider) {
|
||||||
|
is XcodePartsProvider.Local -> xcodePartsProvider.xcode.toolchain
|
||||||
|
XcodePartsProvider.InternalServer -> absolute(toolchainDependency)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val dependencies get() = super.dependencies + when (xcodePartsProvider) {
|
||||||
|
is XcodePartsProvider.Local -> emptyList()
|
||||||
|
XcodePartsProvider.InternalServer -> listOf(sdkDependency, toolchainDependency)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val xcodePartsProvider = if (InternalServer.isAvailable) {
|
||||||
|
XcodePartsProvider.InternalServer
|
||||||
|
} else {
|
||||||
|
val xcode = Xcode.current
|
||||||
|
properties.getProperty("useFixedXcodeVersion")?.let { requiredXcodeVersion ->
|
||||||
|
val currentXcodeVersion = xcode.version
|
||||||
|
|
||||||
|
if (currentXcodeVersion != requiredXcodeVersion) {
|
||||||
|
error("expected Xcode version $requiredXcodeVersion, got $currentXcodeVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XcodePartsProvider.Local(xcode)
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class XcodePartsProvider {
|
||||||
|
class Local(val xcode: Xcode) : XcodePartsProvider()
|
||||||
|
object InternalServer : XcodePartsProvider()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,9 +27,6 @@ class LinuxMIPSConfigurablesImpl(target: KonanTarget, properties: Properties, ba
|
|||||||
class AndroidConfigurablesImpl(target: KonanTarget, properties: Properties, baseDir: String?)
|
class AndroidConfigurablesImpl(target: KonanTarget, properties: Properties, baseDir: String?)
|
||||||
: AndroidConfigurables, KonanPropertiesLoader(target, properties, baseDir)
|
: AndroidConfigurables, KonanPropertiesLoader(target, properties, baseDir)
|
||||||
|
|
||||||
class AppleConfigurablesImpl(target: KonanTarget, properties: Properties, baseDir: String?)
|
|
||||||
: AppleConfigurables, KonanPropertiesLoader(target, properties, baseDir)
|
|
||||||
|
|
||||||
class MingwConfigurablesImpl(target: KonanTarget, properties: Properties, baseDir: String?)
|
class MingwConfigurablesImpl(target: KonanTarget, properties: Properties, baseDir: String?)
|
||||||
: MingwConfigurables, KonanPropertiesLoader(target, properties, baseDir)
|
: MingwConfigurables, KonanPropertiesLoader(target, properties, baseDir)
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ interface TargetableExternalStorage {
|
|||||||
fun downloadDependencies()
|
fun downloadDependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
open class KonanPropertiesLoader(override val target: KonanTarget, val properties: Properties, val baseDir: String? = null) : Configurables {
|
abstract class KonanPropertiesLoader(override val target: KonanTarget, val properties: Properties, val baseDir: String? = null) : Configurables {
|
||||||
val dependencies get() = hostTargetList("dependencies")
|
open val dependencies get() = hostTargetList("dependencies")
|
||||||
|
|
||||||
override fun downloadDependencies() {
|
override fun downloadDependencies() {
|
||||||
dependencyProcessor!!.run()
|
dependencyProcessor!!.run()
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.target
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.KonanExternalToolFailure
|
||||||
|
import org.jetbrains.kotlin.konan.exec.Command
|
||||||
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
|
|
||||||
|
interface Xcode {
|
||||||
|
val toolchain: String
|
||||||
|
val macosxSdk: String
|
||||||
|
val iphoneosSdk: String
|
||||||
|
val iphonesimulatorSdk: String
|
||||||
|
val version: String
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val current: Xcode by lazy {
|
||||||
|
CurrentXcode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private object CurrentXcode : Xcode {
|
||||||
|
|
||||||
|
override val toolchain by lazy {
|
||||||
|
val ldPath = xcrun("-f", "ld") // = $toolchain/usr/bin/ld
|
||||||
|
File(ldPath).parentFile.parentFile.parentFile.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
override val macosxSdk by lazy { getSdkPath("macosx") }
|
||||||
|
override val iphoneosSdk by lazy { getSdkPath("iphoneos") }
|
||||||
|
override val iphonesimulatorSdk by lazy { getSdkPath("iphonesimulator") }
|
||||||
|
|
||||||
|
override val version by lazy {
|
||||||
|
xcrun("xcodebuild", "-version")
|
||||||
|
.removePrefix("Xcode ")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun xcrun(vararg args: String): String =
|
||||||
|
Command("/usr/bin/xcrun", *args).getOutputLines().first() // TODO: handle execution error
|
||||||
|
|
||||||
|
private fun getSdkPath(sdk: String) = xcrun("--sdk", sdk, "--show-sdk-path")
|
||||||
|
}
|
||||||
@@ -273,7 +273,7 @@ class DependencyProcessor(dependenciesRoot: File,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private object InternalServer {
|
internal object InternalServer {
|
||||||
private val host = "repo.labs.intellij.net"
|
private val host = "repo.labs.intellij.net"
|
||||||
val url = "http://$host/kotlin-native"
|
val url = "http://$host/kotlin-native"
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH
|
|||||||
CURRENT_ARCH
|
CURRENT_ARCH
|
||||||
DEVELOPER_APPLICATIONS_DIR
|
DEVELOPER_APPLICATIONS_DIR
|
||||||
DEVELOPER_BIN_DIR
|
DEVELOPER_BIN_DIR
|
||||||
DEVELOPER_DIR
|
|
||||||
DEVELOPER_FRAMEWORKS_DIR
|
DEVELOPER_FRAMEWORKS_DIR
|
||||||
DEVELOPER_FRAMEWORKS_DIR_QUOTED
|
DEVELOPER_FRAMEWORKS_DIR_QUOTED
|
||||||
DEVELOPER_LIBRARY_DIR
|
DEVELOPER_LIBRARY_DIR
|
||||||
|
|||||||
Reference in New Issue
Block a user