5 files changed
+24
-9
No files matched your search
@@ -4,6 +4,7 @@
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "JavaLauncher.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
NSLog(@"Hello from app launch!");
|
||||
// TODO callback
|
||||
|
||||
return YES;
|
||||
|
||||
@@ -4,7 +4,7 @@ project(PojavLauncher)
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_C_FLAGS "-x objective-c")
|
||||
|
||||
add_executable(PojavLauncher main.c AppDelegate.m UILauncher.m JavaLauncher.c)
|
||||
add_executable(PojavLauncher main.c log.m AppDelegate.m UILauncher.m JavaLauncher.c)
|
||||
target_link_libraries(PojavLauncher
|
||||
"-framework UIKit"
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "log.h"
|
||||
#include "JavaLauncher.h"
|
||||
|
||||
// PojavLancher: fixme: are these wrong?
|
||||
@@ -37,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];
|
||||
@@ -46,14 +47,14 @@ void append(char* s, char* c) {
|
||||
}
|
||||
|
||||
int launchJVM(int argc, char *argv[]) {
|
||||
printf("Beginning JVM launch\n");
|
||||
debug("Beginning JVM launch\n");
|
||||
|
||||
mkdir("/var/mobile/Documents/minecraft", 0700);
|
||||
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 +67,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,20 +93,20 @@ 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user