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

Commit d0473319 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Set static timestamps in protologtool output

When build outputs are deterministic, that helps improve the RBE cache
hit rate.

Bug: 325124724
Test: m out/soong/.intermediates/frameworks/base/libs/WindowManager/Shell/wm_shell_protolog_src/6c826b466f2421b82c3ec7d86f8481e7/gen/wm_shell_protolog.srcjar; zipinfo $!
Change-Id: I838eb379531ae5434d576828e6be43663122187b
parent 92b9ed7e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.OutputStream
import java.time.LocalDateTime
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.jar.JarOutputStream
@@ -42,6 +43,13 @@ object ProtoLogTool {
        return source.contains(protoLogSimpleClassName)
    }

    private fun zipEntry(path: String): ZipEntry {
        val entry = ZipEntry(path)
        // Use a constant time to improve the cachability of build actions.
        entry.timeLocal = LocalDateTime.of(2008, 1, 1, 0, 0, 0)
        return entry
    }

    private fun processClasses(command: CommandOptions) {
        val groups = injector.readLogGroups(
                command.protoLogGroupsJarArg,
@@ -77,7 +85,7 @@ object ProtoLogTool {
                }
            }.map { future ->
                val (path, outSrc) = future.get()
                outJar.putNextEntry(ZipEntry(path))
                outJar.putNextEntry(zipEntry(path))
                outJar.write(outSrc.toByteArray())
                outJar.closeEntry()
            }
@@ -90,7 +98,7 @@ object ProtoLogTool {
        val cachePackage = cacheSplit.dropLast(1).joinToString(".")
        val cachePath = "gen/${cacheSplit.joinToString("/")}.java"

        outJar.putNextEntry(ZipEntry(cachePath))
        outJar.putNextEntry(zipEntry(cachePath))
        outJar.write(generateLogGroupCache(cachePackage, cacheName, groups,
                command.protoLogImplClassNameArg, command.protoLogGroupsClassNameArg).toByteArray())