Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
add CommandReorderTiny
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Jun 28, 2019
1 parent 92715f4 commit ea16f28
Show file tree
Hide file tree
Showing 35 changed files with 143 additions and 34 deletions.
2 changes: 1 addition & 1 deletion HEADER
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016, 2017, 2018 Adrian Siekierka
Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/Command.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/fabricmc/stitch/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,7 @@ public static void addCommand(Command command) {
addCommand(new CommandMergeJar());
addCommand(new CommandMergeTiny());
addCommand(new CommandProposeFieldNames());
addCommand(new CommandReorderTiny());
addCommand(new CommandRewriteIntermediary());
addCommand(new CommandUpdateIntermediary());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
108 changes: 108 additions & 0 deletions src/main/java/net/fabricmc/stitch/commands/CommandReorderTiny.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.stitch.commands;

import com.google.common.base.Joiner;
import net.fabricmc.mappings.ClassEntry;
import net.fabricmc.mappings.EntryTriple;
import net.fabricmc.mappings.FieldEntry;
import net.fabricmc.mappings.Mappings;
import net.fabricmc.mappings.MappingsProvider;
import net.fabricmc.mappings.MethodEntry;
import net.fabricmc.stitch.Command;
import net.fabricmc.stitch.representation.JarReader;
import net.fabricmc.stitch.representation.JarRootEntry;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Locale;

public class CommandReorderTiny extends Command {
public CommandReorderTiny() {
super("reorderTiny");
}

@Override
public String getHelpString() {
return "<old-mapping-file> <new-mapping-file> [name order...]";
}

@Override
public boolean isArgumentCountValid(int count) {
return count >= 4;
}

@Override
public void run(String[] args) throws Exception {
File fileOld = new File(args[0]);
File fileNew = new File(args[1]);
String[] names = new String[args.length - 2];
System.arraycopy(args, 2, names, 0, names.length);

System.err.println("Loading mapping file...");

Mappings input;
try (FileInputStream stream = new FileInputStream(fileOld)) {
input = MappingsProvider.readTinyMappings(stream, false);
}

System.err.println("Rewriting mappings...");

try (FileOutputStream stream = new FileOutputStream(fileNew);
OutputStreamWriter osw = new OutputStreamWriter(stream);
BufferedWriter writer = new BufferedWriter(osw)) {

StringBuilder firstLineBuilder = new StringBuilder("v1");
for (String name : names) {
firstLineBuilder.append('\t').append(name);
}
writer.write(firstLineBuilder.append('\n').toString());
for (ClassEntry entry : input.getClassEntries()) {
StringBuilder s = new StringBuilder("CLASS");
for (String name : names) {
s.append('\t').append(entry.get(name));
}
writer.write(s.append('\n').toString());
}
for (FieldEntry entry : input.getFieldEntries()) {
StringBuilder s = new StringBuilder("FIELD");
EntryTriple first = entry.get(names[0]);
s.append('\t').append(first.getOwner()).append('\t').append(first.getDesc());
for (String name : names) {
s.append('\t').append(entry.get(name).getName());
}
writer.write(s.append('\n').toString());
}
for (MethodEntry entry : input.getMethodEntries()) {
StringBuilder s = new StringBuilder("METHOD");
EntryTriple first = entry.get(names[0]);
s.append('\t').append(first.getOwner()).append('\t').append(first.getDesc());
for (String name : names) {
s.append('\t').append(entry.get(name).getName());
}
writer.write(s.append('\n').toString());
}
}

System.err.println("Done!");
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/commands/GenMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/commands/GenState.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/merge/ClassMerger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/merge/JarMerger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/util/MatcherUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/util/Pair.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/stitch/util/StitchUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, 2018 Adrian Siekierka
* Copyright (c) 2016, 2017, 2018, 2019 Adrian Siekierka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit ea16f28

Please sign in to comment.