initial work

This commit is contained in:
Simon Gardling 2021-04-30 20:05:41 -04:00
parent 8d157f9be6
commit c43b088c81
22 changed files with 101339 additions and 1 deletions

5
.gitignore vendored
View File

@ -61,3 +61,8 @@ last-paper
!upstreamConfig/*
!upstreamCommits/*
testserver/
/Base
/Yatopia-Server_remapped
/Yatopia-Server_yarn
/Yatopia-Server_yarn_unpatched

9
.gitmodules vendored
View File

@ -37,3 +37,12 @@
[submodule "Yatopia-Server"]
path = Yatopia-Server
[submodule "Yatopia-Server_yarn"]
path = Yatopia-Server_yarn
[submodule "Yatopia-Server_remapped"]
path = Yatopia-Server_remapped
[submodule "Yatopia-Server_yarn_unpatched"]
path = Yatopia-Server_yarn_unpatched

View File

@ -14,6 +14,7 @@ import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import bashCmd
internal fun Project.createApplyPatchesTask(
receiver: Task.() -> Unit = {}
@ -98,5 +99,7 @@ internal fun Project.createApplyPatchesTask(
if (wasGitSigningEnabled) reEnableGitSigning(projectDir)
logger.lifecycle(">>> Done applying patches to $name")
}
bashCmd("sh scripts/init.sh", printOut = true)
bashCmd("sh scripts/apply.sh", printOut = true)
}
}

View File

@ -11,6 +11,7 @@ import upstreams
import java.io.File
import java.nio.file.Paths
import Upstream
import bashCmd
@Suppress("UNUSED_VARIABLE")
internal fun Project.createRebuildPatchesTask(
@ -20,7 +21,9 @@ internal fun Project.createRebuildPatchesTask(
group = taskGroup
doLast {
for ((name, subproject) in toothpick.subprojects) {
val (sourceRepo, projectDir, patchesDir) = subproject
val (sourceRepo, projectDir_1, patchesDir) = subproject
val projectDir = (if (patchesDir.endsWith("server")) File("${projectDir_1}") else projectDir_1)
var previousUpstreamName = "origin/master"
val folder = (if (patchesDir.endsWith("server")) "server" else "api")
@ -40,6 +43,9 @@ internal fun Project.createRebuildPatchesTask(
logger.lifecycle(">>> Done rebuilding patches for $name")
}
bashCmd("sh scripts/rebuildPatches.sh", printOut = true)
bashCmd("sh scripts/install.sh", printOut = true)
}
}

50374
map.srg Normal file

File diff suppressed because it is too large Load Diff

0
mappedPatches/.gitkeep Normal file
View File

View File

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Simon Gardling <titaniumtown@gmail.com>
Date: Fri, 30 Apr 2021 20:21:11 -0400
Subject: [PATCH] test
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
index 481e53af7d3f0af3c08b188097b2bd3f22d429a4..bebec9bf87757766607f053889a8c78d3384307d 100644
--- a/src/main/java/net/minecraft/CrashReport.java
+++ b/src/main/java/net/minecraft/CrashReport.java
@@ -21,7 +21,7 @@ import org.apache.logging.log4j.Logger;
public class CrashReport {
private static final Logger LOGGER = LogManager.getLogger();
- private final String message_;
+ private final String message_; // This is a cool test comment!!
private final Throwable cause_;
private final CrashReportSystemDetails systemDetailsSection_ = new CrashReportSystemDetails(this, "System Details");
private final List<CrashReportSystemDetails> otherSections_ = Lists.newArrayList();

6
mapper/.gitattributes vendored Normal file
View File

@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

5
mapper/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build

27
mapper/build.gradle Normal file
View File

@ -0,0 +1,27 @@
plugins {
id 'java'
id 'application'
}
repositories {
maven {
name = "Fabric"
url = 'https://maven.fabricmc.net/'
}
jcenter()
}
dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:29.0-jre'
// srg management
implementation 'org.cadixdev:lorenz:0.5.3'
// source code remapping
implementation 'org.cadixdev:mercury:0.1.0.fabric-SNAPSHOT'
}
application {
mainClassName = 'mapper.Main'
}

BIN
mapper/gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
mapper/gradlew vendored Executable file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

104
mapper/gradlew.bat vendored Normal file
View File

@ -0,0 +1,104 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

10
mapper/settings.gradle Normal file
View File

@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html
*/
rootProject.name = 'mapper'

View File

@ -0,0 +1,31 @@
package mapper;
import org.cadixdev.lorenz.io.srg.SrgReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import org.cadixdev.lorenz.MappingSet;
import org.cadixdev.mercury.remapper.MercuryRemapper;
import org.cadixdev.mercury.Mercury;
public class Main {
public static void main(String[] args) throws Exception {
Path mappingsPath = Paths.get(args[0]);
Path src = Paths.get(args[1]);
Path dist = Paths.get(args[2]);
Files.deleteIfExists(dist);
MappingSet mappings;
{
BufferedReader reader = Files.newBufferedReader(mappingsPath);
mappings = new SrgReader(reader).read();
}
Mercury m = new Mercury();
m.getProcessors().add(MercuryRemapper.create(mappings));
m.rewrite(src, dist);
}
}

47
scripts/apply.sh Normal file
View File

@ -0,0 +1,47 @@
#!/bin/sh
# set -e
cd "$(dirname "$0")"
cd ..
basedir="$(pwd -P)"
gitcmd="git -c commit.gpgsign=false"
applyPatch(){
local what="$1"
local what_name="$(basename "$what")"
local target="$2"
local branch="$3"
local patch_folder="$4"
cd "$basedir/$what"
$gitcmd branch -f upstream "$branch" >/dev/null
cd "$basedir"
if [ ! -d "$basedir/$target" ]; then
echo "doing clone"
$gitcmd clone "$what" "$target"
fi
cd "$basedir/$target"
echo "Resetting $target to $what_name..."
$gitcmd remote rm upstream > /dev/null 2>&1
$gitcmd remote add upstream "$basedir/$what" >/dev/null 2>&1
$gitcmd checkout master 2>/dev/null || $gitcmd checkout -b master
$gitcmd fetch upstream >/dev/null 2>&1
$gitcmd reset --hard upstream/upstream
echo " Applying patches to $target..."
$gitcmd am --abort >/dev/null 2>&1
if [ -z "$(ls "$basedir/$patch_folder/"*.patch||true)" ];then
echo " no patches for $target"
elif $gitcmd am --3way --ignore-whitespace "$basedir/$patch_folder/"*.patch; then
echo " Patches applied cleanly to $target"
else
echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh"
return 1
fi
}
(applyPatch Yatopia-Server_yarn_unpatched Yatopia-Server_yarn HEAD mappedPatches)

44
scripts/init.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
cd ..
basedir="$(pwd -P)"
source $basedir/scripts/source.sh
do_fixes(){
find -name '*.java' | xargs --max-procs=4 --no-run-if-empty sed -i '/^import [a-zA-Z0-9]*;$/d'
}
cd mapper
./gradlew installDist
cd "$basedir"
echo "Copying files for the 'Base' Folder"
rm -fr $basedir/Base
mkdir -p $basedir/Base/src/main/java/com/mojang
bash -c "cp -r ${basedir}/${inputdirprefix}Server/src/main/java/* ${basedir}/Base/src/main/java/"
# bash -c "cp -r ${basedir}/${inputdirprefix}API/src/main/java/* Base/src/main/java/"
mcver=$(cat "$paperdir/work/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
cp -r ${basedir}/${paperdir}/work/Minecraft/"${mcver}"/libraries/com.mojang/*/* ${basedir}/Base/src/main/java/
echo "Setting up 'Mapped' Folder"
rm -fr $basedir/Yatopia-Server_yarn_unpatched
mkdir -p $basedir/Yatopia-Server_yarn_unpatched/src/main/java
echo "Remapping...."
cp "${basedir}/${inputdirprefix}Server/.gitignore" "${basedir}/${inputdirprefix}Server/pom.xml" "${basedir}/${inputdirprefix}Server/checkstyle.xml" "${basedir}/${inputdirprefix}Server/CONTRIBUTING.md" "${basedir}/${inputdirprefix}Server/LGPL.txt" "${basedir}/${inputdirprefix}Server/LICENCE.txt" "${basedir}/${inputdirprefix}Server/README.md" Yatopia-Server_yarn_unpatched/
JAVA_OPTS="-Xms1G -Xmx2G" ${basedir}/mapper/build/install/mapper/bin/mapper ${basedir}/map.srg ${basedir}/Base/src/main/java ${basedir}/Yatopia-Server_yarn_unpatched/src/main/java
echo "Applying fixes..."
cd "$basedir"/Yatopia-Server_yarn_unpatched/src/main/java
do_fixes
cd "$basedir"/Yatopia-Server_yarn_unpatched
git init
git add .
git commit --quiet --message=init
cd "$basedir"

42
scripts/install.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
cd ..
basedir="$(pwd -P)"
source $basedir/scripts/source.sh
do_fixes(){
find -name '*.java' | xargs --max-procs=4 --no-run-if-empty sed -i '/^import [a-zA-Z0-9]*;$/d'
}
git config init.defaultBranch master
cd $basedir
rm -fr Yatopia-Server_remapped
mkdir -p Yatopia-Server_remapped/src/main
cp -r Base/src/main/java Yatopia-Server_remapped/src/main/
cd Yatopia-Server_remapped
git init
git add .
git commit --quiet --message=Base
rm -fr src/main/java/*
cd ..
JAVA_OPTS="-Xms1G -Xmx2G" "${basedir}/mapper/build/install/mapper/bin/mapper" "${basedir}/unmap.srg" "${basedir}/Yatopia-Server_yarn/src/main/java" "${basedir}/Yatopia-Server_remapped/src/main/java"
cd "$basedir"
cd Yatopia-Server_remapped/src/main/java
do_fixes
cd "$basedir"
changed="$(cat mappedPatches/*.patch | grep "+++ b/" | sort | uniq | sed 's/\+\+\+ b\///g')"
cd Yatopia-Server_remapped
# git add .
git add $changed #only commit the files that were modified
git diff --cached > a.patch
cd "${basedir}/${inputdirprefix}Server"
patch -p1 < "$basedir/Yatopia-Server_remapped/a.patch"
git add .
git commit -m "<Mapped Patches>"

37
scripts/rebuildPatches.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
cd "$(dirname "$0")"
cd ..
basedir="$(pwd -P)"
echo "Rebuilding patch files from current fork state..."
savePatches(){
local what="$1"
local patch_folder="$2"
cd "$basedir/$what" || return 1
mkdir -p "$basedir/$patch_folder"
if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter
echo "REBASE DETECTED - PARTIAL SAVE"
local last="$(cat .git/rebase-apply/last)"
local next="$(cat .git/rebase-apply/next)"
declare -a files=("$basedir/$patch_folder/"*.patch)
for i in $(seq -f "%04g" 1 1 "$last")
do
if [ "$i" -lt "$next" ]; then
rm "${files[`expr $i - 1`]}"
fi
done
else
if [ $(find $basedir/$patch_folder -type f | wc -l) != 0 ]; then
rm "$basedir/$patch_folder/"*.patch
fi
fi
git format-patch --no-signature --zero-commit --full-index --no-stat -N -o "$basedir/$patch_folder" upstream/upstream
cd "$basedir" || return 1
git add -A "$basedir/$patch_folder"
echo " Patches saved for $what to $patch_folder"
}
(savePatches Yatopia-Server_yarn mappedPatches) || exit 1

5
scripts/source.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# inputdirprefix="" #for testing
inputdirprefix="Yatopia-" #for testing
paperdir="Paper"

50374
unmap.srg Normal file

File diff suppressed because it is too large Load Diff