Generate KotlinNativeCompilerOptions Gradle DSL

^KT-53108 In Progress
This commit is contained in:
Yahor Berdnikau
2023-02-16 18:53:04 +01:00
committed by Space Team
parent 68841fa031
commit 96316a4016
5 changed files with 111 additions and 2 deletions
@@ -32,7 +32,7 @@ interface AdditionalGradleProperties {
private data class GeneratedOptions(
val optionsName: FqName,
val deprecatedOptionsName: FqName,
val deprecatedOptionsName: FqName?,
val properties: List<KProperty1<*, *>>
)
@@ -92,6 +92,19 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
withPrinterToFile
)
val nativeOptions = generateKotlinNativeOptions(
apiSrcDir,
commonCompilerOptions,
withPrinterToFile
)
generateKotlinNativeOptionsImpl(
srcDir,
nativeOptions.optionsName,
commonCompilerOptionsImplFqName,
nativeOptions.properties,
withPrinterToFile
)
val jsDceOptions = generateJsDceOptions(
apiSrcDir,
commonToolOptions,
@@ -340,6 +353,48 @@ private fun generateKotlinJsOptionsImpl(
}
}
private fun generateKotlinNativeOptions(
apiSrcDir: File,
commonCompilerOptions: GeneratedOptions,
withPrinterToFile: (targetFile: File, Printer.() -> Unit) -> Unit
): GeneratedOptions {
val nativeInterfaceFqName = FqName("$OPTIONS_PACKAGE_PREFIX.KotlinNativeCompilerOptions")
val nativeOptions = gradleOptions<K2NativeCompilerArguments>()
withPrinterToFile(fileFromFqName(apiSrcDir, nativeInterfaceFqName)) {
generateInterface(
nativeInterfaceFqName,
nativeOptions,
parentType = commonCompilerOptions.optionsName,
)
}
println("\n### Attributes specific for Native\n")
generateMarkdown(nativeOptions)
return GeneratedOptions(nativeInterfaceFqName, null, nativeOptions)
}
private fun generateKotlinNativeOptionsImpl(
srcDir: File,
nativeInterfaceFqName: FqName,
commonCompilerImpl: FqName,
nativeOptions: List<KProperty1<*, *>>,
withPrinterToFile: (targetFile: File, Printer.() -> Unit) -> Unit
) {
val k2NativeCompilerArgumentsFqName = FqName(K2NativeCompilerArguments::class.qualifiedName!!)
val nativeImplFqName = FqName("${nativeInterfaceFqName.asString()}$IMPLEMENTATION_SUFFIX")
withPrinterToFile(fileFromFqName(srcDir, nativeImplFqName)) {
generateImpl(
nativeImplFqName,
commonCompilerImpl,
nativeInterfaceFqName,
k2NativeCompilerArgumentsFqName,
nativeOptions
)
}
}
private fun generateJsDceOptions(
apiSrcDir: File,
commonToolOptions: GeneratedOptions,