[K/N] Deprecate -Xbundle-id and use binary options for Info.plist.
This commit is contained in:
@@ -382,8 +382,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
})
|
})
|
||||||
putIfNotNull(RUNTIME_LOGS, arguments.runtimeLogs)
|
putIfNotNull(RUNTIME_LOGS, arguments.runtimeLogs)
|
||||||
putIfNotNull(BUNDLE_ID, parseBundleId(arguments, outputKind, configuration))
|
putIfNotNull(BUNDLE_ID, parseBundleId(arguments, outputKind, configuration))
|
||||||
putIfNotNull(BUNDLE_SHORT_VERSION_STRING, arguments.bundleShortVersionString)
|
|
||||||
putIfNotNull(BUNDLE_VERSION, arguments.bundleVersion)
|
|
||||||
put(MEANINGFUL_BRIDGE_NAMES, arguments.meaningfulBridgeNames)
|
put(MEANINGFUL_BRIDGE_NAMES, arguments.meaningfulBridgeNames)
|
||||||
arguments.testDumpOutputPath?.let { put(TEST_DUMP_OUTPUT_PATH, it) }
|
arguments.testDumpOutputPath?.let { put(TEST_DUMP_OUTPUT_PATH, it) }
|
||||||
put(PARTIAL_LINKAGE, arguments.partialLinkage)
|
put(PARTIAL_LINKAGE, arguments.partialLinkage)
|
||||||
|
|||||||
+1
-15
@@ -105,24 +105,10 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
|||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xbundle-id",
|
value = "-Xbundle-id",
|
||||||
valueDescription = "<id>",
|
valueDescription = "<id>",
|
||||||
description = "Bundle ID to be set in Info.plist of a produced framework"
|
description = "Bundle ID to be set in Info.plist of a produced framework. Deprecated. Please use -Xbinary=bundleId=<id>."
|
||||||
)
|
)
|
||||||
var bundleId: String? = null
|
var bundleId: String? = null
|
||||||
|
|
||||||
@Argument(
|
|
||||||
value = "-Xbundle-short-version-string",
|
|
||||||
valueDescription = "<short version string>",
|
|
||||||
description = "Bundle short version string to be set in Info.plist of a produced framework"
|
|
||||||
)
|
|
||||||
var bundleShortVersionString: String? = null
|
|
||||||
|
|
||||||
@Argument(
|
|
||||||
value = "-Xbundle-version",
|
|
||||||
valueDescription = "<version>",
|
|
||||||
description = "Bundle version to be set in Info.plist of a produced framework"
|
|
||||||
)
|
|
||||||
var bundleVersion: String? = null
|
|
||||||
|
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xcache-directory",
|
value = "-Xcache-directory",
|
||||||
valueDescription = "<path>",
|
valueDescription = "<path>",
|
||||||
|
|||||||
+19
@@ -31,6 +31,10 @@ object BinaryOptions : BinaryOptionRegistry() {
|
|||||||
val gcSchedulerType by option<GCSchedulerType>()
|
val gcSchedulerType by option<GCSchedulerType>()
|
||||||
|
|
||||||
val linkRuntime by option<RuntimeLinkageStrategyBinaryOption>()
|
val linkRuntime by option<RuntimeLinkageStrategyBinaryOption>()
|
||||||
|
|
||||||
|
val bundleId by stringOption()
|
||||||
|
val bundleShortVersionString by stringOption()
|
||||||
|
val bundleVersion by stringOption()
|
||||||
}
|
}
|
||||||
|
|
||||||
open class BinaryOption<T : Any>(
|
open class BinaryOption<T : Any>(
|
||||||
@@ -66,6 +70,15 @@ open class BinaryOptionRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun stringOption(): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, CompilerConfigurationKey<String>>> =
|
||||||
|
PropertyDelegateProvider { _, property ->
|
||||||
|
val option = BinaryOption(property.name, StringValueParser)
|
||||||
|
register(option)
|
||||||
|
ReadOnlyProperty { _, _ ->
|
||||||
|
option.compilerConfigurationKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected inline fun <reified T : Enum<T>> option(): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, CompilerConfigurationKey<T>>> =
|
protected inline fun <reified T : Enum<T>> option(): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, CompilerConfigurationKey<T>>> =
|
||||||
PropertyDelegateProvider { _, property ->
|
PropertyDelegateProvider { _, property ->
|
||||||
val option = BinaryOption(property.name, EnumValueParser(enumValues<T>().toList()))
|
val option = BinaryOption(property.name, EnumValueParser(enumValues<T>().toList()))
|
||||||
@@ -83,6 +96,12 @@ private object BooleanValueParser : BinaryOption.ValueParser<Boolean> {
|
|||||||
get() = "true|false"
|
get() = "true|false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object StringValueParser : BinaryOption.ValueParser<String> {
|
||||||
|
override fun parse(value: String) = value
|
||||||
|
override val validValuesHint: String?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal class EnumValueParser<T : Enum<T>>(val values: List<T>) : BinaryOption.ValueParser<T> {
|
internal class EnumValueParser<T : Enum<T>>(val values: List<T>) : BinaryOption.ValueParser<T> {
|
||||||
// TODO: should we really ignore case here?
|
// TODO: should we really ignore case here?
|
||||||
|
|||||||
-4
@@ -14,10 +14,6 @@ class KonanConfigKeys {
|
|||||||
// Keep the list lexically sorted.
|
// Keep the list lexically sorted.
|
||||||
val BUNDLE_ID: CompilerConfigurationKey<String>
|
val BUNDLE_ID: CompilerConfigurationKey<String>
|
||||||
= CompilerConfigurationKey.create("bundle ID to be set in Info.plist of a produced framework")
|
= CompilerConfigurationKey.create("bundle ID to be set in Info.plist of a produced framework")
|
||||||
val BUNDLE_SHORT_VERSION_STRING: CompilerConfigurationKey<String>
|
|
||||||
= CompilerConfigurationKey.create("bundle short version string to be set in Info.plist of the produced framework")
|
|
||||||
val BUNDLE_VERSION: CompilerConfigurationKey<String>
|
|
||||||
= CompilerConfigurationKey.create("bundle version to be set in Info.plist of the produced framework")
|
|
||||||
val CHECK_DEPENDENCIES: CompilerConfigurationKey<Boolean>
|
val CHECK_DEPENDENCIES: CompilerConfigurationKey<Boolean>
|
||||||
= CompilerConfigurationKey.create("check dependencies and download the missing ones")
|
= CompilerConfigurationKey.create("check dependencies and download the missing ones")
|
||||||
val DEBUG: CompilerConfigurationKey<Boolean>
|
val DEBUG: CompilerConfigurationKey<Boolean>
|
||||||
|
|||||||
+13
-7
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.backend.konan.objcexport
|
|||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.BUNDLE_ID
|
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.BUNDLE_ID
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.BUNDLE_SHORT_VERSION_STRING
|
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.BUNDLE_VERSION
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getPackageFragments
|
import org.jetbrains.kotlin.backend.konan.descriptors.getPackageFragments
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
||||||
import org.jetbrains.kotlin.backend.konan.getExportedDependencies
|
import org.jetbrains.kotlin.backend.konan.getExportedDependencies
|
||||||
@@ -166,8 +164,8 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
|||||||
|
|
||||||
val file = directory.child("Info.plist")
|
val file = directory.child("Info.plist")
|
||||||
val bundleId = guessBundleID(name)
|
val bundleId = guessBundleID(name)
|
||||||
val bundleShortVersionString = context.configuration[BUNDLE_SHORT_VERSION_STRING] ?: "1.0"
|
val bundleShortVersionString = context.configuration[BinaryOptions.bundleShortVersionString] ?: "1.0"
|
||||||
val bundleVersion = context.configuration[BUNDLE_VERSION] ?: "1"
|
val bundleVersion = context.configuration[BinaryOptions.bundleVersion] ?: "1"
|
||||||
val platform = properties.platformName()
|
val platform = properties.platformName()
|
||||||
val minimumOsVersion = properties.osVersionMin
|
val minimumOsVersion = properties.osVersionMin
|
||||||
|
|
||||||
@@ -320,9 +318,17 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
|||||||
|
|
||||||
private fun guessBundleID(bundleName: String): String {
|
private fun guessBundleID(bundleName: String): String {
|
||||||
val configuration = context.configuration
|
val configuration = context.configuration
|
||||||
configuration[BUNDLE_ID]?.let {
|
val deprecatedBundleIdOption = configuration[BUNDLE_ID]
|
||||||
return it
|
val bundleIdOption = configuration[BinaryOptions.bundleId]
|
||||||
|
if (deprecatedBundleIdOption != null && bundleIdOption != null && deprecatedBundleIdOption != bundleIdOption) {
|
||||||
|
configuration.report(
|
||||||
|
CompilerMessageSeverity.ERROR,
|
||||||
|
"Both the deprecated -Xbundle-id=<id> and the new -Xbinary=bundleId=<id> options supplied with different values: " +
|
||||||
|
"'$deprecatedBundleIdOption' and '$bundleIdOption'. " +
|
||||||
|
"Please use only one of the options or make sure they have the same value."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
deprecatedBundleIdOption?.let { return it } ?: bundleIdOption?.let { return it }
|
||||||
|
|
||||||
// Consider exported libraries only if we cannot infer the package from sources or included libs.
|
// Consider exported libraries only if we cannot infer the package from sources or included libs.
|
||||||
val mainPackage = guessMainPackage(context.getIncludedLibraryDescriptors() + context.moduleDescriptor)
|
val mainPackage = guessMainPackage(context.getIncludedLibraryDescriptors() + context.moduleDescriptor)
|
||||||
@@ -336,7 +342,7 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
|||||||
CompilerMessageSeverity.STRONG_WARNING,
|
CompilerMessageSeverity.STRONG_WARNING,
|
||||||
"Cannot infer a bundle ID from packages of source files and exported dependencies, " +
|
"Cannot infer a bundle ID from packages of source files and exported dependencies, " +
|
||||||
"use the bundle name instead: $bundleName. " +
|
"use the bundle name instead: $bundleName. " +
|
||||||
"Please specify the bundle ID explicitly using the -Xbundle-id compiler flag."
|
"Please specify the bundle ID explicitly using the -Xbinary=bundleId=<id> compiler flag."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return bundleID
|
return bundleID
|
||||||
|
|||||||
@@ -5417,7 +5417,7 @@ if (isAppleTarget(project)) {
|
|||||||
framework(frameworkName) {
|
framework(frameworkName) {
|
||||||
sources = ['objcexport']
|
sources = ['objcexport']
|
||||||
library = libraryName
|
library = libraryName
|
||||||
opts = ["-Xemit-lazy-objc-header=$lazyHeader", "-Xexport-kdoc", "-Xbundle-id=foo.bar"]
|
opts = ["-Xemit-lazy-objc-header=$lazyHeader", "-Xexport-kdoc", "-Xbinary=bundleId=foo.bar"]
|
||||||
}
|
}
|
||||||
swiftSources = ['objcexport']
|
swiftSources = ['objcexport']
|
||||||
if (isNoopGC) {
|
if (isNoopGC) {
|
||||||
@@ -5684,7 +5684,7 @@ if (isAppleTarget(project)) {
|
|||||||
|
|
||||||
framework("Foo") {
|
framework("Foo") {
|
||||||
sources = ["framework/bundle_id/main.kt", "framework/bundle_id/lib.kt"]
|
sources = ["framework/bundle_id/main.kt", "framework/bundle_id/lib.kt"]
|
||||||
opts = ["-Xbundle-version=FooBundleVersion", "-Xbundle-short-version-string=FooBundleShortVersionString"]
|
opts = ["-Xbinary=bundleVersion=FooBundleVersion", "-Xbinary=bundleShortVersionString=FooBundleShortVersionString"]
|
||||||
}
|
}
|
||||||
swiftSources = []
|
swiftSources = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user