Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.neoforged.neoform.runtime.graph.NodeOutput;
import net.neoforged.neoform.runtime.graph.NodeOutputType;
import net.neoforged.neoform.runtime.utils.ToolCoordinate;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Objects;
Expand All @@ -13,11 +14,15 @@ public final class PatchActionFactory {

public static NodeOutput makeAction(ExecutionNodeBuilder builder,
DataSource patches,
NodeOutput sources,
@Nullable NodeOutput sources,
String basePathPrefix,
String modifiedPathPrefix) {
Objects.requireNonNull(patches, "patches");
builder.input("input", sources.asInput());
if (sources != null) {
builder.input("input", sources.asInput());
} else if (!builder.hasInput("input")) {
throw new IllegalStateException("The builder must have an input named 'input' when no explit sources are given.");
}
var mainOutput = builder.output("output", NodeOutputType.ZIP, "ZIP file containing the patched sources");
builder.output("outputRejects", NodeOutputType.ZIP, "ZIP file containing the rejected patches");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void run(ProcessingEnvironment environment) throws IOException, Interrupt
Path mappingsPath = null;
if (generateDistManifestSettings != null) {
otherDistJarPath = environment.getRequiredInputPath(INPUT_OTHER_DIST_JAR);
mappingsPath = environment.getRequiredInputPath(INPUT_MAPPINGS);
mappingsPath = environment.getInputPath(INPUT_MAPPINGS);
}

var classesJar = environment.getOutputPath("output");
Expand Down Expand Up @@ -132,6 +132,7 @@ private static void generateDistSourceManifest(String distId,
ZipFile jar,
String otherDistId,
Path otherDistJarPath,
@Nullable
Path mappingsPath,
JarOutputStream resourcesJarOut) throws IOException {
var mappings = mappingsPath != null ? IMappingFile.load(mappingsPath.toFile()) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private void execute(NeoFormEngine engine) throws InterruptedException, IOExcept
));

if (neededResults.isEmpty()) {
System.err.println("No results requested. Available results: " + engine.getAvailableResults());
System.err.println("No results requested using --write-result=<result>:<path>. Available results: " + engine.getAvailableResults());
System.exit(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.neoforged.neoform.runtime.graph.ExecutionNode;
import net.neoforged.neoform.runtime.graph.ExecutionNodeBuilder;
import net.neoforged.neoform.runtime.graph.NodeExecutionException;
import net.neoforged.neoform.runtime.graph.NodeInput;
import net.neoforged.neoform.runtime.graph.NodeOutput;
import net.neoforged.neoform.runtime.graph.NodeOutputType;
import net.neoforged.neoform.runtime.graph.ResultRepresentation;
Expand All @@ -39,6 +40,7 @@
import net.neoforged.neoform.runtime.utils.OsUtil;
import net.neoforged.neoform.runtime.utils.StringUtil;
import net.neoforged.problems.ProblemReporter;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.PrintWriter;
Expand Down Expand Up @@ -182,16 +184,18 @@ public void loadNeoFormProcess(NeoFormDistConfig distConfig) {
addNodeForStep(graph, distConfig, step);
}

var renameOutput = graph.getRequiredOutput("rename", "output");

var sourcesOutput = graph.getRequiredOutput("patch", "output");

var compiledOutput = addRecompileStep(distConfig, sourcesOutput);

var sourcesAndCompiledOutput = addMergeWithSourcesStep(compiledOutput, sourcesOutput);

// Register the sources and the compiled binary as results
graph.setResult("vanillaDeobfuscated", renameOutput);
// Vanilla deobfuscated is equivalent to the input to the decompiler
var decompile = graph.getNode("decompile");
if (decompile != null && decompile.inputs().get("input") instanceof NodeInput.NodeInputForOutput nodeInputForOutput) {
graph.setResult("vanillaDeobfuscated", nodeInputForOutput.getOutput());
}
graph.setResult("sources", sourcesOutput);
graph.setResult("compiled", compiledOutput);
graph.setResult("sourcesAndCompiled", sourcesAndCompiledOutput);
Expand Down Expand Up @@ -343,11 +347,15 @@ private void addNodeForStep(ExecutionGraph graph, NeoFormDistConfig config, NeoF

action.generateSplitManifest("client", "server");
builder.input(SplitResourcesFromClassesAction.INPUT_OTHER_DIST_JAR, serverJarInput);
builder.input(SplitResourcesFromClassesAction.INPUT_MAPPINGS, graph.getRequiredOutput("mergeMappings", "output").asInput());
if (graph.hasOutput("mergeMappings", "output")) {
builder.input(SplitResourcesFromClassesAction.INPUT_MAPPINGS, graph.getRequiredOutput("mergeMappings", "output").asInput());
}
} else if ("stripServer".equals(step.getId())) {
action.generateSplitManifest("server", "client");
builder.input(SplitResourcesFromClassesAction.INPUT_OTHER_DIST_JAR, graph.getRequiredOutput("downloadClient", "output").asInput());
builder.input(SplitResourcesFromClassesAction.INPUT_MAPPINGS, graph.getRequiredOutput("mergeMappings", "output").asInput());
if (graph.hasOutput("mergeMappings", "output")) {
builder.input(SplitResourcesFromClassesAction.INPUT_MAPPINGS, graph.getRequiredOutput("mergeMappings", "output").asInput());
}
}
}

Expand All @@ -363,11 +371,10 @@ private void addNodeForStep(ExecutionGraph graph, NeoFormDistConfig config, NeoF
));
}
case "patch" -> {
builder.clearInputs();
PatchActionFactory.makeAction(
builder,
getRequiredDataSource("patches"),
graph.getRequiredOutput("inject", "output"),
null,
"a/",
"b/"
);
Expand Down Expand Up @@ -790,6 +797,12 @@ public <T> T getRequiredInput(String id, ResultRepresentation<T> representation)
return node.getRequiredInput(id).getValue(representation);
}

@Nullable
@Override
public <T> T getInput(String id, ResultRepresentation<T> representation) throws IOException {
return node.hasInput(id) ? node.getRequiredInput(id).getValue(representation) : null;
}

@Override
public Path getOutputPath(String id) {
var output = node.getRequiredOutput(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.neoforged.neoform.runtime.artifacts.ArtifactManager;
import net.neoforged.neoform.runtime.graph.ResultRepresentation;
import net.neoforged.problems.ProblemReporter;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -43,8 +44,20 @@ default Path getRequiredInputPath(String id) {
}
}

@Nullable
default Path getInputPath(String id) {
try {
return getInput(id, ResultRepresentation.PATH);
} catch (IOException e) {
throw new UncheckedIOException(e); // Getting a path should not fail
}
}

<T> T getRequiredInput(String id, ResultRepresentation<T> representation) throws IOException;

@Nullable
<T> T getInput(String id, ResultRepresentation<T> representation) throws IOException;

/**
* Also automatically calls {@link #setOutput(String, Path)} with the generated path.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public Map<String, NodeInput> inputs() {
return inputs;
}

public boolean hasInput(String id) {
return inputs.containsKey(id);
}

public boolean hasOutput(String id) {
return outputs.containsKey(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ void setNode(ExecutionNode node) {

public abstract <T> T getValue(ResultRepresentation<T> representation) throws IOException;

static final class NodeInputForOutput extends NodeInput {
public static final class NodeInputForOutput extends NodeInput {
private NodeOutput output;

public NodeInputForOutput(NodeOutput output) {
this.output = output;
}

public NodeOutput getOutput() {
return output;
}

@Override
public void replaceReferences(NodeOutput oldOutput, NodeOutput newOutput) {
if (this.output == oldOutput) {
Expand Down