fix compiling for android, strip out all delphi code, objfpc ftw hedgeroid
authorkoda
Tue, 04 Oct 2011 19:20:42 +0200
branchhedgeroid
changeset 6033 6bcc36225162
parent 6031 95d565991edd
child 6035 bdd0528ee8a6
fix compiling for android, strip out all delphi code, objfpc ftw
hedgewars/hwLibrary.pas
hedgewars/options.inc
hedgewars/uConsole.pas
project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java
project_files/Android-build/Templates/Makefile.android
--- a/hedgewars/hwLibrary.pas	Tue Oct 04 17:18:25 2011 +0200
+++ b/hedgewars/hwLibrary.pas	Tue Oct 04 19:20:42 2011 +0200
@@ -17,26 +17,31 @@
  *)
 
 Library hwLibrary;
-
+{$INCLUDE "options.inc"}
 
-// Add all your Pascal units to the "uses" clause below to add them to the program.
+// Add all your Pascal units to the 'uses' clause below to add them to the program.
 // Mark all Pascal procedures/functions that you wish to call from C/C++/Objective-C code using
-// "cdecl; export;" (see the fpclogo.pas unit for an example), and then add C-declarations for
-// these procedures/functions to the PascalImports.h file (also in the "Pascal Sources" group)
+// 'cdecl; export;' (see the fpclogo.pas unit for an example), and then add C-declarations for
+// these procedures/functions to the PascalImports.h file (also in the 'Pascal Sources' group)
 // to make these functions available in the C/C++/Objective-C source files
-// (add "#include PascalImports.h" near the top of these files if it's not there yet)
+// (add '#include PascalImports.h' near the top of these files if it is not there yet)
 uses PascalExports, hwengine{$IFDEF ANDROID}, jni{$ENDIF};
 exports Game, HW_versionInfo;
 
 {$IFDEF ANDROID}
 function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl;
 begin
-    JNI_HW_versionInfoNet := cNetProtoVersion;
+    env:= env; // avoid hint
+    obj:= obj; // avoid hint
+    JNI_HW_versionInfoNet:= cNetProtoVersion;
 end;
 
 function JNI_HW_versionInfoVersion(env: PJNIEnv; obj: JObject):JString; cdecl;
+var envderef : JNIEnv;
 begin
-    JNI_HW_versionInfoVersion := env^.NewStringUTF(env, PChar(cVersionString));
+    obj:= obj; // avoid hint
+    envderef:= @env;
+    JNI_HW_versionInfoVersion := envderef^.NewStringUTF(env, PChar(cVersionString));
 end;
 
 exports
--- a/hedgewars/options.inc	Tue Oct 04 17:18:25 2011 +0200
+++ b/hedgewars/options.inc	Tue Oct 04 19:20:42 2011 +0200
@@ -28,7 +28,6 @@
 {$DEFINE GLunit:=GL}
 
 {$IFDEF ANDROID}
-  {$MODE delphi}
   {$DEFINE SDL13}
   {$DEFINE HWLIBRARY}
   {$DEFINE S3D_DISABLED}
@@ -43,7 +42,10 @@
   {$DEFINE S3D_DISABLED}
   {$DEFINE GLunit:=gles11}
   {$DEFINE MOBILE}
-{$ELSE}
+{$ENDIF}
+
+{$IFNDEF IPHONEOS}
+  // not needed on ios because it is switched from the compiler command line arguments
   {$DEFINE DEBUGFILE}
   //{$DEFINE TRACEAIACTIONS}
   //{$DEFINE COUNTTICKS}
--- a/hedgewars/uConsole.pas	Tue Oct 04 17:18:25 2011 +0200
+++ b/hedgewars/uConsole.pas	Tue Oct 04 19:20:42 2011 +0200
@@ -93,9 +93,9 @@
 
 function ShortStringAsPChar(s: ShortString) : PChar;
 begin
-    if Length(S) = High(s) then Dec(s[0]);
+    if Length(s) = High(s) then Dec(s[0]);
     s[Ord(Length(s))+1] := #0;
-    Result := @S[1];
+    exit(@s[1]);
 end;
 
 function GetLastConsoleLine: shortstring;
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java	Tue Oct 04 17:18:25 2011 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java	Tue Oct 04 19:20:42 2011 +0200
@@ -283,7 +283,7 @@
 		// Runs SDL_main() with added parameters
 		SDLActivity.nativeInit(new String[] { String.valueOf(ipc.port),
 				String.valueOf(surfaceWidth), String.valueOf(surfaceHeight),
-				"0", "null", "xeli", "1", "1", "1", "0", "", path });
+				"0", "null", "xeli", "1", "1", "1", path, ""  });
 
 		try {
 			ipc.quitIPC();
--- a/project_files/Android-build/Templates/Makefile.android	Tue Oct 04 17:18:25 2011 +0200
+++ b/project_files/Android-build/Templates/Makefile.android	Tue Oct 04 19:20:42 2011 +0200
@@ -1,7 +1,7 @@
 SDL_ANDROID_DIR=./SDL-android-project
 
 PPCROSSARM=${FPC_DIR}/compiler/ppcrossarm
-PPCROSSARM_FLAGS= -Xd -O- -Tlinux -XParm-linux-androideabi- -vwnh -XS -a- 
+PPCROSSARM_FLAGS= -Xd -O- -Tlinux -XParm-linux-androideabi- -vwnh -XS -a- -B
 PPCROSSARM_INCLUDES= \
 	-FD${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin \
 	-Fu${FPC_DIR}/rtl/units/arm-linux \