Hey All, I am making a multiplatform library. On ...
# kotlin-native
p
Hey All, I am making a multiplatform library. On the iOS side, i was able to selectively perform linkTask using buildTypes parameter in framework (inside target.binaries). But it is still compiling for all targets. How do I selectively compile using build type?
s
You can find all the build tasks you have access too by running
./gradlew :<your project name here>:tasks
You should see something like this:
Copy code
Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
clean - Deletes the build directory.
compileKotlinLinuxX64 - Compiles a klibrary from the 'main' compilation for target 'native'.
compileKotlinMacosX64 - Compiles a klibrary from the 'main' compilation for target 'native'.
compileTestKotlinLinuxX64 - Compiles a klibrary from the 'test' compilation for target 'native'.
compileTestKotlinMacosX64 - Compiles a klibrary from the 'test' compilation for target 'native'.
jsJar - Assembles a jar archive containing the main classes.
jsMainClasses - Assembles outputs for compilation 'main' of target 'js'
jsTestClasses - Assembles outputs for compilation 'test' of target 'js'
jvmJar - Assembles a jar archive containing the main classes.
jvmMainClasses - Assembles outputs for compilation 'main' of target 'jvm'
jvmTestClasses - Assembles outputs for compilation 'test' of target 'jvm'
linkDebugTestLinuxX64 - Links a test executable 'debugTest' for a target 'linuxX64'.
linkDebugTestMacosX64 - Links a test executable 'debugTest' for a target 'macosX64'.
linuxX64MainKlibrary - Assembles outputs for compilation 'main' of target 'linuxX64'
linuxX64TestKlibrary - Assembles outputs for compilation 'test' of target 'linuxX64'
macosX64MainKlibrary - Assembles outputs for compilation 'main' of target 'macosX64'
macosX64TestKlibrary - Assembles outputs for compilation 'test' of target 'macosX64'
metadataJar - Assembles a jar archive containing the main classes.
metadataMainClasses - Assembles outputs for compilation 'main' of target 'metadata'
There is a build task to build the various different source sets and targets. Is that what you were looking for?
p
Thanks for the response Scott. I was looking to compile the various source sets selectively based on whether it is ios 64 or ios 32.
I am able to do the same with linkTask using the buildType parameter in framework
Copy code
targets {
    for (target in getIOSTargetList()) {
        target.apply {
            println("target is ${this.name}")
            binaries {
                framework(frameworkName, getNativeBuildTypes()) {
                    export(project(":phonepe-kn-kernel"))
                    export(project(":phonepe-kn-os"))
                    export(project(":analytics"))
                }
            }
        }
    }
}
but could not find a way to do the same for compile Task
Fixed it. Basically, I was creating all the targets which in turn created BinaryNativeContainer and that created the compile tasks. Once I created targets on demand, it started compiling only one target.