Add minor code improvements
This commit is contained in:
committed by
SvyatoslavScherbina
parent
8591f13b94
commit
338152263a
+3
-3
@@ -186,9 +186,9 @@ internal class LinkStage(val context: Context) {
|
||||
} else {
|
||||
val framework = File(context.config.outputFile)
|
||||
val dylibName = framework.name.removeSuffix(".framework")
|
||||
val dylibRelativePath = when (target) {
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64, KonanTarget.IOS_X64 -> dylibName
|
||||
KonanTarget.MACOS_X64 -> "Versions/A/$dylibName"
|
||||
val dylibRelativePath = when (target.family) {
|
||||
Family.IOS -> dylibName
|
||||
Family.OSX -> "Versions/A/$dylibName"
|
||||
else -> error(target)
|
||||
}
|
||||
frameworkLinkerArgs = listOf("-install_name", "@rpath/${framework.name}/$dylibRelativePath")
|
||||
|
||||
+3
-3
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.backend.konan.irasdescriptors.*
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.objc.ObjCDataGenerator
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
|
||||
internal class CodeGenerator(override val context: Context) : ContextUtils {
|
||||
@@ -97,9 +98,8 @@ internal class CodeGenerator(override val context: Context) : ContextUtils {
|
||||
return LLVMCreateLocation(LLVMGetModuleContext(context.llvmModule), locationInfo.line, locationInfo.line, locationInfo.scope)
|
||||
}
|
||||
|
||||
val objCDataGenerator = when (context.config.target) {
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_X64, KonanTarget.MACOS_X64 -> ObjCDataGenerator(this)
|
||||
val objCDataGenerator = when (context.config.target.family) {
|
||||
Family.IOS, Family.OSX -> ObjCDataGenerator(this)
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -579,7 +579,8 @@ private fun ObjCExportCodeGenerator.generateObjCImp(
|
||||
tailrec fun genReturnValueOnSuccess(returnBridge: MethodBridge.ReturnValue): LLVMValueRef? = when (returnBridge) {
|
||||
MethodBridge.ReturnValue.Void -> null
|
||||
MethodBridge.ReturnValue.HashCode -> {
|
||||
zext(targetResult!!, if (codegen.context.is64Bit()) int64Type else int32Type)
|
||||
val kotlinHashCode = targetResult!!
|
||||
if (codegen.context.is64Bit()) zext(kotlinHashCode, int64Type) else kotlinHashCode
|
||||
}
|
||||
is MethodBridge.ReturnValue.Mapped -> kotlinToObjC(targetResult!!, returnBridge.bridge)
|
||||
MethodBridge.ReturnValue.WithError.Success -> Int8(1).llvm // true
|
||||
@@ -683,7 +684,7 @@ private fun ObjCExportCodeGenerator.generateKotlinToObjCBridge(
|
||||
val high = trunc(shr(targetResult, 32, signed = false), int32Type)
|
||||
xor(low, high)
|
||||
} else {
|
||||
trunc(targetResult, int32Type)
|
||||
targetResult
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -164,10 +164,8 @@ internal class ObjCExport(val codegen: CodeGenerator) {
|
||||
""".trimIndent())
|
||||
|
||||
|
||||
contents.append(when (target) {
|
||||
KonanTarget.IOS_ARM32,
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_X64 -> """
|
||||
contents.append(when (target.family) {
|
||||
Family.IOS -> """
|
||||
| <key>MinimumOSVersion</key>
|
||||
| <string>$minimumOsVersion</string>
|
||||
| <key>UIDeviceFamily</key>
|
||||
@@ -177,7 +175,7 @@ internal class ObjCExport(val codegen: CodeGenerator) {
|
||||
| </array>
|
||||
|
||||
""".trimMargin()
|
||||
KonanTarget.MACOS_X64 -> ""
|
||||
Family.OSX -> ""
|
||||
else -> error(target)
|
||||
})
|
||||
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.internal.reflect.Instantiator
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
import java.io.File
|
||||
@@ -126,7 +127,7 @@ open class KonanFramework(name: String,
|
||||
get() = project.konanBinBaseDir
|
||||
|
||||
override fun targetIsSupported(target: KonanTarget): Boolean =
|
||||
target == MACOS_X64 || target == IOS_ARM32 || target == IOS_ARM64 || target == IOS_X64
|
||||
target.family == Family.OSX || target.family == Family.IOS
|
||||
}
|
||||
|
||||
open class KonanLibrary(name: String,
|
||||
|
||||
Reference in New Issue
Block a user