Repository: JetBrains/kotlin
File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt (Kotlin)

Code before:

    internal val includeBinaries: List<String> =
            configuration.getList(KonanConfigKeys.INCLUDED_BINARY_FILES)

    internal val languageVersionSettings =
            configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!!

    internal val friendModuleFiles: Set<File> =
            configuration.get(KonanConfigKeys.FRIEND_MODULES)?.map { File(it) }?.toSet() ?: emptySet()

    internal val manifestProperties = configuration.get(KonanConfigKeys.MANIFEST_FILE)?.let {
        File(it).loadProperties()
    }

    internal val isInteropStubs: Boolean get() = manifestProperties?.getProperty("interop") == "true"

    internal val propertyLazyInitialization: Boolean get() = configuration.get(KonanConfigKeys.PROPERTY_LAZY_INITIALIZATION)!!

    internal val lazyIrForCaches: Boolean get() = configuration.get(KonanConfigKeys.LAZY_IR_FOR_CACHES)!!

    internal val entryPointName: String by lazy {
        if (target.family == Family.ANDROID) {
            val androidProgramTypeOrNull = configuration.get(BinaryOptions.androidProgramType)
            if (androidProgramTypeOrNull == null) {
                configuration.report(CompilerMessageSeverity.WARNING,
                        "Android Native executables are currently built as shared libraries with NativeActivity support, but the " +
                                "default behavior is going to change to build regular executables instead. To keep using NativeActivity " +
                                "support, please add the compiler flag '-Xbinary=androidProgramType=nativeActivity'.")
            }
            val androidProgramType = androidProgramTypeOrNull ?: AndroidProgramType.Default
            if (androidProgramType.konanMainOverride != null) {
                return@lazy androidProgramType.konanMainOverride
            }
        }
        "Konan_main"
    }
}

fun CompilerConfiguration.report(priority: CompilerMessageSeverity, message: String)
    = this.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(priority, message)


Review comment (suggestion):
The absolute majority of our users invoke compiler via Gradle, so it makes sense to show how to adjust Gradle script instead of compiler flag. Let's change the message to the following:

> Android Native executables are currently built as shared libraries with NativeActivity support, but the default behavior is going to change in 1.7.0 to build regular executables instead.
> To keep using NativeActivity support, add `binaryOptions["androidProgramType"] = "nativeActivity"` to your androidNative executable configuration block in Gradle script:
> ```
> binaries {
>     executable {
>         binaryOptions["androidProgramType"] = "nativeActivity"
>     }
> }
> ```
> See https://youtrack.jetbrains.com/issue/KT-49406 for more details.

I'll populate the YouTrack ticket with a content (including other ways to tune the compiler behavior) a bit later.

Code after:

    internal val includeBinaries: List<String> =
            configuration.getList(KonanConfigKeys.INCLUDED_BINARY_FILES)

    internal val languageVersionSettings =
            configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!!

    internal val friendModuleFiles: Set<File> =
            configuration.get(KonanConfigKeys.FRIEND_MODULES)?.map { File(it) }?.toSet() ?: emptySet()

    internal val manifestProperties = configuration.get(KonanConfigKeys.MANIFEST_FILE)?.let {
        File(it).loadProperties()
    }

    internal val isInteropStubs: Boolean get() = manifestProperties?.getProperty("interop") == "true"

    internal val propertyLazyInitialization: Boolean get() = configuration.get(KonanConfigKeys.PROPERTY_LAZY_INITIALIZATION)!!

    internal val lazyIrForCaches: Boolean get() = configuration.get(KonanConfigKeys.LAZY_IR_FOR_CACHES)!!

    internal val entryPointName: String by lazy {
        if (target.family == Family.ANDROID) {
            val androidProgramTypeOrNull = configuration.get(BinaryOptions.androidProgramType)
            if (androidProgramTypeOrNull == null) {
                configuration.report(CompilerMessageSeverity.WARNING, """
                    Android Native executables are currently built as shared libraries with NativeActivity support, but the default behavior is going to change in 1.7.0 to build regular executables instead.
                    To keep using NativeActivity support, add binaryOptions["androidProgramType"] = "nativeActivity" to your androidNative executable configuration block in Gradle script:
                    binaries {
                        executable {
                            binaryOptions["androidProgramType"] = "nativeActivity"
                        }
                    }
                    See https://youtrack.jetbrains.com/issue/KT-49406 for more details.
                """.trimIndent())
            }
            val androidProgramType = androidProgramTypeOrNull ?: AndroidProgramType.Default
            if (androidProgramType.konanMainOverride != null) {
                return@lazy androidProgramType.konanMainOverride
            }
        }
        "Konan_main"
    }
}

fun CompilerConfiguration.report(priority: CompilerMessageSeverity, message: String)
    = this.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(priority, message)