Make it build as library
authorunc0rr
Sun, 02 Mar 2014 00:34:18 +0400
changeset 10173 fff5e4b0dfcb
parent 10172 7cfd1a9356b5
child 10174 710ffaae7d59
Make it build as library
QTfrontend/CMakeLists.txt
hedgewars/ArgParsers.pas
--- a/QTfrontend/CMakeLists.txt	Sat Mar 01 15:04:38 2014 -0500
+++ b/QTfrontend/CMakeLists.txt	Sun Mar 02 00:34:18 2014 +0400
@@ -156,6 +156,11 @@
     add_definitions(-DHWLIBRARY=1)
     set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
     list(APPEND HW_LINK_LIBS ${hwlibname})
+
+    if(LIBAV_FOUND)
+#        add_subdirectory(avwrapper)
+        list(APPEND HW_LINK_LIBS avwrapper)
+    endif()
 endif()
 
 qt4_add_resources(hwfr_rez_src ${hwfr_rez})
@@ -201,7 +206,7 @@
     ${SDL_LIBRARY}
     ${SDLMIXER_LIBRARY}
     )
-
+    
 if(WIN32 AND NOT UNIX)
     if(NOT SDL_LIBRARY)
         list(APPEND HW_LINK_LIBS SDL)
--- a/hedgewars/ArgParsers.pas	Sat Mar 01 15:04:38 2014 -0500
+++ b/hedgewars/ArgParsers.pas	Sun Mar 02 00:34:18 2014 +0400
@@ -25,6 +25,10 @@
 procedure GetParams;
 {$ELSE}
 procedure parseCommandLine(argc: LongInt; argv: PPChar);
+
+var operatingsystem_parameter_argc: integer = 0; export;
+    operatingsystem_parameter_argv: pointer = nil; export;
+    operatingsystem_parameter_envp: pointer = nil; export;
 {$ENDIF}
 
 implementation
@@ -146,6 +150,7 @@
     // Silence the hint that appears when USE_VIDEO_RECORDING is not defined
     paramIndex:= paramIndex;
 {$IFDEF USE_VIDEO_RECORDING}
+{$IFNDEF HWLIBRARY}
     GameType:= gmtRecord;
     inc(paramIndex);
     cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex);
@@ -156,13 +161,14 @@
     cVideoQuality:= StrToInt(ParamStr(paramIndex));      inc(paramIndex);
     cAudioCodec:= ParamStr(paramIndex);                  inc(paramIndex);
 {$ENDIF}
+{$ENDIF}
 end;
 
 function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt;
 var tmpInt, c: LongInt;
 begin
     inc(paramIndex);
-{$IFDEF PAS2C}
+{$IFDEF PAS2C OR HWLIBRARY}
     val(str, tmpInt);
 {$ELSE}
     val(str, tmpInt, c);
@@ -177,8 +183,10 @@
 begin
     inc(paramIndex);
     wrongParameter:= (str='') or (Copy(str,1,2) = '--');
+    {$IFNDEF HWLIBRARY}
     if wrongParameter then
-         WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"');
+        WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"');
+    {$ENDIF}
     getstringParameter:= str;
 end;
 
@@ -277,7 +285,7 @@
         newSyntax:= '';
         inc(paramIndex);
         cmd:= cmdarray[index];
-        arg:= ParamStr(paramIndex);
+        arg:= cmdarray[paramIndex];
         isValid:= (cmd<>'--depth');
 
         // check if the parameter is a boolean one
@@ -309,6 +317,11 @@
     wrongParameter: boolean;
 //var tmpInt: LongInt;
 begin
+    {$IFDEF HWLIBRARY}
+    operatingsystem_parameter_argc:= argc;
+    operatingsystem_parameter_argv:= argv;
+    {$ENDIF}
+
     paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF};
     paramTotal:= {$IFDEF HWLIBRARY}argc-1{$ELSE}ParamCount{$ENDIF}; //-1 because pascal enumeration is inclusive
     (*