alef-backend-kotlin 0.17.35

Kotlin (JVM) backend for alef
Documentation
//! Emit the `build.gradle.kts` for a Kotlin/Native project.

use alef_core::config::ResolvedCrateConfig;
use alef_core::template_versions;

/// Generate the `build.gradle.kts` contents for the Kotlin/Native module.
pub(super) fn emit_gradle_build(config: &ResolvedCrateConfig) -> String {
    let crate_name = &config.name;
    let kotlin_version = template_versions::maven::KOTLIN_JVM_PLUGIN;

    format!(
        r#"// Generated by alef. Do not edit by hand.
// To build for a different host triple, replace `linuxX64()` with
// `macosX64()` or `macosArm64()` and update the linkerOpts path accordingly.

plugins {{
    kotlin("multiplatform") version "{kotlin_version}"
}}

kotlin {{
    linuxX64 {{
        compilations["main"].cinterops {{
            val {crate_name} by creating {{
                defFile = project.file("{crate_name}.def")
            }}
        }}
        binaries {{
            sharedLib()
        }}
    }}
}}
"#
    )
}