diff options
author | Tor Lillqvist <tml@iki.fi> | 2011-07-07 07:58:56 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2011-07-09 13:50:19 +0300 |
commit | 6b766372929f0b2fd5c0769074b72c5d045ac468 (patch) | |
tree | f18f7572444c47c49bf6ad094c6341da9a5e4288 | |
parent | a0b1f5482c44ae711dd2432455672d0f9e15735e (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...
-rw-r--r-- | sal/cppunittester/makefile.mk | 4 | ||||
-rw-r--r-- | sal/inc/sal/main.h | 57 | ||||
-rw-r--r-- | sal/osl/unx/salinit.cxx | 1 |
3 files changed, 61 insertions, 1 deletions
diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk index 938b63d90..7c43bab6b 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 bf7a82821..190aaed50 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 dd12d2f1c..9503443fe 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" { |