Drop DebugJsAstProtoBuf
This commit is contained in:
-53723
File diff suppressed because it is too large
Load Diff
@@ -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,13 +142,15 @@ private fun renamePackages(protoPath: String, outPath: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun modifyAndExecProtoc(protoPath: ProtoPath) {
|
private fun modifyAndExecProtoc(protoPath: ProtoPath) {
|
||||||
val debugProtoFile = File(protoPath.file.replace(".proto", ".debug.proto"))
|
if (protoPath.generateDebug) {
|
||||||
debugProtoFile.writeText(modifyForDebug(protoPath))
|
val debugProtoFile = File(protoPath.file.replace(".proto", ".debug.proto"))
|
||||||
debugProtoFile.deleteOnExit()
|
debugProtoFile.writeText(modifyForDebug(protoPath))
|
||||||
|
debugProtoFile.deleteOnExit()
|
||||||
|
|
||||||
val outPath = "build-common/test"
|
val outPath = "build-common/test"
|
||||||
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 {
|
||||||
|
|||||||
+12
-10
@@ -30,16 +30,18 @@ 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) {
|
||||||
val classFqName = protoPath.packageName + "." + protoPath.debugClassName
|
if (protoPath.generateDebug) {
|
||||||
val klass = this::class.java.classLoader.loadClass(classFqName) ?: error("Class not found: $classFqName")
|
val classFqName = protoPath.packageName + "." + protoPath.debugClassName
|
||||||
for (field in klass.declaredFields) {
|
val klass = this::class.java.classLoader.loadClass(classFqName) ?: error("Class not found: $classFqName")
|
||||||
if (Modifier.isStatic(field.modifiers) && field.type == GeneratedExtension::class.java) {
|
for (field in klass.declaredFields) {
|
||||||
// The only place where type information for an extension is stored is the field's declared generic type.
|
if (Modifier.isStatic(field.modifiers) && field.type == GeneratedExtension::class.java) {
|
||||||
// The message type which this extension extends is the first argument to GeneratedExtension<*, *>
|
// The only place where type information for an extension is stored is the field's declared generic type.
|
||||||
val containingType = (field.genericType as ParameterizedType).actualTypeArguments.first() as Class<*>
|
// The message type which this extension extends is the first argument to GeneratedExtension<*, *>
|
||||||
val value = field.get(null) as GeneratedExtension<*, *>
|
val containingType = (field.genericType as ParameterizedType).actualTypeArguments.first() as Class<*>
|
||||||
val desc = value.descriptor
|
val value = field.get(null) as GeneratedExtension<*, *>
|
||||||
extensions.put(Key(containingType, desc.number), desc)
|
val desc = value.descriptor
|
||||||
|
extensions.put(Key(containingType, desc.number), desc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user