Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import tiktok.knit.plugin.knitVMAnnotationDesc
import tiktok.knit.plugin.providesDesc
import tiktok.knit.plugin.singletonDesc
import tiktok.knit.plugin.toFieldAccess
import tiktok.knit.plugin.writer.VMProperty
import kotlin.metadata.Visibility
import kotlin.metadata.isSecondary
import kotlin.metadata.jvm.signature
Expand Down Expand Up @@ -56,6 +57,9 @@ data class ComponentClass(
emptyMap(), emptyList(), emptyList(), false,
)

// Internal names of all vm properties in this component class, used for incremental build
val vmPropertyInternalNames = hashSetOf<InternalName>()

companion object {
fun from(container: MetadataContainer): ComponentClass {
val classNode = container.node
Expand Down
3 changes: 3 additions & 0 deletions knit-asm/src/main/java/tiktok/knit/plugin/writer/VMWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ fun generateVMLogic(context: KnitContext, classNode: ClassNode, thisComponent: B
val allVMProperties = getVMProperties(context, classNode, thisComponent)
if (allVMProperties.isEmpty()) return

val componentClass = context.componentMap[classNode.name]
componentClass?.vmPropertyInternalNames?.addAll(allVMProperties.map { it.type.internalName })

// create vm prop provider functions
for (vmProp in allVMProperties) {
val backendFunctionName = vmProp.property.name + "\$knitVm"
Expand Down
10 changes: 9 additions & 1 deletion knit-bytex/src/main/java/tiktok/knit/bytex/KnitContextImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,18 @@ class KnitContextImpl(
depsMap[internalName]?.forEach { producer ->
allNonIncrementalFiles += "$producer.class"
}
allNonIncrementalFiles += calculateVMRelatedClasses(internalName).map { "$it.class" }
}
return allNonIncrementalFiles
}

private fun calculateVMRelatedClasses(changedClass: String): Collection<InternalName> {
val componentMap = componentMap
return componentMap.filter {
changedClass in it.value.vmPropertyInternalNames
}.keys
}

class Storage(
val componentMap: Map<InternalName, ComponentClass>,
val backDepsMap: Map<InternalName, MutableSet<InternalName>>,
Expand All @@ -170,4 +178,4 @@ class KnitContextImpl(

private val gson by lazy { Gson() }
private const val cacheName = "knit-cache.json"
private val globalProvidesClass = "$globalProvidesInternalName.class"
private val globalProvidesClass = "$globalProvidesInternalName.class"