Skip to content

Commit

Permalink
closer now, still some wrong checksums...
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Dec 11, 2021
1 parent ccb215d commit a4e9363
Show file tree
Hide file tree
Showing 5 changed files with 666 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import dev.architectury.tinyremapper.OutputConsumerPath;
import dev.architectury.tinyremapper.TinyRemapper;
import net.minecraftforge.binarypatcher.ConsoleTool;
import net.minecraftforge.gradle.tasks.MergeJars;
import org.apache.commons.io.output.NullOutputStream;
import org.gradle.api.Project;
import org.gradle.api.file.ConfigurableFileCollection;
Expand Down Expand Up @@ -347,11 +348,21 @@ private void produceSrgJar(boolean official, Path clientJar, Path serverJar) thr

boolean isSrg = getExtension().getMcpConfigProvider().isSRG();

// ThreadingUtils.run(() -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg, isSrg), minecraftClientSrgJar.toPath());
// }, () -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg, isSrg), minecraftServerSrgJar.toPath());
// });
Path[] clientJarOut = new Path[] { null };
Path[] serverJarOut = new Path[] { null };

ThreadingUtils.run(() -> {
clientJarOut[0] = SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg, isSrg);
}, () -> {
serverJarOut[0] = SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg, isSrg);
});

if (isSrg) {
new MergeJars().processJar(clientJarOut[0].toFile(), serverJarOut[0].toFile(), minecraftClientSrgJar);
} else {
Files.copy(clientJarOut[0], minecraftClientSrgJar.toPath());
Files.copy(serverJarOut[0], minecraftServerSrgJar.toPath());
}
}

private Path getToSrgMappings() throws IOException {
Expand Down
39 changes: 22 additions & 17 deletions src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.stream.Collectors;

import com.google.common.base.Stopwatch;
import net.minecraftforge.gradle.tasks.MergeJars;
import org.apache.commons.io.output.NullOutputStream;
import org.gradle.api.Project;
import org.gradle.api.logging.LogLevel;
Expand Down Expand Up @@ -113,7 +114,7 @@ public static Path produceSrgJar(RemapAction remapAction, Project project, Strin
}

Path output = extension.getFiles().getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-srg-output.jar");
Files.deleteIfExists(output);
// Files.deleteIfExists(output);
stopwatch = Stopwatch.createStarted();

project.getLogger().info(stripped.toString());
Expand All @@ -123,32 +124,36 @@ public static Path produceSrgJar(RemapAction remapAction, Project project, Strin

Path workingDir = tmpDir();

project.javaexec(spec -> {
spec.setArgs(args);
spec.setClasspath(remapAction.getClasspath());
spec.workingDir(workingDir.toFile());
spec.getMainClass().set(remapAction.getMainClass());
if (!isSrg) {
project.javaexec(spec -> {
spec.setArgs(args);
spec.setClasspath(remapAction.getClasspath());
spec.workingDir(workingDir.toFile());
spec.getMainClass().set(remapAction.getMainClass());

// if running with INFO or DEBUG logging
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
// if running with INFO or DEBUG logging
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
spec.setStandardOutput(System.out);
spec.setErrorOutput(System.err);
} else {
spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM);
spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM);
}
}).rethrowFailure().assertNormalExitValue();
spec.setStandardOutput(System.out);
spec.setErrorOutput(System.err);
} else {
spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM);
spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM);
}
}).rethrowFailure().assertNormalExitValue();
} else {
Files.copy(stripped, output, StandardCopyOption.REPLACE_EXISTING);
}

project.getLogger().lifecycle(":remapped minecraft (" + remapAction + ", " + side + ", official -> mojang) in " + stopwatch.stop());

Files.deleteIfExists(stripped);
// Files.deleteIfExists(stripped);

Path tmp = tmpFile();
Files.deleteIfExists(tmp);
Files.copy(output, tmp);

Files.deleteIfExists(output);
// Files.deleteIfExists(output);
return tmp;
}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/net/minecraftforge/fml/relauncher/Side.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/

package net.minecraftforge.fml.relauncher;

public enum Side {

/**
* The client side. Specifically, an environment where rendering capability exists.
* Usually in the game client.
*/
CLIENT,
/**
* The server side. Specifically, an environment where NO rendering capability exists.
* Usually on the dedicated server.
*/
SERVER;

/**
* @return If this is the server environment
*/
public boolean isServer()
{
return !isClient();
}

/**
* @return if this is the Client environment
*/
public boolean isClient()
{
return this == CLIENT;
}
}
33 changes: 33 additions & 0 deletions src/main/java/net/minecraftforge/fml/relauncher/SideOnly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/

package net.minecraftforge.fml.relauncher;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
*
* Stolen from FML for use with merging the jars.
*
* @author cpw
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface SideOnly
{
public Side value();
}
Loading

0 comments on commit a4e9363

Please sign in to comment.