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

Commit 92a90695 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Make Ravenizer less verbose

Also allow it to take options from a dotfile for local testing.

Flag: EXEMPT host test change only
Bug: 292141694
Test: m RavenwoodBivalentTest, with and without the dotfile
Change-Id: I9f40fcc037aa9226a4d10570dd4ff24692c63fd5
parent 69243320
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ class Ravenizer(val options: RavenizerOptions) {
            }
        }

        stats.totalProcessTime = log.iTime("$executableName processing $inJar") {
        stats.totalProcessTime = log.vTime("$executableName processing $inJar") {
            ZipFile(inJar).use { inZip ->
                val inEntries = inZip.entries()

+23 −2
Original line number Diff line number Diff line
@@ -20,6 +20,20 @@ import com.android.hoststubgen.ArgumentsException
import com.android.hoststubgen.SetOnce
import com.android.hoststubgen.ensureFileExists
import com.android.hoststubgen.log
import java.nio.file.Paths
import kotlin.io.path.exists

/**
 * If this file exits, we also read options from it. This is "unsafe" because it could break
 * incremental builds, if it sets any flag that affects the output file.
 * (however, for now, there's no such options.)
 *
 * For example, to enable verbose logging, do `echo '-v' > ~/.raveniezr-unsafe`
 *
 * (but even the content of this file changes, soong won't rerun the command, so you need to
 * remove the output first and then do a build again.)
 */
private val RAVENIZER_DOTFILE = System.getenv("HOME") + "/.raveniezr-unsafe"

class RavenizerOptions(
    /** Input jar file*/
@@ -35,9 +49,16 @@ class RavenizerOptions(
    var fatalValidation: SetOnce<Boolean> = SetOnce(false),
) {
    companion object {
        fun parseArgs(args: Array<String>): RavenizerOptions {

        fun parseArgs(origArgs: Array<String>): RavenizerOptions {
            val args = origArgs.toMutableList()
            if (Paths.get(RAVENIZER_DOTFILE).exists()) {
                log.i("Reading options from $RAVENIZER_DOTFILE")
                args.add(0, "@$RAVENIZER_DOTFILE")
            }

            val ret = RavenizerOptions()
            val ai = ArgIterator.withAtFiles(args)
            val ai = ArgIterator.withAtFiles(args.toTypedArray())

            while (true) {
                val arg = ai.nextArgOptional()
+2 −2
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ class RunnerRewritingAdapter private constructor(
            av.visit("value", ravenwoodTestRunnerType.type)
            av.visitEnd()
        }
        log.i("Update the @RunWith: ${classInternalName.toHumanReadableClassName()}")
        log.v("Update the @RunWith: ${classInternalName.toHumanReadableClassName()}")
    }

    /*
@@ -442,7 +442,7 @@ class RunnerRewritingAdapter private constructor(
            // Don't process a class if it has a @NoRavenizer annotation.
            classes.findClass(className)?.let { cn ->
                if (cn.findAnyAnnotation(noRavenizerAnotType.descAsSet) != null) {
                    log.w("Class ${className.toHumanReadableClassName()} has" +
                    log.i("Class ${className.toHumanReadableClassName()} has" +
                        " @${noRavenizerAnotType.humanReadableName}. Skipping."
                    )
                    return false