Drop DebugJsAstProtoBuf

This commit is contained in:
Roman Artemev
2019-02-25 19:26:22 +03:00
committed by romanart
parent cae800b24e
commit 52baf90518
3 changed files with 22 additions and 53741 deletions
@@ -34,7 +34,7 @@ import java.util.regex.Pattern
// You may need to provide custom path to protoc executable, just modify this constant: // You may need to provide custom path to protoc executable, just modify this constant:
private const val PROTOC_EXE = "protoc" private const val PROTOC_EXE = "protoc"
class ProtoPath(val file: String) { class ProtoPath(val file: String, val generateDebug: Boolean = true) {
val outPath: String = File(file).parent val outPath: String = File(file).parent
val packageName: String = findFirst(Pattern.compile("package (.+);")) val packageName: String = findFirst(Pattern.compile("package (.+);"))
val className: String = findFirst(Pattern.compile("option java_outer_classname = \"(.+)\";")) val className: String = findFirst(Pattern.compile("option java_outer_classname = \"(.+)\";"))
@@ -53,7 +53,7 @@ val PROTO_PATHS: List<ProtoPath> = listOf(
ProtoPath("core/metadata/src/metadata.proto"), ProtoPath("core/metadata/src/metadata.proto"),
ProtoPath("core/metadata/src/builtins.proto"), ProtoPath("core/metadata/src/builtins.proto"),
ProtoPath("js/js.serializer/src/js.proto"), ProtoPath("js/js.serializer/src/js.proto"),
ProtoPath("js/js.serializer/src/js-ast.proto"), ProtoPath("js/js.serializer/src/js-ast.proto", false),
ProtoPath("konan/library-reader/src/konan.proto"), ProtoPath("konan/library-reader/src/konan.proto"),
ProtoPath("core/metadata.jvm/src/jvm_metadata.proto"), ProtoPath("core/metadata.jvm/src/jvm_metadata.proto"),
ProtoPath("core/metadata.jvm/src/jvm_module.proto"), ProtoPath("core/metadata.jvm/src/jvm_module.proto"),
@@ -142,6 +142,7 @@ private fun renamePackages(protoPath: String, outPath: String) {
} }
private fun modifyAndExecProtoc(protoPath: ProtoPath) { private fun modifyAndExecProtoc(protoPath: ProtoPath) {
if (protoPath.generateDebug) {
val debugProtoFile = File(protoPath.file.replace(".proto", ".debug.proto")) val debugProtoFile = File(protoPath.file.replace(".proto", ".debug.proto"))
debugProtoFile.writeText(modifyForDebug(protoPath)) debugProtoFile.writeText(modifyForDebug(protoPath))
debugProtoFile.deleteOnExit() debugProtoFile.deleteOnExit()
@@ -150,6 +151,7 @@ private fun modifyAndExecProtoc(protoPath: ProtoPath) {
execProtoc(debugProtoFile.path, outPath) execProtoc(debugProtoFile.path, outPath)
renamePackages(debugProtoFile.path, outPath) renamePackages(debugProtoFile.path, outPath)
} }
}
private fun modifyForDebug(protoPath: ProtoPath): String { private fun modifyForDebug(protoPath: ProtoPath): String {
var text = File(protoPath.file).readText() var text = File(protoPath.file).readText()
@@ -30,6 +30,7 @@ class ProtoBufConsistencyTest : TestCase() {
val extensions = LinkedHashMultimap.create<Key, Descriptors.FieldDescriptor>() val extensions = LinkedHashMultimap.create<Key, Descriptors.FieldDescriptor>()
for (protoPath in PROTO_PATHS) { for (protoPath in PROTO_PATHS) {
if (protoPath.generateDebug) {
val classFqName = protoPath.packageName + "." + protoPath.debugClassName val classFqName = protoPath.packageName + "." + protoPath.debugClassName
val klass = this::class.java.classLoader.loadClass(classFqName) ?: error("Class not found: $classFqName") val klass = this::class.java.classLoader.loadClass(classFqName) ?: error("Class not found: $classFqName")
for (field in klass.declaredFields) { for (field in klass.declaredFields) {
@@ -43,6 +44,7 @@ class ProtoBufConsistencyTest : TestCase() {
} }
} }
} }
}
for ((key, descriptors) in extensions.asMap().entries) { for ((key, descriptors) in extensions.asMap().entries) {
if (descriptors.size > 1) { if (descriptors.size > 1) {