Merge pull request #11824 from endragor/ios-logging

Fix logging on iOS
This commit is contained in:
Rémi Verschelde 2017-10-09 12:23:34 +02:00 committed by GitHub
commit ad85acfe31
4 changed files with 18 additions and 16 deletions

View File

@ -81,7 +81,7 @@ void _set_keep_screen_on(bool p_enabled) {
extern int gargc;
extern char **gargv;
extern int iphone_main(int, int, int, char **);
extern int iphone_main(int, int, int, char **, String);
extern void iphone_finish();
CMMotionManager *motionManager;
@ -393,15 +393,6 @@ static int frame_count = 0;
};
++frame_count;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// NSString *documentsDirectory = [[[NSFileManager defaultManager]
// URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
// lastObject];
OSIPhone::get_singleton()->set_data_dir(
String::utf8([documentsDirectory UTF8String]));
NSString *locale_code = [[NSLocale currentLocale] localeIdentifier];
OSIPhone::get_singleton()->set_locale(
String::utf8([locale_code UTF8String]));
@ -604,7 +595,11 @@ static int frame_count = 0;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
int err = iphone_main(backingWidth, backingHeight, gargc, gargv);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
int err = iphone_main(backingWidth, backingHeight, gargc, gargv, String::utf8([documentsDirectory UTF8String]));
if (err != 0) {
// bail, things did not go very well for us, should probably output a message on screen with our error code...
exit(0);

View File

@ -29,6 +29,7 @@
/*************************************************************************/
#include "main/main.h"
#include "os_iphone.h"
#include "ustring.h"
#include <stdio.h>
#include <string.h>
@ -41,9 +42,9 @@ int add_path(int p_argc, char **p_args);
int add_cmdline(int p_argc, char **p_args);
};
int iphone_main(int, int, int, char **);
int iphone_main(int, int, int, char **, String);
int iphone_main(int width, int height, int argc, char **argv) {
int iphone_main(int width, int height, int argc, char **argv, String data_dir) {
int len = strlen(argv[0]);
@ -63,7 +64,7 @@ int iphone_main(int width, int height, int argc, char **argv) {
char cwd[512];
getcwd(cwd, sizeof(cwd));
printf("cwd %s\n", cwd);
os = new OSIPhone(width, height);
os = new OSIPhone(width, height, data_dir);
char *fargv[64];
for (int i = 0; i < argc; i++) {

View File

@ -97,6 +97,8 @@ void OSIPhone::initialize_core() {
OS_Unix::initialize_core();
SemaphoreIphone::make_default();
set_data_dir(data_dir);
};
void OSIPhone::initialize_logger() {
@ -572,7 +574,7 @@ bool OSIPhone::_check_internal_feature_support(const String &p_feature) {
return p_feature == "mobile" || p_feature == "etc" || p_feature == "pvrtc" || p_feature == "etc2";
}
OSIPhone::OSIPhone(int width, int height) {
OSIPhone::OSIPhone(int width, int height, String p_data_dir) {
main_loop = NULL;
visual_server = NULL;
@ -586,6 +588,10 @@ OSIPhone::OSIPhone(int width, int height) {
event_count = 0;
virtual_keyboard_height = 0;
// can't call set_data_dir from here, since it requires DirAccess
// which is initialized in initialize_core
data_dir = p_data_dir;
_set_logger(memnew(SyslogLogger));
};

View File

@ -201,7 +201,7 @@ public:
virtual void native_video_stop();
virtual bool _check_internal_feature_support(const String &p_feature);
OSIPhone(int width, int height);
OSIPhone(int width, int height, String p_data_dir);
~OSIPhone();
};