Skip to content

Commit

Permalink
default shadeInlining to true, add missing cli args, flag serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jan 5, 2025
1 parent 365b633 commit db5a188
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
73 changes: 72 additions & 1 deletion src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Flags {
*
* @since 1.2.0
*/
public boolean shadeInlining = Boolean.getBoolean(Constants.SHADE_INLINING);
public boolean shadeInlining = Boolean.getBoolean(System.getProperty(Constants.SHADE_INLINING, "true"));
/**
* this skips applying stubs for the specified input class version, this will still apply the
* {@link xyz.wagyourtail.jvmdg.version.VersionProvider#otherTransforms(ClassNode, Set, Function, Set)}
Expand Down Expand Up @@ -405,6 +405,77 @@ private String hash(InputStream is) {
}
}

public String serialize() {
List<String> args = new ArrayList<>();
if (classVersion != Opcodes.V1_8) {
args.add("--classVersion");
args.add(String.valueOf(classVersion));
}
if (quiet) args.add("--quiet");
if (!logAnsiColors) args.add("--noColor");
if (logLevel != Logger.Level.INFO) {
args.add("--logLevel");
args.add(logLevel.name());
}
for (Map.Entry<String, WildcardType> entry : ignoreWarningsIn.entrySet()) {
args.add("--ignoreWarningsIn");
String key = entry.getKey();
switch (entry.getValue()) {
case DOUBLE:
key += "*";
case SINGLE:
key += "*";
case NONE:
}
args.add(key);
}
if (multiReleaseOriginal) {
args.add("--multiReleaseOriginal");
}
for (Integer v : multiReleaseVersions) {
args.add("--multiRelease");
args.add(String.valueOf(v));
}
if (downgradeFromMultiReleases) {
args.add("--multiReleaseInputs");
}
if (!shadeInlining) {
args.add("--noInlining");
}
for (File a : api) {
args.add("--api");
// todo: escape spaces, but, how does that work with javac plugin args?
args.add(a.getAbsolutePath());
}
if (printDebug || !debugSkipStub.isEmpty() || !debugSkipStubs.isEmpty() || debugDumpClasses) {
args.add("debug");
if (printDebug) {
args.add("--print");
}
if (!debugSkipStub.isEmpty()) {
for (FullyQualifiedMemberNameAndDesc f : debugSkipStub) {
args.add("--skipStub");
args.add(f.toString());
}
}
if (!debugSkipStubs.isEmpty()) {
for (int i : debugSkipStubs) {
args.add("--skipStubs");
args.add(String.valueOf(i));
}
}
if (debugDumpClasses) {
args.add("--dumpClasses");
}
}
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg).append(" ");
}
if (!args.isEmpty()) sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}

public enum WildcardType {
NONE,
SINGLE,
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/xyz/wagyourtail/jvmdg/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ protected Arguments buildArgumentList() {
new Arguments("--classVersion", "Target class version (ex. \"52\" for java 8)", new String[]{"-c"}, new String[]{"version"}),
new Arguments("--multiReleaseOriginal", "Use the original class file for a Multi-Release jar", new String[]{"-mro"}, null),
new Arguments("--multiRelease", "Use semi-downgraded files for a Multi-Release jar, versions as class version (ex. \"55\" for java 11)", new String[]{"-mr"}, new String[]{"version"}),
new Arguments("--noColor", "Disables ansi colors", new String[]{"-nc"}, null),
new Arguments("--multiReleaseInputs", "Use the Multi-Release files as inputs for downgrading when available, instead of the normal ones", new String[]{"-mri"}, null),
new Arguments("debug", "Set debug flags/call debug actions", null, null).addChildren(
new Arguments("--print", "[Deprecated] Enable printing debug info", new String[]{"-p"}, null),
new Arguments("--skipStub", "Skip a specific class/method, of form \"Lcom/example/ClassName;\" or \"Lcom/example/ClassName;methodName;()V\"", new String[] {"-ss"}, new String[] {"stub"}),
new Arguments("--skipStubs", "Skip method/class stubs for these class versions", new String[]{"-s"}, new String[]{"versions"}),
new Arguments("--dumpClasses", "Dump classes to the debug folder", new String[]{"-d"}, null),
new Arguments("downgradeApi", "Retrieves and downgrades the java api jar", null, new String[]{"outputPath"})
),
new Arguments("--noInlining", "Disable shade inlining when a method is only used in one class", new String[]{"-ni"}, null),
new Arguments("downgrade", "Downgrades a jar or folder", null, null).addChildren(
input,
classpath
Expand Down Expand Up @@ -158,6 +161,16 @@ public void parseArgs(String[] args) throws IOException, ClassNotFoundException,
}
}
flags.multiReleaseVersions = versions;
break;
case "--noColor":
flags.logAnsiColors = false;
break;
case "--multiReleaseInputs":
flags.downgradeFromMultiReleases = true;
break;
case "--noInlining":
flags.shadeInlining = false;
break;
default:
}
}
Expand Down

0 comments on commit db5a188

Please sign in to comment.