mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Возможность сборки Avanguard для каждого проекта отдельно
This commit is contained in:
parent
4a2b535403
commit
b4cd10ef85
8 changed files with 33 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,6 +34,9 @@
|
|||
import proguard.ProGuard;
|
||||
|
||||
public final class JARLauncherBinary extends LauncherBinary {
|
||||
|
||||
public static final String[] guardFileList = {"Avanguard64.dll", "Avanguard32.dll", "wrapper64.exe", "wrapper32.exe"};
|
||||
|
||||
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
||||
private final ZipOutputStream output;
|
||||
private final Map<String, byte[]> runtime;
|
||||
|
@ -69,6 +73,7 @@ private static ZipEntry newEntry(String fileName) {
|
|||
|
||||
@LauncherAPI
|
||||
public final Path runtimeDir;
|
||||
public final Path guardDir;
|
||||
|
||||
@LauncherAPI
|
||||
public final Path initScriptFile;
|
||||
|
@ -81,6 +86,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
|||
super(server, server.dir.resolve(server.config.binaryName + ".jar"),
|
||||
server.dir.resolve(server.config.binaryName + (server.config.sign.enabled ? "-sign.jar" : "-obf.jar")));
|
||||
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
guardDir = server.dir.resolve("guard");
|
||||
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
|
||||
obfJar = server.config.sign.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar")
|
||||
: syncBinaryFile;
|
||||
|
@ -90,6 +96,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
|||
@Override
|
||||
public void build() throws IOException {
|
||||
tryUnpackRuntime();
|
||||
tryUnpackGuard();
|
||||
|
||||
// Build launcher binary
|
||||
LogHelper.info("Building launcher binary file");
|
||||
|
@ -232,6 +239,13 @@ private void stdBuild() throws IOException {
|
|||
output.putNextEntry(e);
|
||||
jaConfigurator.compile();
|
||||
output.write(jaConfigurator.getBytecode());
|
||||
for(String file : guardFileList)
|
||||
{
|
||||
Path path = guardDir.resolve(file);
|
||||
ZipEntry en = newZipEntry(file);
|
||||
output.putNextEntry(en);
|
||||
IOHelper.transfer(path,output);
|
||||
}
|
||||
server.buildHookManager.postHook(context);
|
||||
} catch (CannotCompileException | NotFoundException e) {
|
||||
LogHelper.error(e);
|
||||
|
@ -257,4 +271,23 @@ public void tryUnpackRuntime() throws IOException {
|
|||
}
|
||||
}
|
||||
}
|
||||
@LauncherAPI
|
||||
public void tryUnpackGuard() throws IOException {
|
||||
// Verify is runtime dir unpacked
|
||||
if (IOHelper.isDir(guardDir))
|
||||
return; // Already unpacked
|
||||
|
||||
// Unpack launcher runtime files
|
||||
Files.createDirectory(guardDir);
|
||||
LogHelper.info("Unpacking launcher native guard files");
|
||||
try (ZipInputStream input = IOHelper.newZipInput(IOHelper.getResourceURL("guard.zip"))) {
|
||||
for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) {
|
||||
if (entry.isDirectory())
|
||||
continue; // Skip dirs
|
||||
|
||||
// Unpack runtime file
|
||||
IOHelper.transfer(input, guardDir.resolve(IOHelper.toPath(entry.getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
BIN
LaunchServer/src/main/resources/guard.zip
Normal file
BIN
LaunchServer/src/main/resources/guard.zip
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue