gradle: add support for rs2asm / overlay index
This commit is contained in:
@@ -6,3 +6,22 @@ dependencies {
|
|||||||
compile group: 'org.apache.maven', name: 'maven-plugin-api', version:'3.6.1'
|
compile group: 'org.apache.maven', name: 'maven-plugin-api', version:'3.6.1'
|
||||||
compileOnly group: 'org.apache.maven.plugin-tools', name: 'maven-plugin-annotations', version:'3.6.0'
|
compileOnly group: 'org.apache.maven.plugin-tools', name: 'maven-plugin-annotations', version:'3.6.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task assembleMojo(type:JavaExec) {
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
|
||||||
|
main = "net.runelite.script.AssembleMojo"
|
||||||
|
args('../runelite-client/src/main/scripts,../runelite-client/build/classes/runelite'.split(','))
|
||||||
|
}
|
||||||
|
|
||||||
|
task indexMojo(type:JavaExec) {
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
|
||||||
|
main = "net.runelite.script.IndexMojo"
|
||||||
|
args('../runelite-client/build/classes/runelite,../runelite-client/build/classes/runelite/index'.split(','))
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava.doLast {
|
||||||
|
tasks.assembleMojo.execute()
|
||||||
|
tasks.indexMojo.execute()
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.apache.maven.plugin.logging.Log;
|
|||||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@Mojo(
|
@Mojo(
|
||||||
name = "assemble",
|
name = "assemble",
|
||||||
@@ -54,6 +55,56 @@ public class AssembleMojo extends AbstractMojo
|
|||||||
|
|
||||||
private final Log log = getLog();
|
private final Log log = getLog();
|
||||||
|
|
||||||
|
public static void main(String args[])
|
||||||
|
{
|
||||||
|
File scriptDirectory = new File(args[0]);
|
||||||
|
File outputDirectory = new File(args[1]);
|
||||||
|
|
||||||
|
RuneLiteInstructions instructions = new RuneLiteInstructions();
|
||||||
|
instructions.init();
|
||||||
|
|
||||||
|
Assembler assembler = new Assembler(instructions);
|
||||||
|
ScriptSaver saver = new ScriptSaver();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber()));
|
||||||
|
scriptOut.mkdirs();
|
||||||
|
|
||||||
|
for (File scriptFile : scriptDirectory.listFiles((dir, name) -> name.endsWith(".rs2asm")))
|
||||||
|
{
|
||||||
|
System.out.println("Assembling " + scriptFile);
|
||||||
|
|
||||||
|
try (FileInputStream fin = new FileInputStream(scriptFile))
|
||||||
|
{
|
||||||
|
ScriptDefinition script = assembler.assemble(fin);
|
||||||
|
byte[] packedScript = saver.save(script);
|
||||||
|
|
||||||
|
File targetFile = new File(scriptOut, Integer.toString(script.getId()));
|
||||||
|
Files.write(packedScript, targetFile);
|
||||||
|
|
||||||
|
// Copy hash file
|
||||||
|
|
||||||
|
File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash");
|
||||||
|
if (hashFile.exists())
|
||||||
|
{
|
||||||
|
Files.copy(hashFile, new File(scriptOut, Integer.toString(script.getId()) + ".hash"));
|
||||||
|
}
|
||||||
|
else if (script.getId() < 10000) // Scripts >=10000 are RuneLite scripts, so they shouldn't have a .hash
|
||||||
|
{
|
||||||
|
System.out.println("Unable to find hash file for " + scriptFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
System.out.println("unable to open file " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Assembled " + count + " scripts");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException
|
public void execute() throws MojoExecutionException, MojoFailureException
|
||||||
{
|
{
|
||||||
@@ -63,6 +114,10 @@ public class AssembleMojo extends AbstractMojo
|
|||||||
Assembler assembler = new Assembler(instructions);
|
Assembler assembler = new Assembler(instructions);
|
||||||
ScriptSaver saver = new ScriptSaver();
|
ScriptSaver saver = new ScriptSaver();
|
||||||
|
|
||||||
|
System.out.println(outputDirectory);
|
||||||
|
System.out.println(scriptDirectory);
|
||||||
|
StringFileUtils.writeStringToFile("./Scriptstores.txt", outputDirectory + ":" + scriptDirectory);
|
||||||
|
System.exit(-1);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber()));
|
File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber()));
|
||||||
scriptOut.mkdirs();
|
scriptOut.mkdirs();
|
||||||
|
|||||||
@@ -48,6 +48,40 @@ public class IndexMojo extends AbstractMojo
|
|||||||
@Parameter(required = true)
|
@Parameter(required = true)
|
||||||
private File indexFile;
|
private File indexFile;
|
||||||
|
|
||||||
|
public static void main(String args[])
|
||||||
|
{
|
||||||
|
try (DataOutputStream fout = new DataOutputStream(new FileOutputStream(args[1])))
|
||||||
|
{
|
||||||
|
for (File indexFolder : new File(args[0]).listFiles())
|
||||||
|
{
|
||||||
|
if (indexFolder.isDirectory())
|
||||||
|
{
|
||||||
|
int indexId = parseInt(indexFolder.getName());
|
||||||
|
for (File archiveFile : indexFolder.listFiles())
|
||||||
|
{
|
||||||
|
int archiveId;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
archiveId = parseInt(archiveFile.getName());
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fout.writeInt(indexId << 16 | archiveId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fout.writeInt(-1);
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException
|
public void execute() throws MojoExecutionException, MojoFailureException
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user