Skip to content

Commit

Permalink
update notice
Browse files Browse the repository at this point in the history
  • Loading branch information
MidCoard committed Nov 4, 2022
1 parent 238ad38 commit e85e535
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>MCLWJGLNativesDownloader</artifactId>
<artifactId>MinecraftNativesDownloader</artifactId>
<version>1.0</version>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
if (ignoreCompileTemplates == null) {
Process process = new ProcessBuilder("ant", "compile-templates").redirectOutput(new File(parent, "lwjgl-compile-templates.txt")).redirectError(new File(parent, "lwjgl-compile-templates.txt")).directory(lwjgl3).start();
if (process.waitFor() != 0) {
System.err.println(Files.readString(new File(parent, "lwjgl-compile-templates.txt").toPath()));
System.err.println("LWJGL compile templates failed. Please check the error above.");
System.exit(-1);
}
Expand All @@ -216,6 +217,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
platformResolver.resolveBeforeLwjglLink(lwjgl3);
Process process = new ProcessBuilder("ant", "compile-native").redirectOutput(new File(parent, "lwjgl-compile-native.txt")).redirectError(new File(parent, "lwjgl-compile-native.txt")).directory(lwjgl3).start();
if (process.waitFor() != 0 && ignore == null) {
System.err.println(Files.readString(new File(parent, "lwjgl-compile-native.txt").toPath()));
System.err.println("LWJGL compile native failed. Please add --ignore-error to ignore this error if this is a known error.");
System.exit(-1);
}
Expand Down Expand Up @@ -252,18 +254,21 @@ public static void main(String[] args) throws IOException, InterruptedException,
if (o == null) {
process = new ProcessBuilder("chmod", "-R", "777", ".").redirectOutput(new File(parent, "jemalloc-chmod.txt")).redirectError(new File(parent, "jemalloc-chmod.txt")).directory(jmalloc).start();
if (process.waitFor() != 0) {
System.err.println(Files.readString(new File(parent, "jemalloc-chmod.txt").toPath()));
System.err.println("jemalloc: change mode of * failed. Please add --no-change-mode if there is no permission problem.");
System.exit(-1);
}
}
System.out.println("Build jemalloc...");
process = new ProcessBuilder("./autogen.sh").redirectOutput(new File(parent, "jemalloc-configure.txt")).redirectError(new File(parent, "jemalloc-configure.txt")).directory(jmalloc).start();
if (process.waitFor() != 0) {
System.err.println(Files.readString(new File(parent, "jemalloc-configure.txt").toPath()));
System.err.println("jemalloc: autogen failed. Please check the error above.");
System.exit(-1);
}
process = new ProcessBuilder("make").redirectOutput(new File(parent, "jemalloc-make.txt")).redirectError(new File(parent, "jemalloc-make.txt")).directory(jmalloc).start();
if (process.waitFor() != 0 && ignore == null) {
System.err.println(Files.readString(new File(parent, "jemalloc-make.txt").toPath()));
System.err.println("jemalloc: make failed. Please add --ignore-error to ignore this error if this is a known error.");
System.exit(-1);
}
Expand All @@ -287,11 +292,13 @@ public static void main(String[] args) throws IOException, InterruptedException,
System.out.println("Build openal...");
Process process = new ProcessBuilder("cmake", "..").redirectOutput(new File(parent, "openal-cmake.txt")).redirectError(new File(parent, "openal-cmake.txt")).directory(buildFile).start();
if (process.waitFor() != 0) {
System.err.println(Files.readString(new File(parent, "openal-cmake.txt").toPath()));
System.err.println("openal: cmake failed. Please check the error above.");
System.exit(-1);
}
process = new ProcessBuilder("make").redirectOutput(new File(parent, "openal-make.txt")).redirectError(new File(parent, "openal-make.txt")).directory(buildFile).start();
if (process.waitFor() != 0 && ignore == null) {
System.err.println(Files.readString(new File(parent, "openal-make.txt").toPath()));
System.err.println("openal: make failed. Please add --ignore-error to ignore this error if this is a known error.");
System.exit(-1);
}
Expand All @@ -304,7 +311,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
if (buildLwjgl == null && ignoreBridge == null && find(builtLibs, "java-objc-bridge"))
TASKS.add(THREAD_POOL_SCHEDULER.run(() -> {
try {
platformResolver.resolveBridge(parent);
platformResolver.resolveBridge(parent, json);
System.out.println("Finish building bridge " + COUNTER.incrementAndGet() + "/" + TASKS.size());
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -322,6 +329,8 @@ public static void main(String[] args) throws IOException, InterruptedException,
if (!f.getName().endsWith(".txt") && !f.isDirectory())
Files.writeString(sha1.toPath(), f.getName() + ": " + Sha1Util.genSha1(f) + "\n", StandardOpenOption.CREATE, StandardOpenOption.APPEND);
}
File newJsonFile = new File(natives, jsonFile.getName());
Files.writeString(newJsonFile.toPath(), json.toJson());
option = options.get("no-clean");
if (option == null) {
System.out.println("Clean up...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void resolveMove(File parent, File natives, String bridgeVersion) throws
}

@Override
public void resolveBridge(File parent) throws IOException, InterruptedException {
public void resolveBridge(File parent,JSONObject json) throws IOException, InterruptedException {
File dir = new File(parent, "Java-Objective-C-Bridge-master");
if (!dir.exists()) {
System.out.println("Download Java-Objective-C-Bridge...");
Expand All @@ -145,9 +145,35 @@ public void resolveBridge(File parent) throws IOException, InterruptedException
System.out.println("Build Java-Objective-C-Bridge...");
Process process = new ProcessBuilder("mvn", "package").redirectOutput(new File(parent, "bridge.txt")).redirectError(new File(parent, "bridge.txt")).directory(dir).start();
if (process.waitFor() != 0) {
System.err.println(Files.readString(new File(parent, "bridge.txt").toPath()));
System.err.println("Java-Objective-C-Bridge: mvn package failed. Please check the error above.");
System.exit(-1);
}
JSONList list = json.getList("libraries");
for (JSONObject library : list) {
String name = library.get("name");
String[] arguments = name.split(":");
String group = arguments[0];
String type = arguments[1];
JSON j = (JSON) library;
if (group.equals("net.java.dev.jna") && type.equals("jna")) {
j.set("name", "net.java.dev.jna:jna:5.10.0");
JSON downloads = j.getJSON("downloads");
JSON artifact = downloads.getJSON("artifact");
artifact.set("path", "net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar");
artifact.set("url", "https://libraries.minecraft.net/net/java/dev/jna/jna/5.10.0/jna-5.10.0.jar");
artifact.set("sha1", "7cf4c87dd802db50721db66947aa237d7ad09418");
artifact.set("size", 1756400);
} else if (group.equals("net.java.dev.jna") && type.equals("jna-platform")) {
j.set("name", "net.java.dev.jna:jna-platform:5.10.0");
JSON downloads = j.getJSON("downloads");
JSON artifact = downloads.getJSON("artifact");
artifact.set("path", "net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar");
artifact.set("url", "https://libraries.minecraft.net/net/java/dev/jna/jna-platform/5.10.0/jna-platform-5.10.0.jar");
artifact.set("sha1", "fbed7d9669dba47714ad0d4f4454290a997aee69");
artifact.set("size", 1343495);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.commons.io.FileUtils;
import top.focess.minecraft.minecraftnativesdownloader.util.ZipUtil;
import top.focess.util.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -46,8 +47,8 @@ public void resolveMove(File parent, File natives, String bridgeVersion) throws
}

@Override
public void resolveBridge(File parent) throws IOException, InterruptedException {
PlatformResolver.getPlatformResolver(Platform.MACOS, Architecture.ARM64).resolveBridge(parent);
public void resolveBridge(File parent, JSONObject json) throws IOException, InterruptedException {
PlatformResolver.getPlatformResolver(Platform.MACOS, Architecture.ARM64).resolveBridge(parent, json);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package top.focess.minecraft.minecraftnativesdownloader.platform;

import top.focess.util.Pair;
import top.focess.util.json.JSONObject;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -47,7 +48,7 @@ protected static File find(File file, String suffix) {

public abstract void resolveMove(File parent, File natives, String bridgeVersion) throws IOException;

public abstract void resolveBridge(File parent) throws IOException, InterruptedException;
public abstract void resolveBridge(File parent, JSONObject json) throws IOException, InterruptedException;

public abstract void resolveBeforeLwjglBuild(File lwjgl) throws IOException;

Expand All @@ -69,7 +70,7 @@ public void resolveMove(File parent, File natives, String bridgeVersion) throws
}

@Override
public void resolveBridge(File parent) {
public void resolveBridge(File parent, JSONObject json) {

}

Expand Down

0 comments on commit e85e535

Please sign in to comment.