diff --git a/CHANGELOG.md b/CHANGELOG.md index ea824313..0d8aba0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,12 +36,20 @@ Running changelog document, will be added to as I commit things. * The plugin will *not* retrieve ATs transitively from mod dependencies. * Forge has them configurable through Java in the coremod, so it's impossible in the general case. * Just paste them into the project. (Because I don't try to auto generate a coremod, you don't have to worry about them showing up in the built jar) -* Binpatches +* Binpatches. * 1.6.4 stopped being a jarmod, instead distributing patches inside a `binpatches.pack.lzma` file. * Now, if this file exists, Voldeloom is able to parse the file and apply the binary patches. + * You can't quite launch 1.6 yet, but it's a start. ## Other changes +* Rewrote how `genSources` interacts with Fernflower. + * It does not attempt to interact with the Gradle `ProgressLogger` system anymore, because it didn't appear to be working. This also removed a *lot* of logging being swallowed by the progress logger. + * Another optimization (rather brazenly using NIO for reading classes from the jar) improved the runtime a fair bit on my computer. This is a tinge unsafe, so `-Pvoldeloom.saferFernflower` will toggle back to the old `ZipFile`/`ZipEntry` system. +* Reduced retained size of in-memory MCP mappings by about 50%. + * You can also reduce the retained size of the in-memory Tiny mappings tree with `-Pvoldeloom.lowMemory`, but it's a bit slow and unsafe, whcih is why it's behind a flag. Might be useful if you're very memory constrained and want to squeeze out every drop. +* Redid the whole "dependency provider" system to be less garbage. + * Names of providers have changed. The general shape of log output also changed, a bit less spammy, but I will still spam you with file paths. * The project-wide `offline` and `refreshDependencies` flags were moved from `Constants` into the extension: * Set the `voldeloom.offline` system property, project property, pass `--offline` to Gradle, or configure `offline` in the extension to configure offline mode * Set the `voldeloom.refreshDependencies` system property, project property, pass `--refresh-dependencies` to Gradle, or configure `refreshDependencies` in the extension to configure refreshDependencies mode diff --git a/src/main/java/net/fabricmc/loom/newprovider/Binpatcher.java b/src/main/java/net/fabricmc/loom/newprovider/Binpatcher.java index 2cfe2d82..55212af3 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/Binpatcher.java +++ b/src/main/java/net/fabricmc/loom/newprovider/Binpatcher.java @@ -59,7 +59,7 @@ public Binpatcher patch() throws Exception { cleanOnRefreshDependencies(output); log.info("] binpatch input: {}", input); - log.info("] binpatch output: {}", output); + log.lifecycle("] binpatch output: {}", output); log.info("] number of binpatches: {}", binpatches.size()); if(Files.notExists(output)) { diff --git a/src/main/java/net/fabricmc/loom/newprovider/ForgeDependencyFetcher.java b/src/main/java/net/fabricmc/loom/newprovider/ForgeDependencyFetcher.java index ead27a70..341e7f0e 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/ForgeDependencyFetcher.java +++ b/src/main/java/net/fabricmc/loom/newprovider/ForgeDependencyFetcher.java @@ -58,13 +58,10 @@ public ForgeDependencyFetcher sniff() throws Exception { Preconditions.checkNotNull(forgeJar, "forge jar"); class LibrarySniffingClassVisitor extends ClassVisitor { - public LibrarySniffingClassVisitor(ClassVisitor classVisitor, Collection sniffedLibraries) { - super(Opcodes.ASM4, classVisitor); - this.sniffedLibraries = sniffedLibraries; + public LibrarySniffingClassVisitor() { + super(Opcodes.ASM4, null); } - private final Collection sniffedLibraries; - @Override public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { //static initializer @@ -93,13 +90,15 @@ public void visitLdcInsn(Object value) { if(Files.exists(coreFmlLibsPath)) { log.info("|-> Parsing cpw.mods.fml.relauncher.CoreFMLLibraries..."); try(InputStream in = Files.newInputStream(coreFmlLibsPath)) { - new ClassReader(in).accept(new LibrarySniffingClassVisitor(null, sniffedLibraries), ClassReader.SKIP_FRAMES); //just don't need frames + new ClassReader(in).accept(new LibrarySniffingClassVisitor(), ClassReader.SKIP_FRAMES); //just don't need frames } } else { log.info("|-> No cpw.mods.fml.relauncher.CoreFMLLibraries class in this jar."); } } + log.info("] found {} libraries", sniffedLibraries.size()); + return this; } diff --git a/src/main/java/net/fabricmc/loom/newprovider/Jarmodder.java b/src/main/java/net/fabricmc/loom/newprovider/Jarmodder.java index 3f12a6d9..45bc1013 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/Jarmodder.java +++ b/src/main/java/net/fabricmc/loom/newprovider/Jarmodder.java @@ -57,6 +57,9 @@ public Jarmodder patch() throws Exception { Preconditions.checkNotNull(overlay, "jarmod overlay"); cleanOnRefreshDependencies(jarmodded); + + log.lifecycle("] jarmodded: {}", jarmodded); + if(Files.notExists(jarmodded)) { log.lifecycle("|-> Jarmodded jar does not exist, performing jarmod..."); Files.createDirectories(jarmodded.getParent()); diff --git a/src/main/java/net/fabricmc/loom/newprovider/MappingsWrapper.java b/src/main/java/net/fabricmc/loom/newprovider/MappingsWrapper.java index 812cc8b1..c6f7f34e 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/MappingsWrapper.java +++ b/src/main/java/net/fabricmc/loom/newprovider/MappingsWrapper.java @@ -31,8 +31,8 @@ public MappingsWrapper(Project project, LoomGradleExtension extension, Configura if(extension.forgeCapabilities.useSrgsAsFallback()) mappingDiscriminant += "-srgfallback"; mappingsDepString = getDepString() + mappingDiscriminant; - log.info("] mappings dep: {}", mappingsDepString); - log.info("] mappings source: {}", getPath()); + log.lifecycle("] mappings dep: {}", mappingsDepString); + log.lifecycle("] mappings source: {}", getPath()); try(FileSystem mcpZipFs = FileSystems.newFileSystem(URI.create("jar:" + getPath().toUri()), Collections.emptyMap())) { //TODO: Remove this crap when i do the good mappings system diff --git a/src/main/java/net/fabricmc/loom/newprovider/Merger.java b/src/main/java/net/fabricmc/loom/newprovider/Merger.java index cbe8cc53..27d68626 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/Merger.java +++ b/src/main/java/net/fabricmc/loom/newprovider/Merger.java @@ -68,7 +68,7 @@ public Merger merge() throws Exception { log.info("] merge client: {}", clientJar); log.info("] merge server: {}", serverJar); - log.info("] merge target: {}", merged); + log.lifecycle("] merge target: {}", merged); if(Files.notExists(merged)) { Files.createDirectories(merged.getParent()); diff --git a/src/main/java/net/fabricmc/loom/newprovider/Remapper.java b/src/main/java/net/fabricmc/loom/newprovider/Remapper.java index 1897c783..2e9c8809 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/Remapper.java +++ b/src/main/java/net/fabricmc/loom/newprovider/Remapper.java @@ -94,8 +94,10 @@ public Remapper remap() throws Exception { Preconditions.checkNotNull(inputJar, "input jar"); Preconditions.checkNotNull(nonNativeLibs, "nonNativeLibs"); // ? - cleanOnRefreshDependencies(intermediaryJar, mappedJar); + log.lifecycle("] intermediary jar: {}", intermediaryJar); + log.lifecycle("] mapped jar: {}", mappedJar); + cleanOnRefreshDependencies(intermediaryJar, mappedJar); if (Files.notExists(intermediaryJar) || Files.notExists(mappedJar)) { log.lifecycle("|-> At least one mapped jar didn't exist, performing remap..."); diff --git a/src/main/java/net/fabricmc/loom/newprovider/Tinifier.java b/src/main/java/net/fabricmc/loom/newprovider/Tinifier.java index cae1d460..74dc4624 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/Tinifier.java +++ b/src/main/java/net/fabricmc/loom/newprovider/Tinifier.java @@ -77,10 +77,9 @@ public Tinifier tinify() throws Exception { Preconditions.checkNotNull(mappings, "mappings"); mappingsFile = getCacheDir().resolve("mappings").resolve(mappings.getPath().getFileName() + mappings.getMappingDiscriminant() + ".tiny"); - log.info("] mappings destination: {}", mappingsFile); + log.lifecycle("] mappings destination: {}", mappingsFile); cleanOnRefreshDependencies(mappingsFile); - if(Files.notExists(mappingsFile)) { log.info("|-> Mappings file does not exist, writing..."); Files.createDirectories(mappingsFile.getParent()); diff --git a/src/main/java/net/fabricmc/loom/newprovider/VanillaDependencyFetcher.java b/src/main/java/net/fabricmc/loom/newprovider/VanillaDependencyFetcher.java index 2fc80182..8093e611 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/VanillaDependencyFetcher.java +++ b/src/main/java/net/fabricmc/loom/newprovider/VanillaDependencyFetcher.java @@ -66,16 +66,21 @@ public VanillaDependencyFetcher fetch() throws Exception { Preconditions.checkNotNull(manifest, "minecraft version manifest"); Preconditions.checkNotNull(librariesBaseUrl, "libraries base URL"); + log.lifecycle("] native libraries directory: {}", nativesDir); + cleanOnRefreshDependencies(nativesDir); Path nativesJarStore = nativesDir.resolve("jars"); Files.createDirectories(nativesJarStore); + int nativeDepCount = 0; + for(VersionManifest.Library library : manifest.libraries) { if(!library.allowed()) continue; if(library.isNative()) { log.info("Found minecraft native dependency {}", library.getArtifactName()); + nativeDepCount++; Path libJarFile = library.getPath(nativesJarStore); @@ -130,6 +135,8 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { } } + log.info("] found {} native libraries and {} maven dependencies", nativeDepCount, mavenDependencies.size()); + return this; } diff --git a/src/main/java/net/fabricmc/loom/newprovider/VanillaJarFetcher.java b/src/main/java/net/fabricmc/loom/newprovider/VanillaJarFetcher.java index cb384f75..4d2e9ea5 100644 --- a/src/main/java/net/fabricmc/loom/newprovider/VanillaJarFetcher.java +++ b/src/main/java/net/fabricmc/loom/newprovider/VanillaJarFetcher.java @@ -71,8 +71,10 @@ public VanillaJarFetcher fetch() throws Exception { Path versionManifestIndexJson = getCacheDir().resolve("version_manifest.json"); Path thisVersionManifestJson = getCacheDir().resolve("minecraft-" + mc.getFilenameSafeVersion() + "-info.json"); - log.info("] client jar: {}", clientJar); - log.info("] server jar: {}", serverJar); + log.lifecycle("] client jar: {}", clientJar); + log.lifecycle("] server jar: {}", serverJar); + log.lifecycle("] manifest index: {}", versionManifestIndexJson); + log.lifecycle("] this version manifest: {}", thisVersionManifestJson); cleanOnRefreshDependencies(andEtags(Arrays.asList(clientJar, serverJar, thisVersionManifestJson, versionManifestIndexJson))); diff --git a/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerTask.java b/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerTask.java index 982cce45..04f2af70 100644 --- a/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerTask.java +++ b/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerTask.java @@ -75,7 +75,6 @@ public void doTask() throws Throwable { getLogging().captureStandardOutput(LogLevel.LIFECYCLE); ExecResult result = forkedJavaexec(spec -> { - //spec.setMain(ForkedFFExecutor.class.getName()); //TODO: setMain is deprecated and removed in Gradle 8 GradleSupport.setMainClass(spec, ForkedFFExecutor.class.getName()); //spec.jvmArgs("-Xms200m", "-Xmx3G"); //the defaults work on my machine :tm: and this version of minecraft is so small and cute diff --git a/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerUtils.java b/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerUtils.java deleted file mode 100644 index 69c0e703..00000000 --- a/src/main/java/net/fabricmc/loom/task/fernflower/FernFlowerUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of fabric-loom, licensed under the MIT License (MIT). - * - * Copyright (c) 2016, 2017, 2018 FabricMC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package net.fabricmc.loom.task.fernflower; - -import java.io.File; -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.jetbrains.java.decompiler.util.InterpreterUtil; - -public class FernFlowerUtils { - public static byte[] getBytecode(String externalPath, String internalPath) throws IOException { - File file = new File(externalPath); - - if (internalPath == null) { - return InterpreterUtil.getBytes(file); - } else { - try (ZipFile archive = new ZipFile(file)) { - ZipEntry entry = archive.getEntry(internalPath); - - if (entry == null) { - throw new IOException("Entry not found: " + internalPath); - } - - return InterpreterUtil.getBytes(archive, entry); - } - } - } -}