rework dsl, add mod configurations (remapped), add support for other mappings #3
|
@ -12,5 +12,4 @@ object Constants {
|
||||||
const val GEN_RUN_CONFIGS_TASK = "genRunConfigs"
|
const val GEN_RUN_CONFIGS_TASK = "genRunConfigs"
|
||||||
const val RUN_CLIENT_TASK = "runClient"
|
const val RUN_CLIENT_TASK = "runClient"
|
||||||
const val RUNT_SERVER_TASK = "runServer"
|
const val RUNT_SERVER_TASK = "runServer"
|
||||||
const val DEV_NAMESPACE = "named"
|
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
package dev.frogmc.phytotelma.ext
|
package dev.frogmc.phytotelma.ext
|
||||||
|
|
||||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||||
|
import dev.frogmc.phytotelma.mappings.filterClasses
|
||||||
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
||||||
|
import dev.frogmc.phytotelma.mappings.renameNamespaces
|
||||||
import dev.frogmc.thyroxine.api.data.MappingBundle
|
import dev.frogmc.thyroxine.api.data.MappingBundle
|
||||||
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser
|
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser
|
||||||
import dev.frogmc.thyroxine.provider.MojmapProvider
|
import dev.frogmc.thyroxine.provider.MojmapProvider
|
||||||
|
@ -57,6 +59,27 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parchment(action: Action<ParchmentConfiguration>): Provider<MappingBundle> {
|
||||||
|
return project.provider {
|
||||||
|
val conf = objects.newInstance(ParchmentConfiguration::class.java)
|
||||||
|
conf.gameVersion = version
|
||||||
|
action.execute(conf)
|
||||||
|
val cacheDir = PhytotelmaPlugin.globalCacheDir
|
||||||
|
|
||||||
|
if (conf.version == null) {
|
||||||
|
conf.version = ParchmentProvider.findForMinecraftVersion(conf.gameVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
mappingsName = "parchment(${conf.gameVersion}, ${conf.version})"
|
||||||
|
targetNamespace = "parchment"
|
||||||
|
|
||||||
|
return@provider ParchmentProvider.getParchment(
|
||||||
|
version,
|
||||||
|
cacheDir.resolve("org/parchmentmc/parchment/${conf.gameVersion}/${conf.version}")
|
||||||
|
).renameNamespaces("mojmap", "parchment")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun mojmap(): Provider<MappingBundle> {
|
fun mojmap(): Provider<MappingBundle> {
|
||||||
return project.provider {
|
return project.provider {
|
||||||
val cacheDir = PhytotelmaPlugin.globalCacheDir
|
val cacheDir = PhytotelmaPlugin.globalCacheDir
|
||||||
|
@ -76,13 +99,32 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
if (conf.version == null) {
|
if (conf.version == null) {
|
||||||
error("No version provided for quilt mappings!")
|
error("No version provided for quilt mappings!")
|
||||||
}
|
}
|
||||||
mappingsName = "quilt(${conf.version})"
|
mappingsName = "quilt-mappings(${conf.version})"
|
||||||
targetNamespace = "quilt"
|
targetNamespace = "quilt-mappings"
|
||||||
// Use qm via intermediary because hashed publications are broken
|
// Use qm via intermediary because hashed publications are broken
|
||||||
return@provider twoStepMappings(
|
return@provider twoStepMappings(
|
||||||
"net.fabricmc:intermediary:$version:v2",
|
"net.fabricmc:intermediary:$version:v2",
|
||||||
"org.quiltmc:quilt-mappings:${conf.version}:intermediary-v2"
|
"org.quiltmc:quilt-mappings:${conf.version}:intermediary-v2"
|
||||||
).renameDstNamespace(targetNamespace)
|
).filterClasses { !it.startsWith("net/minecraft/unmapped") }
|
||||||
|
.flatten(true).renameDstNamespace(targetNamespace)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun yarn(action: Action<VersionConfiguration>): Provider<MappingBundle> {
|
||||||
|
return project.provider {
|
||||||
|
val conf = objects.newInstance(VersionConfiguration::class.java)
|
||||||
|
action.execute(conf)
|
||||||
|
if (conf.version == null) {
|
||||||
|
error("No version provided for yarn!")
|
||||||
|
}
|
||||||
|
mappingsName = "yarn(${conf.version})"
|
||||||
|
targetNamespace = "yarn"
|
||||||
|
// Use qm via intermediary because hashed publications are broken
|
||||||
|
return@provider twoStepMappings(
|
||||||
|
"net.fabricmc:intermediary:$version:v2",
|
||||||
|
"net.fabricmc:yarn:${conf.version}:v2"
|
||||||
|
).filterClasses { !it.startsWith("net/minecraft/class_") }
|
||||||
|
.flatten(true).renameDstNamespace(targetNamespace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +169,41 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun layer(action: Action<LayerConfiguration>): Provider<MappingBundle> {
|
||||||
|
return project.provider {
|
||||||
|
val conf = objects.newInstance(LayerConfiguration::class.java)
|
||||||
|
action.execute(conf)
|
||||||
|
|
||||||
|
var back = MappingBundle()
|
||||||
|
var name = "layer["
|
||||||
|
|
||||||
|
val layers = conf.layers.mapIndexed {index, provider ->
|
||||||
|
val bundle = provider.get().flatten(true)
|
||||||
|
if (index == 0) {
|
||||||
|
name+=mappingsName
|
||||||
|
back.insert(bundle)
|
||||||
|
return@mapIndexed bundle
|
||||||
|
}
|
||||||
|
name+=", $mappingsName"
|
||||||
|
|
||||||
|
back = back.flatten(false)
|
||||||
|
val prevDst = back.data[0].dstNamespace
|
||||||
|
val dst = bundle.data[0].dstNamespace
|
||||||
|
val remapped = MappingBundle.merge(bundle.reverse(), back)
|
||||||
|
.flatten(prevDst, dst)
|
||||||
|
.insert(back.docsForNamespace(dst))
|
||||||
|
|
||||||
|
back.insert(remapped)
|
||||||
|
return@mapIndexed remapped
|
||||||
|
}
|
||||||
|
mappingsName = "$name]"
|
||||||
|
val result = MappingBundle.merge(*layers.toTypedArray())
|
||||||
|
.flatten("official", layers.last().dstNamespaces()[0])
|
||||||
|
targetNamespace = result.data[0].dstNamespace
|
||||||
|
return@provider result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun twoStepMappings(intermediary: String, mappings: String): MappingBundle {
|
private fun twoStepMappings(intermediary: String, mappings: String): MappingBundle {
|
||||||
return MappingBundle.merge(tinyMappings(intermediary), tinyMappings(mappings))
|
return MappingBundle.merge(tinyMappings(intermediary), tinyMappings(mappings))
|
||||||
}
|
}
|
||||||
|
@ -163,7 +240,7 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class LayerConfiguration {
|
abstract class LayerConfiguration {
|
||||||
internal val layers = mutableListOf<Provider<MappingBundle>>()
|
/*internal*/ val layers = mutableListOf<Provider<MappingBundle>>()
|
||||||
fun add(mappings: Provider<MappingBundle>): LayerConfiguration {
|
fun add(mappings: Provider<MappingBundle>): LayerConfiguration {
|
||||||
layers.add(mappings)
|
layers.add(mappings)
|
||||||
return this
|
return this
|
||||||
|
|
|
@ -62,7 +62,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
||||||
println("Preparing Parchment...")
|
println("Preparing Parchment...")
|
||||||
val javadocs = ProjectStorage.get(project).mappings!!
|
val javadocs = ProjectStorage.get(project).mappings!!
|
||||||
options[IFabricJavadocProvider.PROPERTY_NAME] =
|
options[IFabricJavadocProvider.PROPERTY_NAME] =
|
||||||
FrogJavadocProvider(javadocs.docsForNamespace(Constants.DEV_NAMESPACE))
|
FrogJavadocProvider(javadocs.get(ProjectStorage.get(project).targetNamespace))
|
||||||
|
|
||||||
println("Decompiling...")
|
println("Decompiling...")
|
||||||
val logger = PrintStreamLogger(PrintStream(System.out))
|
val logger = PrintStreamLogger(PrintStream(System.out))
|
||||||
|
|
|
@ -4,10 +4,9 @@ import dev.frogmc.thyroxine.api.data.DocumentationData
|
||||||
import dev.frogmc.thyroxine.api.data.MappingBundle
|
import dev.frogmc.thyroxine.api.data.MappingBundle
|
||||||
import dev.frogmc.thyroxine.api.data.MappingData
|
import dev.frogmc.thyroxine.api.data.MappingData
|
||||||
|
|
||||||
fun MappingBundle.renameDstNamespace(newDst: String): MappingBundle {
|
fun MappingBundle.renameNamespaces(newSrc: String?, newDst: String): MappingBundle {
|
||||||
val renamed = MappingBundle()
|
val oldData = if (srcNamespaces().size > 1 || dstNamespaces().size > 1) flattenData() else data[0]
|
||||||
val oldData = flattenData()
|
val newData = MappingData(newSrc ?: oldData.srcNamespace, newDst)
|
||||||
val newData = MappingData(oldData.srcNamespace, newDst)
|
|
||||||
val newDocs = DocumentationData(newDst)
|
val newDocs = DocumentationData(newDst)
|
||||||
|
|
||||||
oldData.apply {
|
oldData.apply {
|
||||||
|
@ -17,5 +16,33 @@ fun MappingBundle.renameDstNamespace(newDst: String): MappingBundle {
|
||||||
newData.parameters.putAll(parameters)
|
newData.parameters.putAll(parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
return renamed.insert(newData, newDocs.insert(get(oldData.dstNamespace)))
|
return MappingBundle(newData, get(oldData.dstNamespace)?.let { newDocs.insert(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MappingBundle.renameDstNamespace(newDst: String): MappingBundle {
|
||||||
|
return renameNamespaces(null, newDst)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MappingBundle.filterClasses(filter: (String) -> Boolean): MappingBundle {
|
||||||
|
val oldData = data.last()
|
||||||
|
val newData = MappingData(oldData.srcNamespace, oldData.dstNamespace)
|
||||||
|
val oldDocs = if (documentation.isNotEmpty()) documentation.last() else null
|
||||||
|
|
||||||
|
oldData.apply {
|
||||||
|
newData.classes.putAll(classes.filter { filter.invoke(it.value) })
|
||||||
|
newData.fields.putAll(fields.filter { newData.classes.containsKey(it.key.owner) })
|
||||||
|
newData.methods.putAll(methods.filter { newData.classes.containsKey(it.key.owner) })
|
||||||
|
newData.parameters.putAll(parameters.filter { newData.classes.containsKey(it.key.owner) })
|
||||||
|
}
|
||||||
|
|
||||||
|
val bundle = MappingBundle(data.subList(0, data.size-1).plus(newData), mutableListOf())
|
||||||
|
|
||||||
|
if (oldDocs != null) {
|
||||||
|
val newDocs = DocumentationData(newData.dstNamespace)
|
||||||
|
newDocs.classes.addAll(oldDocs.classes.filter { filter.invoke(it.name) })
|
||||||
|
bundle.insert(newDocs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return bundle
|
||||||
}
|
}
|
Loading…
Reference in a new issue