Merge ; commit 'caf79a2dfb75b9b4bb6d400fc7a1329076513a8f'

Conflicts:
	Natives/CMakeLists.txt
	Natives/JavaLauncher.h
This commit is contained in:
Duy Tran Khanh committed 2021-01-01 11:30:49 +07:00
commit 94fdb03c58
6 files changed
+27 -13

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
#import "AppDelegate.h"
#import "JavaLauncher.h"
#import <Foundation/Foundation.h>
@interface AppDelegate ()
+2 -3
View File
@@ -4,17 +4,16 @@ project(PojavLauncher)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "-x objective-c")
add_executable(PojavLauncher main.c JavaLauncher.c)
add_executable(PojavLauncher main.c log.m JavaLauncher.c)
target_link_libraries(PojavLauncher
"-framework UIKit"
)
set_target_properties(PojavLauncher PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget
MACOSX_BUNDLE_INFO_PLIST "../Info.plist")
add_library(pojavexec SHARED AppDelegate.m UILauncher.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c)
add_library(pojavexec SHARED log.m AppDelegate.m UILauncher.m egl_bridge_ios.m egl_bridge.c input_bridge_v3.c utils.c)
target_link_libraries(pojavexec
"-framework OpenGLES"
)
+10 -10
View File
@@ -4,12 +4,12 @@
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <bool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "jni.h"
#include "log.h"
#include "JavaLauncher.h"
// PojavLancher: fixme: are these wrong?
@@ -38,7 +38,7 @@ typedef jint JLI_Launch_func(int argc, char ** argv, /* main argc, argc */
);
void append(char* s, char* c) {
printf("Appending %s\n", c);
debug("Appending %s\n", c);
int len;
for (len = strlen(s); c[len] != '\0'; len++) {
s[len] = c[len];
@@ -47,13 +47,13 @@ void append(char* s, char* c) {
}
int launchJVM(int argc, char *argv[]) {
printf("Beginning JVM launch\n");
debug("Beginning JVM launch\n");
char *args_path = "/var/mobile/Documents/minecraft/overrideargs.txt";
char *log_path = "/var/mobile/Documents/minecraft/latestlog.txt";
char *main_jar = "/Applications/PojavLauncher.app/launcher.jar";
printf("Staring logging STDIO as jrelog:V\n");
debug("Staring logging STDIO as jrelog:V\n");
// Redirect stdio to latestlog.txt
FILE* logFile = fopen(log_path, "w");
int log_fd = fileno(logFile);
@@ -66,7 +66,7 @@ int launchJVM(int argc, char *argv[]) {
// Check if JVM restarts
if (!started) {
margv[margc++] = "/usr/lib/jvm/java-16-openjdk/bin/java";
printf("Reading custom JVM args (overrideargs.txt)");
debug("Reading custom JVM args (overrideargs.txt)");
char jvmargs[10000];
FILE* argsFile = fopen(args_path, "r");
if (argsFile) {
@@ -92,23 +92,23 @@ int launchJVM(int argc, char *argv[]) {
void* libjli = dlopen("/usr/lib/jvm/java-16-openjdk/lib/libjli.dylib", RTLD_LAZY | RTLD_GLOBAL);
if (NULL == libjli) {
printf("JLI lib = NULL: %s\n", dlerror());
debug("JLI lib = NULL: %s\n", dlerror());
return -1;
}
printf("Found JLI lib\n");
debug("Found JLI lib\n");
JLI_Launch_func *pJLI_Launch =
(JLI_Launch_func *)dlsym(libjli, "JLI_Launch");
if (NULL == pJLI_Launch) {
printf("JLI_Launch = NULL\n");
debug("JLI_Launch = NULL\n");
return -2;
}
printf("Calling JLI_Launch\n");
debug("Calling JLI_Launch\n");
int targc = started ? argc : margc;
char *targv[] targv = started ? argv : margv;
char **targv = started ? argv : margv;
if (!started) {
started = true;
+2
View File
@@ -1,5 +1,7 @@
#pragma once
#include <stdbool.h>
static bool started = false;
int launchJVM(int argc, char *argv[]);
+2
View File
@@ -9,6 +9,8 @@ extern "C" {
#define LOGI(...) printf(__VA_ARGS__)
#define LOGD(...) printf(__VA_ARGS__)
void debug(const char *message, ...) __attribute__((format(printf, 1, 2)));
#ifdef __cplusplus
}
#endif
+10
View File
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import "log.h"
void debug(const char *message,...)
{
va_list args;
va_start(args, message);
NSLog(@"%@",[[NSString alloc] initWithFormat:[NSString stringWithUTF8String:message] arguments:args]);
va_end(args);
}