上游 · Kotlin compiler options · Native
-output name (-o name )
Set the name for the output file.
-produce output (-p output )
Specify output file kind:
program
static
dynamic
framework
library
bitcode
全部配置 / KN-PRODUCE
produce · KN-PRODUCE · 编译器参数(Native)
默认值:未设置。未指定时由消费侧决定;未核对前不写死取值。使用场合:场景可配。场景可配:有明确目标(性能、包体、安全、兼容)时再改。
用途。指定产物类型(可执行文件、框架、库等)。原文:Specify the output file kind.
影响。决定产物形态或目标平台。
适用场景。场景可配。有明确需求再改,无需求时保持发行版默认更稳妥。改前核对目标限制与联动项,改后做冒烟。
| 可写取值 | 含义 | 使用场景 |
|---|---|---|
program | 产出可执行程序(program) | 需要可直接运行的 native 可执行文件时 |
static | 产出静态库(static) | 需要静态链接入库时 |
dynamic | 产出动态库(dynamic) | 需要动态库产物时 |
framework | 产出 Apple framework | iOS/macOS framework 集成时 |
library | 产出 klib/库形态(library) | 库模块编译产物时 |
bitcode | 产出 LLVM bitcode | 需要 bitcode 中间产物时 |
含义/场景依据:NativeCompilerArguments valueDescription + description「output file kind」; NativeCompilerArguments valueDescription
定义依据:description/NativeCompilerArguments.kt 在仓库中打开
// 文件:build.gradle.kts(应用的 Kotlin 模块,例如 composeApp)
kotlin {
ohosArm64 { // 按实际 native target 调整
binaries.all {
freeCompilerArgs += "-produce"
}
}
}
不写这个配置时,编译器会怎么处理?
此选项默认未设置(空列表 / 空映射 / null)。不设置时由其他逻辑决定行为或直接跳过。
未指定时由消费侧决定;未核对前不写死取值。
以下摘抄原文中与本配置最相关的段落,便于速读;完整上下文请点原文。
-output name (-o name )
Set the name for the output file.
-produce output (-p output )
Specify output file kind:
program
static
dynamic
framework
library
bitcode