Add --numeric-srg option for using srg names (vs csv) on MCP dirs
Normally, --srg-in on a directory will load joined.srg or client.srg and server.srg, translated through fields.csv, methods.csv, and packages.csv, if available. --numeric will ignore fields.csv and methods.csv, remapping the jar to the numeric "srg" names instead of descriptive "csv" names. (packages.csv will still be used if it exists; if you want flat packaging then specify joined.srg to --srg-in directly.)
This commit is contained in:
parent
e36a60a078
commit
308d1b4413
@ -50,10 +50,15 @@ public class CSVMappingTransformer extends JarMappingLoadTransformer {
|
||||
fieldMap = new HashMap<String, String>();
|
||||
methodMap = new HashMap<String, String>();
|
||||
|
||||
readIntoMap(fieldsCsv, fieldMap);
|
||||
readIntoMap(methodsCsv, methodMap);
|
||||
if (fieldsCsv != null && fieldsCsv.exists()) {
|
||||
readIntoMap(fieldsCsv, fieldMap);
|
||||
}
|
||||
|
||||
if (packagesCsv.exists()) {
|
||||
if (methodsCsv != null && methodsCsv.exists()) {
|
||||
readIntoMap(methodsCsv, methodMap);
|
||||
}
|
||||
|
||||
if (packagesCsv != null && packagesCsv.exists()) {
|
||||
// repackaged (FML)
|
||||
classPackageMap = new HashMap<String, String>();
|
||||
|
||||
@ -94,12 +99,12 @@ public class CSVMappingTransformer extends JarMappingLoadTransformer {
|
||||
|
||||
@Override
|
||||
public String transformFieldName(String fieldName) {
|
||||
return fieldMap.get(fieldName);
|
||||
return fieldMap.containsKey(fieldName) ? fieldMap.get(fieldName) : fieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transformMethodName(String methodName) {
|
||||
return methodMap.get(methodName);
|
||||
return methodMap.containsKey(methodName) ? methodMap.get(methodName) : methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +90,7 @@ public class JarMapping {
|
||||
/**
|
||||
* Load mappings from an MCP directory
|
||||
*/
|
||||
public void loadMappingsDir(String dirname, boolean reverse) throws IOException {
|
||||
public void loadMappingsDir(String dirname, boolean reverse, boolean numeric) throws IOException {
|
||||
File dir = new File(dirname);
|
||||
if (!URLDownloader.isHTTPURL(dirname) && !dir.isDirectory()) {
|
||||
throw new IllegalArgumentException("loadMappingsDir("+dir+"): not a directory");
|
||||
@ -120,7 +120,7 @@ public class JarMapping {
|
||||
throw new IOException("loadMappingsDir("+dirname+"): no joined.srg, client.srg, or client.srg found");
|
||||
}
|
||||
|
||||
// Read output names through csv mappings, if available
|
||||
// Read output names through csv mappings, if available & enabled
|
||||
File fieldsCsv = URLDownloader.getLocalFile(dirname + sep + "fields.csv");
|
||||
File methodsCsv = URLDownloader.getLocalFile(dirname + sep + "methods.csv");
|
||||
File packagesCsv = URLDownloader.getLocalFile(dirname + sep + "packages.csv"); // FML repackaging, optional
|
||||
@ -128,10 +128,8 @@ public class JarMapping {
|
||||
CSVMappingTransformer outputTransformer;
|
||||
|
||||
if (fieldsCsv.exists() && methodsCsv.exists()) {
|
||||
// they want descriptive "csv" names
|
||||
outputTransformer = new CSVMappingTransformer(fieldsCsv, methodsCsv, packagesCsv);
|
||||
outputTransformer = new CSVMappingTransformer(numeric ? null : fieldsCsv, numeric ? null : methodsCsv, packagesCsv);
|
||||
} else {
|
||||
// they want numeric "srg" names, for some reason (TODO: option to override)
|
||||
outputTransformer = null;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,8 @@ public class SpecialSource {
|
||||
.withRequiredArg()
|
||||
.ofType(String.class);
|
||||
|
||||
acceptsAll(asList("n", "numeric-srg"), "Use numeric .srg mappings (not .csv) with srg-in dir");
|
||||
|
||||
acceptsAll(asList("R", "in-shade-relocation", "shade-relocation"), "Simulate maven-shade-plugin relocation patterns on srg-in input names")
|
||||
.withRequiredArg()
|
||||
.withValuesSeparatedBy(',');
|
||||
@ -164,7 +166,7 @@ public class SpecialSource {
|
||||
List<String> filenames = (List<String>) options.valuesOf("srg-in");
|
||||
for (String filename : filenames) {
|
||||
if (new File(filename).isDirectory() || filename.endsWith("/")) { // existing local dir or dir URL
|
||||
jarMapping.loadMappingsDir(filename, reverse);
|
||||
jarMapping.loadMappingsDir(filename, reverse, options.has("numeric-srg"));
|
||||
} else {
|
||||
jarMapping.loadMappings(new BufferedReader(new FileReader(URLDownloader.getLocalFile(filename))), inputTransformer, outputTransformer, reverse);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user