Skip to content

Commit

Permalink
[hugo2] enable class level debug log output
Browse files Browse the repository at this point in the history
  • Loading branch information
s1rius committed Jun 10, 2021
1 parent a6b9057 commit e76a578
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
}

apply from: "$rootDir/app/plugin-bytex.gradle"
apply from: "$rootDir/app/plugin-stick.gradle"
apply from: "$rootDir/app/plugin-hugo2.gradle"
apply from: "$rootDir/app/plugin-willfix.gradle"
//apply from: "$rootDir/app/plugin-stick.gradle"
//apply from: "$rootDir/app/plugin-willfix-standalone.gradle"
2 changes: 2 additions & 0 deletions app/src/main/java/wtf/s1/pudge/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package wtf.s1.pudge
import android.app.Application
import android.content.Context
import android.util.Log
import wtf.s1.pudge.hugo2.DebugLog
import wtf.s1.pudge.hugo2.Hugo2
import wtf.s1.stick.core.ITracer
import wtf.s1.stick.core.MethodTrace

@DebugLog
class App: Application() {

override fun attachBaseContext(base: Context?) {
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/wtf/s1/buildsrc/Configs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package wtf.s1.buildsrc

object Versions{
const val pudge = "0.1.1"
const val pudgeDev = "0.1.2"
const val pudgeDev = "0.1.3"
const val asm = "8.0.1"
const val kotlin = "1.5.0"
const val ktx = "1.0.0"
Expand Down Expand Up @@ -68,8 +68,8 @@ object Deps{
}

object Hugo2 {
const val core = "wtf.s1.pudge:hugo2-core:${Versions.pudge}"
const val byteX = "wtf.s1.pudge:hugo2-bytex:${Versions.pudge}"
const val core = "wtf.s1.pudge:hugo2-core:${Versions.pudgeDev}"
const val byteX = "wtf.s1.pudge:hugo2-bytex:${Versions.pudgeDev}"
}

const val firebasePref = "com.google.firebase:firebase-perf:19.0.9"
Expand Down
3 changes: 1 addition & 2 deletions hugo2-bytex/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=hugo2-bytex
POM_DESCRIPTION=hugo bytex plugin
POM_ARTIFACT_ID=hugo2-bytex
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package wtf.s1.pudge.hugo2

import com.ss.android.ugc.bytex.common.visitor.BaseClassVisitor
import org.objectweb.asm.AnnotationVisitor
import org.objectweb.asm.MethodVisitor

class Hugo2ClassVisitor(private val context: Hugo2ByteXContext) : BaseClassVisitor() {

private var clazz: String? = null
private var clazzAnnotated = false

override fun visit(
version: Int,
Expand All @@ -19,6 +21,12 @@ class Hugo2ClassVisitor(private val context: Hugo2ByteXContext) : BaseClassVisit
super.visit(version, access, name, signature, superName, interfaces)
}

override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor {
if (Hugo2.DEBUGLOGDESC == descriptor) {
clazzAnnotated = true
}
return super.visitAnnotation(descriptor, visible)
}

override fun visitMethod(
access: Int,
Expand All @@ -28,6 +36,6 @@ class Hugo2ClassVisitor(private val context: Hugo2ByteXContext) : BaseClassVisit
exceptions: Array<out String>?
): MethodVisitor {
val visitor = super.visitMethod(access, name, descriptor, signature, exceptions)
return Hugo2MethodVisitor(visitor, context, clazz, api, access, name, descriptor, signature, exceptions)
return Hugo2MethodVisitor(visitor, context, clazz, clazzAnnotated, api, access, name, descriptor, signature, exceptions)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Hugo2MethodVisitor(
private val methodVisitor: MethodVisitor,
private val context: Hugo2ByteXContext,
private val clazz: String?,
private val clazzAnnotated: Boolean = false,
api: Int,
access: Int,
name: String?,
Expand All @@ -18,7 +19,7 @@ class Hugo2MethodVisitor(
exceptions: Array<out String>?
) : MethodNode(api, access, name, descriptor, signature, exceptions) {

private var hasStickAnn: Boolean = false
private var methodAnnotated: Boolean = false
private var firstLabel: Label? = null
private val paramList = arrayListOf<TraceMethodParam>()

Expand Down Expand Up @@ -52,11 +53,11 @@ class Hugo2MethodVisitor(
private fun methodTransform() {
visibleAnnotations?.forEach {
if (Hugo2.DEBUGLOGDESC == it.desc) {
hasStickAnn = true
methodAnnotated = true
}
}

if (!hasStickAnn) {
if (!methodAnnotated && !clazzAnnotated) {
return
}

Expand Down
3 changes: 1 addition & 2 deletions hugo2-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=hugo2-core
POM_DESCRIPTION=hugo2-core
POM_ARTIFACT_ID=hugo2-core
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
2 changes: 2 additions & 0 deletions hugo2-core/src/main/java/wtf/s1/pudge/hugo2/DebugLog.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package wtf.s1.pudge.hugo2

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class DebugLog
6 changes: 0 additions & 6 deletions pluginDebugWithInstall.sh

This file was deleted.

7 changes: 4 additions & 3 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./gradlew :willfix-core:publish
./gradlew :willfix-standalone:publish
./gradlew :willfix-bytex:publish
#!/bin/sh
echo "publish module $1"
publish="./gradlew :$1:publish"
$publish
3 changes: 1 addition & 2 deletions stick-android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=stick-android
POM_DESCRIPTION=stick android
POM_ARTIFACT_ID=stick-android
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
3 changes: 1 addition & 2 deletions stick-bytex/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=stick
POM_DESCRIPTION=stick
POM_ARTIFACT_ID=stick-bytex
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
3 changes: 1 addition & 2 deletions stick-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=StickCore
POM_DESCRIPTION=stick core lib
POM_ARTIFACT_ID=stick-core
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
3 changes: 1 addition & 2 deletions willfix-bytex/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=WillFixByteX
POM_DESCRIPTION=will fix bytex
POM_ARTIFACT_ID=will-fix-bytex
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
3 changes: 1 addition & 2 deletions willfix-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=WillFixCore
POM_DESCRIPTION=willfix plugin core logic
POM_ARTIFACT_ID=will-fix-core
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar
3 changes: 1 addition & 2 deletions willfix-standalone/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
POM_NAME=WillFix
POM_DESCRIPTION=will fix something thing
POM_ARTIFACT_ID=will-fix-plugin
POM_PACKAGING=aar
VERSION_NAME=0.1.1
POM_PACKAGING=aar

0 comments on commit e76a578

Please sign in to comment.