summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2011-07-07 07:58:56 +0300
committerTor Lillqvist <tml@iki.fi>2011-07-09 13:50:19 +0300
commitd2218f8e2683bae4627f1067996158295026d1d6 (patch)
tree98a2ba6885398da5266237f57b2f23ea541947f6 /sal
parent13400b61afc88384afbac3bf885bee454e6b1fff (diff)
iOS hacking for cppunittester
We don't need sal/main.h in salinit.cxx as far as I can see. Add stuff to sal/main.h so that we can link an iOS executable that actually will run, and hack the makefile so that cppunittester builds successfully. Of course, a cppunittester executable built here won't be usable for anything interesting as we don't build any dynamic libraries of LibreOffice code for iOS, so there is nothing to pass on the command line to load. But hey, baby steps, experimentation, doing work in the public, commit often, etc...
Diffstat (limited to 'sal')
-rw-r--r--sal/cppunittester/makefile.mk4
-rw-r--r--sal/inc/sal/main.h57
-rw-r--r--sal/osl/unx/salinit.cxx1
3 files changed, 61 insertions, 1 deletions
diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk
index 938b63d90ae9..7c43bab6b743 100644
--- a/sal/cppunittester/makefile.mk
+++ b/sal/cppunittester/makefile.mk
@@ -35,6 +35,10 @@ ENABLE_EXCEPTIONS = TRUE
CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(OS)" == "IOS"
+CFLAGSCXX += -x objective-c++ -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300
+.ENDIF
+
OBJFILES = $(APP1OBJS)
APP1OBJS = $(OBJ)/cppunittester.obj
diff --git a/sal/inc/sal/main.h b/sal/inc/sal/main.h
index 536bf328a43a..0415d04ac0ea 100644
--- a/sal/inc/sal/main.h
+++ b/sal/inc/sal/main.h
@@ -41,6 +41,60 @@ extern "C" {
void SAL_CALL sal_detail_initialize(int argc, char ** argv);
void SAL_CALL sal_detail_deinitialize();
+#ifdef IOS
+
+#include <premac.h>
+#import <UIKit/UIKit.h>
+#include <postmac.h>
+
+static int sal_argc;
+static char **sal_argv;
+
+#define SAL_MAIN_WITH_ARGS_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ sal_argc = argc; \
+ sal_argv = argv; \
+ sal_detail_initialize(argc, argv); \
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \
+ int retVal = UIApplicationMain (argc, argv, @"UIApplication", @"salAppDelegate"); \
+ \
+ [pool release]; \
+ \
+ sal_detail_deinitialize(); \
+ return retVal; \
+}
+
+#define SAL_MAIN_IMPL \
+SAL_MAIN_WITH_ARGS_IMPL \
+ \
+int \
+sal_main_with_args(int argc, char ** argv) \
+{ \
+ return sal_main(); \
+}
+
+@interface salAppDelegate : NSObject <UIApplicationDelegate> {
+}
+@end
+
+int sal_main_with_args(int argc, char **argv);
+
+@implementation salAppDelegate
+
+- (BOOL)application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
+{
+ UIWindow *uiw = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ uiw.backgroundColor = [UIColor redColor];
+ [uiw release];
+
+ sal_main_with_args(sal_argc, sal_argv);
+}
+
+@end
+
+#else
+
#define SAL_MAIN_WITH_ARGS_IMPL \
int SAL_CALL main(int argc, char ** argv) \
{ \
@@ -61,6 +115,9 @@ int SAL_CALL main(int argc, char ** argv) \
return ret; \
}
+#endif
+
+
/* Definition macros for CRT entries */
#ifdef SAL_W32
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index 1ed1363500e9..e62bdab890eb 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -30,7 +30,6 @@
#include "sal/config.h"
#include "osl/process.h"
-#include "sal/main.h"
#include "sal/types.h"
extern "C" {