Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32b1b355 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Use deterministic hash for generate ProtoLogImpl postfix

This is to make sure build artifacts are more deterministic to improve developer build time, RBE cache rate, and testing infrastructure load.

Bug: 327529918
Test: none
Change-Id: I47f47bf657eed853c683995b47f48943ab0ed9e0
parent ea2bc080
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.jar.JarOutputStream
import java.util.zip.ZipEntry
import kotlin.math.abs
import kotlin.random.Random
import kotlin.math.absoluteValue
import kotlin.system.exitProcess

object ProtoLogTool {
@@ -72,7 +71,11 @@ object ProtoLogTool {
    }

    private fun processClasses(command: CommandOptions) {
        val generationHash = abs(Random.nextInt())
        // A deterministic hash based on the group jar path and the source files we are processing.
        // The hash is required to make sure different ProtoLogImpls don't conflict.
        val generationHash = (command.javaSourceArgs.toTypedArray() + command.protoLogGroupsJarArg)
                .contentHashCode().absoluteValue

        // Need to generate a new impl class to inject static constants into the class.
        val generatedProtoLogImplClass =
            "com.android.internal.protolog.ProtoLogImpl_$generationHash"