Skip to content

Commit

Permalink
"finish" injector module, more robust injected-client loading (open-o…
Browse files Browse the repository at this point in the history
…srs#2881)

"finish" injector module, more robust injected-client loading
  • Loading branch information
zeruth authored Dec 23, 2020
1 parent f415f3c commit c36be56
Show file tree
Hide file tree
Showing 65 changed files with 96 additions and 1,754 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ buildscript {
dependencies {
classpath("org.ajoberstar.grgit:grgit-core:4.1.0")
classpath("com.github.ben-manes:gradle-versions-plugin:0.36.0")
classpath("com.openosrs:openosrs-injector:1.0.2")
}
}

Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/BootstrapPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BootstrapPlugin : Plugin<Project> {
bootstrapDependencies(project(":runelite-api"))
bootstrapDependencies(project(":runescape-api"))
bootstrapDependencies(project(":http-api"))
bootstrapDependencies(project(":injected-client"))
bootstrapDependencies(project(":injector"))
bootstrapDependencies(project(":runelite-client"))
}

Expand All @@ -31,7 +31,7 @@ class BootstrapPlugin : Plugin<Project> {
dependsOn(project(":runelite-api").tasks["publish"])
dependsOn(project(":runescape-api").tasks["publish"])
dependsOn(project(":http-api").tasks["publish"])
dependsOn(project(":injected-client").tasks["publish"])
dependsOn(project(":injector").tasks["publish"])

doLast {
copy {
Expand All @@ -41,7 +41,7 @@ class BootstrapPlugin : Plugin<Project> {
copy {
from(
"${buildDir}/repo/.",
"${parent?.projectDir}/injected-client/build/repo/.",
"${parent?.projectDir}/injector/build/repo/.",
"${parent?.projectDir}/runelite-api/build/repo/.",
"${parent?.projectDir}/http-api/build/repo/.",
"${parent?.projectDir}/runescape-api/build/repo/."
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
82 changes: 0 additions & 82 deletions injected-client/injected-client.gradle.kts

This file was deleted.

44 changes: 44 additions & 0 deletions injector/injector.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import ProjectVersions.rsversion

group = "com.openosrs"
version = 1.0

repositories {
mavenCentral()
mavenLocal()
maven {
url = uri("https://repo.runelite.net")
url = uri("https://raw.githubusercontent.com/open-osrs/hosting/master")
url = uri("https://repo.openosrs.com/repository/maven")
}
}

plugins {
java
}

dependencies {
implementation(gradleApi())
annotationProcessor("org.projectlombok:lombok:1.18.12")
compileOnly("org.projectlombok:lombok:1.18.12")

implementation("org.ow2.asm:asm:8.0.1")
implementation("org.ow2.asm:asm-util:8.0.1")
implementation("org.jetbrains:annotations:19.0.0")
implementation("com.google.guava:guava:29.0-jre")
implementation(project(":deobfuscator"))
implementation(project(":runescape-api"))
implementation(project(":runescape-client"))
implementation(project(":runelite-mixins"))
}

tasks.register<JavaExec>("inject") {
main = "com.openosrs.injector.Injector"
classpath = sourceSets["main"].runtimeClasspath
}

tasks {
build {
finalizedBy("inject")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.openosrs.injector.injection.InjectTaskHandler;
import com.openosrs.injector.injectors.CreateAnnotations;
import com.openosrs.injector.injectors.InjectConstruct;
import com.openosrs.injector.injectors.Injector;
import com.openosrs.injector.injectors.InterfaceInjector;
import com.openosrs.injector.injectors.MixinInjector;
import com.openosrs.injector.injectors.RSApiInjector;
Expand All @@ -28,22 +27,43 @@
import java.io.File;
import java.io.IOException;
import net.runelite.deob.util.JarUtil;
import org.gradle.api.file.FileTree;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;

public class Injection extends InjectData implements InjectTaskHandler
public class Injector extends InjectData implements InjectTaskHandler
{
private static final Logger log = Logging.getLogger(Injection.class);
private static final Logger log = Logging.getLogger(Injector.class);

public Injection(File vanilla, File rsclient, File mixins, FileTree rsapi) throws IOException
public Injector(File vanilla, File rsclient, File mixins, File[] rsapi) throws IOException
{
super(
JarUtil.loadJar(vanilla),
JarUtil.loadJar(rsclient),
JarUtil.loadJar(mixins),
new RSApi(rsapi)
);
inject();
save(new File("../runelite-client/src/main/resources/net/runelite/client/injected-client.jar"));
}

public static void main(String[] args)
{
try
{
args = new String[]
{
"./vanilla.jar",
"../runescape-client/build/libs/runescape-client-3.5.4.jar",
"../runelite-mixins/build/libs/runelite-mixins-3.5.4.jar",
"../runescape-api/build/classes/java/main/net/runelite/rs/api/"
};
new Injector(new File(args[0]), new File(args[1]), new File(args[2]), new File(args[3]).listFiles());
}
catch (Exception e)
{
e.printStackTrace();
}

}

public void inject()
Expand Down Expand Up @@ -93,7 +113,7 @@ public void save(File outputJar) throws IOException
JarUtil.saveJar(this.getVanilla(), outputJar);
}

private void inject(Injector injector)
private void inject(com.openosrs.injector.injectors.Injector injector)
{
final String name = injector.getName();

Expand Down Expand Up @@ -132,7 +152,7 @@ private void transform(InjectTransformer transformer)
log.lifecycle("{} {}", name, transformer.getCompletionMsg());
}

public void runChildInjector(Injector injector)
public void runChildInjector(com.openosrs.injector.injectors.Injector injector)
{
inject(injector);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void check(ClassFile clazz, RSApiClass apiClass)

if (clazz.findMethodDeep(apiMethod.getName(), apiMethod.getSignature()) == null)
{
log.warn("[WARN] Class {} implements interface {} but doesn't implement {}",
log.error("[WARN] Class {} implements interface {} but doesn't implement {}",
clazz.getPoolClass(), apiClass.getClazz(), apiMethod.getMethod());
++missing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.runelite.asm.signature.Signature;

/**
* Abstract class meant as the interface of {@link com.openosrs.injector.Injection injection} for injectors
* Abstract class meant as the interface of {@link com.openosrs.injector.Injector injection} for injectors
*/
public abstract class InjectData
{
Expand Down Expand Up @@ -96,6 +96,7 @@ private Map<ClassFile, ClassFile> initToVanilla()
*/
public ClassFile toVanilla(ClassFile deobClass)
{

return toVanilla.get(deobClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void injectInterface(final ClassFile deobCf, final ClassFile vanillaCf)
final String fullName = API_BASE + impls;
if (!inject.getRsApi().hasClass(fullName))
{
log.debug("[DEBUG] Class {} implements nonexistent interface {}, skipping interface injection",
log.error("[DEBUG] Class {} implements nonexistent interface {}, skipping interface injection",
deobCf.getName(),
fullName
);
Expand All @@ -52,6 +52,7 @@ private void injectInterface(final ClassFile deobCf, final ClassFile vanillaCf)
}

final Interfaces interfaces = vanillaCf.getInterfaces();
System.out.println(fullName);
interfaces.addInterface(new Class(fullName));
implemented++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class RSApi implements Iterable<RSApiClass>

private ImmutableMap<String, RSApiClass> map;

public RSApi(FileTree classes)
public RSApi(File[] classes)
{
for (File file : classes)
{
Expand Down
3 changes: 0 additions & 3 deletions openosrs-injector/.gitignore

This file was deleted.

Loading

0 comments on commit c36be56

Please sign in to comment.