mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-25 06:24:35 +00:00
Minor tweaks to AP internals
This commit is contained in:
1 parent
5ea23f8bb0
commit
a15897221b
8 files changed
+37
-16
No files matched your search
@@ -498,10 +498,6 @@ abstract class AnnotatedMixinElementHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void printMessage(Kind kind, String msg, Element e, AnnotationHandle annotation) {
|
||||
this.printMessage(kind, msg, e, annotation, null);
|
||||
}
|
||||
|
||||
private void printMessage(Kind kind, String msg, Element e, AnnotationHandle annotation, String suppressedBy) {
|
||||
if (annotation == null) {
|
||||
this.ap.printMessage(kind, msg, e, suppressedBy);
|
||||
|
||||
@@ -246,6 +246,12 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
return this.getProperties().getProperty(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOption(String option, String defaultValue) {
|
||||
String value = this.getOption(option);
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOption(String option, boolean defaultValue) {
|
||||
String value = this.getOption(option);
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.Map;
|
||||
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IOptionProvider;
|
||||
import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
|
||||
import org.spongepowered.tools.obfuscation.service.ObfuscationTypeDescriptor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -43,6 +42,8 @@ import com.google.common.collect.ImmutableList.Builder;
|
||||
*/
|
||||
public final class ObfuscationType {
|
||||
|
||||
public static final String DEFAULT_TYPE = "searge";
|
||||
|
||||
/**
|
||||
* Available obfuscation types indexed by key
|
||||
*/
|
||||
@@ -111,9 +112,8 @@ public final class ObfuscationType {
|
||||
* Get whether this is ithe default obfuscation environment
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
String defaultEnv = this.options.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV);
|
||||
return (defaultEnv == null && this.key.equals(ObfuscationServiceMCP.SEARGE))
|
||||
|| (defaultEnv != null && this.key.equals(defaultEnv.toLowerCase(Locale.ROOT)));
|
||||
String defaultEnv = this.options.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV, ObfuscationType.DEFAULT_TYPE).toLowerCase(Locale.ROOT);
|
||||
return (this.key.equals(defaultEnv));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,6 @@ public class ObfuscationServiceFG3 implements IObfuscationService {
|
||||
|
||||
public static final String REOBF_TSRG_FILE = "reobfTsrgFile";
|
||||
public static final String OUT_TSRG_SRG_FILE = "outTsrgFile";
|
||||
public static final String OUT_REFMAP_FILE = "outRefMapFile";
|
||||
public static final String TSRG_OUTPUT_BEHAVIOUR = "mergeBehaviour";
|
||||
|
||||
@Override
|
||||
@@ -53,7 +52,6 @@ public class ObfuscationServiceFG3 implements IObfuscationService {
|
||||
return ImmutableSet.<String>of(
|
||||
ObfuscationServiceFG3.REOBF_TSRG_FILE,
|
||||
ObfuscationServiceFG3.OUT_TSRG_SRG_FILE,
|
||||
ObfuscationServiceFG3.OUT_REFMAP_FILE,
|
||||
ObfuscationServiceFG3.TSRG_OUTPUT_BEHAVIOUR
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,16 @@ public interface IOptionProvider {
|
||||
*/
|
||||
public abstract String getOption(String option);
|
||||
|
||||
/**
|
||||
* Fetch the value of the specified option, if available. If the option is
|
||||
* not available, return the specified default value
|
||||
*
|
||||
* @param option Name of the option to fetch
|
||||
* @param defaultValue Default value to return if the option is not present
|
||||
* @return Option value or default if absent
|
||||
*/
|
||||
public abstract String getOption(String option, String defaultValue);
|
||||
|
||||
/**
|
||||
* Fetch the value of the specified option, if available. If the option is
|
||||
* not available, return the specified default value
|
||||
|
||||
@@ -50,7 +50,6 @@ public class ObfuscationServiceMCP implements IObfuscationService {
|
||||
public static final String REOBF_EXTRA_NOTCH_FILES = "reobfNotchSrgFiles";
|
||||
public static final String OUT_SRG_SRG_FILE = "outSrgFile";
|
||||
public static final String OUT_NOTCH_SRG_FILE = "outNotchSrgFile";
|
||||
public static final String OUT_REFMAP_FILE = "outRefMapFile";
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedOptions() {
|
||||
@@ -60,8 +59,7 @@ public class ObfuscationServiceMCP implements IObfuscationService {
|
||||
ObfuscationServiceMCP.REOBF_NOTCH_FILE,
|
||||
ObfuscationServiceMCP.REOBF_EXTRA_NOTCH_FILES,
|
||||
ObfuscationServiceMCP.OUT_SRG_SRG_FILE,
|
||||
ObfuscationServiceMCP.OUT_NOTCH_SRG_FILE,
|
||||
ObfuscationServiceMCP.OUT_REFMAP_FILE
|
||||
ObfuscationServiceMCP.OUT_NOTCH_SRG_FILE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package org.spongepowered.tools.obfuscation.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
@@ -33,6 +34,7 @@ import java.util.Set;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import org.spongepowered.tools.obfuscation.ObfuscationType;
|
||||
import org.spongepowered.tools.obfuscation.SupportedOptions;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
|
||||
|
||||
/**
|
||||
@@ -78,6 +80,8 @@ public final class ObfuscationServices {
|
||||
* @param ap annotation processor
|
||||
*/
|
||||
public void initProviders(IMixinAnnotationProcessor ap) {
|
||||
boolean defaultIsPresent = false;
|
||||
|
||||
try {
|
||||
for (IObfuscationService service : this.serviceLoader) {
|
||||
if (!this.services.contains(service)) {
|
||||
@@ -91,6 +95,7 @@ public final class ObfuscationServices {
|
||||
try {
|
||||
ObfuscationType type = ObfuscationType.create(obfType, ap);
|
||||
ap.printMessage(Kind.NOTE, serviceName + " supports type: \"" + type + "\"");
|
||||
defaultIsPresent |= type.isDefault();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -102,6 +107,17 @@ public final class ObfuscationServices {
|
||||
ap.printMessage(Kind.ERROR, serviceError.getClass().getSimpleName() + ": " + serviceError.getMessage());
|
||||
serviceError.printStackTrace();
|
||||
}
|
||||
|
||||
if (!defaultIsPresent) {
|
||||
String defaultEnv = ap.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV);
|
||||
if (defaultEnv == null) {
|
||||
ap.printMessage(Kind.WARNING, "No default obfuscation environment was specified and \"" + ObfuscationType.DEFAULT_TYPE
|
||||
+ "\" is not available. Please ensure defaultObfuscationEnv is specified in your build configuration");
|
||||
} else {
|
||||
ap.printMessage(Kind.WARNING, "Specified default obfuscation environment \"" + defaultEnv.toLowerCase(Locale.ROOT)
|
||||
+ "\" was not defined. This probably means your build configuration is out of date or a required service is missing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user