Procházet zdrojové kódy

Added UIQ 2 device support for mksymbian

git-svn-id: trunk@8832 -
sekelsenmat před 18 roky
rodič
revize
091e563e77

+ 3 - 2
utils/mksymbian/cmdline.pas

@@ -72,7 +72,7 @@ begin
   WriteLn('');
   WriteLn('Possible commands: ');
   WriteLn('');
-  WriteLn('build    - Builds a application');
+  WriteLn('build    - Builds an application');
   WriteLn('bindings - Builds the c++ bindings for pascal');
   WriteLn('showpath - Show the paths the tool is using');
   WriteLn('');
@@ -92,7 +92,8 @@ procedure TCmdLine.ShowPath;
 begin
   WriteLn('mksymbian - Build tool for Free Pascal for SymbianOS');
   WriteLn('');
-  WriteLn('Location of UIQ 3 SDK: ' + vSDKUtil.SDKFolder);
+  WriteLn('SDK Version: ' + vSDKUtil.StrSDKVersion);
+  WriteLn('Location of SDK: ' + vSDKUtil.SDKFolder);
   WriteLn('Location of Free Pascal Compiler: ' + vProject.CompilerPath);
   WriteLn('');
 end;

+ 118 - 1
utils/mksymbian/compiler.pas

@@ -47,6 +47,8 @@ type
     destructor Destroy; override;
     procedure FileCopy(source, dest: string);
     procedure MakeBuildPascal;
+    procedure MakeBuildPascal_UIQ21_ARM;
+    procedure MakeBuildPascal_UIQ3_Emulator;
     procedure MakeBuildCpp;
     procedure MakeBuildBindings;
     procedure BuildUIDFile;
@@ -151,6 +153,121 @@ end;
 *
 *******************************************************************}
 procedure TCompiler.MakeBuildPascal;
+begin
+  case vSDKUtil.SDKVersion of
+   sdkUIQ21: MakeBuildPascal_UIQ21_ARM;
+   sdkUIQ3:  MakeBuildPascal_UIQ3_Emulator;
+  end;
+end;
+
+procedure TCompiler.MakeBuildPascal_UIQ21_ARM;
+var
+  EPOCSTATLINKUREL, EPOCLINKUREL, LIBSUREL: string;
+begin
+  WriteLn('');
+  WriteLn('Preparations for compiling');
+  WriteLn('');
+
+  { Creation of directories }
+
+  { Compiling the source files }
+
+  WriteLn('');
+  WriteLn('Compiling the source files');
+  WriteLn('');
+
+  { Linking and library creation }
+  
+  WriteLn('');
+  WriteLn('Linking and library creation');
+  WriteLn('');
+
+  EPOCSTATLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
+  EPOCLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
+
+  LIBSUREL := EPOCSTATLINKUREL + 'EDLLSTUB.LIB '
+    + EPOCSTATLINKUREL + 'EGCC.LIB '
+    + EPOCLINKUREL + 'EUSER.LIB '
+    + EPOCLINKUREL + 'APPARC.LIB '
+    + EPOCLINKUREL + 'CONE.LIB '
+    + EPOCLINKUREL + 'EIKCORE.LIB '
+    + EPOCLINKUREL + 'EIKCOCTL.LIB ';
+
+  AProcess.CommandLine := 'dlltool -m thumb '
+   + '--output-def "' + MakePartialFolder + 'HELLOWORLD.inf" "'
+   + MakePartialFolder + 'HELLOWORLD.in" ';
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+  AProcess.CommandLine := 'perl -S ' + vSdkUtil.SDKFolder + Str_Path_UIQ2_Makmake
+   + ' -Deffile "' + MakePartialFolder + 'HELLOWORLD.inf" -1 NewApplication__Fv "'
+   + MakePartialFolder + 'HELLOWORLD.dev"';
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+{ -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.inf" }
+
+  AProcess.CommandLine := 'dlltool -m thumb --def "'
+   + MakePartialFolder + 'HELLOWORLD.def" --output-exp "'
+   + MakePartialFolder + 'HELLOWORLD.exp" --dllname "HELLOWORLD[101f6163].APP"';
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+  AProcess.CommandLine := 'ld  -s --thumb-entry _E32Dll '
+   + '-u _E32Dll "' + MakePartialFolder + 'HELLOWORLD.exp" '
+   + '--dll --base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
+   + '-o "' + MakePartialFolder + 'HELLOWORLD.APP" "'
+   + EPOCSTATLINKUREL + 'EDLL.LIB" '
+   + '--whole-archive "' + MakePartialFolder + 'HELLOWORLD.in" '
+   + '--no-whole-archive ' + LIBSUREL;
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+{	-$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.exp"
+	-$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.APP"
+ }
+
+  AProcess.CommandLine := 'dlltool -m thumb '
+   + '--def "' + MakePartialFolder + 'HELLOWORLD.def" '
+   + '--dllname "HELLOWORLD[101f6163].APP" '
+   + '--base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
+   + '--output-exp ' + MakePartialFolder + 'HELLOWORLD.exp"';
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+  AProcess.CommandLine := 'ld  -s --thumb-entry _E32Dll -u _E32Dll --dll "'
+   + MakePartialFolder + 'HELLOWORLD.exp" -Map "'
+   + MakePartialFolder + 'HELLOWORLD.APP.map" -o "'
+   + MakePartialFolder + 'HELLOWORLD.APP" "'
+   + EPOCSTATLINKUREL + 'EDLL.LIB" --whole-archive "'
+   + MakePartialFolder + 'HELLOWORLD.in" --no-whole-archive '
+   + LIBSUREL;
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+
+  AProcess.CommandLine := 'petran  "'
+   + MakePartialFolder + 'HELLOWORLD.APP" "'
+   + MakePartialFolder + 'HELLOWORLD.APP" '
+   + '-nocall -uid1 0x10000079 -uid2 0x100039ce -uid3 0x101f6163';
+  WriteLn('');
+  WriteLn(AProcess.CommandLine);
+  WriteLn('');
+  AProcess.Execute;
+end;
+
+procedure TCompiler.MakeBuildPascal_UIQ3_Emulator;
 var
   STR_LINK_FLAGSUDEB, STR_EPOCBLDUDEB, STR_LINK_OBJSUDEB: string;
   STR_FPC_RTL_OBJECTS: string;
@@ -180,7 +297,7 @@ begin
   WriteLn('');
   WriteLn('Compiling file ' + vProject.MainSource);
   WriteLn('');
-  
+
   AProcess.CommandLine := vProject.CompilerPath + ' -a -s -Fu' + vProject.RTLUnitsDir +
     ' -Tsymbian QPasHello.pas';
   WriteLn(AProcess.CommandLine);

+ 13 - 0
utils/mksymbian/constants.pas

@@ -42,6 +42,14 @@ type
     ProjectFile: string;
   end;
 
+{ Constants and types for the SDK version }
+type
+  TSDKVersion = (sdkUIQ21, sdkUIQ3);
+
+const
+  Str_UIQ21 = 'UIQ 2.1';
+  Str_UIQ3  = 'UIQ 3';
+
 { Commands }
 
 const
@@ -51,6 +59,11 @@ const
 
 { Paths on the SDK }
 const
+  { UIQ 2 Paths }
+  Str_Path_UIQ2_ARM_BINUTILS = 'epoc32\gcc\bin\';
+  Str_Path_UIQ2_Makmake = 'epoc32\tools\makmake.pl';
+
+  { UIQ 3 Paths }
   Str_Path_CWTools = 'epoc32\tools\nokia_compiler\Symbian_Tools\Command_Line_Tools\';
   Str_Path_RComp = 'epoc32\tools\rcomp.exe';
   Str_Path_Cpp = 'epoc32\tools\scpp.exe';

+ 11 - 10
utils/mksymbian/mksymbian.pas

@@ -36,10 +36,10 @@ var
   opts: TMkSymbianOptions;
 begin
 
+  vProject := TProject.Create;
   vSDKUtil := TSDKUtil.Create;
   vCmdLine := TCmdLine.Create;
   vCompiler := TCompiler.Create;
-  vProject := TProject.Create;
 
   try
     vCmdLine.ParseCmdLineOptions(opts);
@@ -54,22 +54,26 @@ begin
         vProject.ParseFile;
         
         { compilation }
+        
         if CompareText(vProject.Language, STR_OPT_Cpp) = 0 then
          vCompiler.MakeBuildCpp
         else
          vCompiler.MakeBuildPascal;
 
-        { Main resource file }
+        if vSDKUtil.SDKVersion = sdkUIQ3 then
+        begin
+          { Main resource file }
         
-        vCompiler.BuildResource(vProject.MainResource);
+          vCompiler.BuildResource(vProject.MainResource);
 
-        vCompiler.InstallResource(vProject.MainResource);
+          vCompiler.InstallResource(vProject.MainResource);
 
-        { Registration resource file }
+          { Registration resource file }
         
-        vCompiler.BuildResource(vProject.RegResource);
+          vCompiler.BuildResource(vProject.RegResource);
 
-        vCompiler.RegisterInEmulator;
+          vCompiler.RegisterInEmulator;
+        end;
       end;
 
       stBuildBindings:
@@ -78,7 +82,6 @@ begin
 
         vCompiler.MakeBuildBindings;
       end;
-      
     end;
     
   finally
@@ -86,8 +89,6 @@ begin
     vSDKUtil.Free;
     vCompiler.Free;
     vProject.Free;
-
   end;
-  
 end.
 

+ 6 - 1
utils/mksymbian/projectparser.pas

@@ -40,7 +40,8 @@ type
   public
     opts: TMkSymbianOptions;
     { Main section }
-    ExeName, Language: string;
+    ExeName, Language, ProjectType, SDK, SDKVersion: string;
+    Emulator: Boolean;
     { FPC section }
     CompilerPath, AssemblerPath, RTLUnitsDir: string;
     { UIDs section }
@@ -94,6 +95,10 @@ begin
   try
     ExeName := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_ExeName, 'default.exe');
     Language := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_Language, 'Pascal');
+    ProjectType := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_ProjectType, 'EXE');
+    SDK := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_SDK, 'UIQ');
+    SDKVersion := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_SDKVersion, '2.1');
+    Emulator := IniFile.ReadBool(STR_PRJ_Files, STR_PRJ_Emulator, False);
 
     CompilerPath := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_CompilerPath, 'C:\Programas\fpc21\compiler\ppc386.exe');
     AssemblerPath := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_AssemblerPath, 'C:\Programas\lazarus20\fpc\2.1.5\bin\i386-win32\as.exe');

+ 31 - 17
utils/mksymbian/sdkutil.pas

@@ -29,21 +29,19 @@ unit sdkutil;
 interface
 
 uses
-  Classes, SysUtils, registry;
+  Classes, SysUtils, registry, constants;
 
 type
 
   { TSDKUtil }
 
   TSDKUtil = class(TObject)
-  private
-    vSDKFolder, vSDKPartialFolder: string;
   public
+    SDKFolder, SDKPartialFolder, StrSDKVersion: string;
+    SDKVersion: TSDKVersion;
     constructor Create;
-    procedure LocateSDK;
-
-    property SDKFolder: string read vSDKFolder;
-    property SDKPartialFolder: string read vSDKPartialFolder;
+    procedure LocateUIQ2SDK;
+    procedure LocateUIQ3SDK;
   end;
 
 var
@@ -51,9 +49,30 @@ var
 
 implementation
 
+uses projectparser;
+
 { TSDKUtil }
 
-procedure TSDKUtil.LocateSDK;
+constructor TSDKUtil.Create;
+begin
+  StrSDKVersion := vProject.SDK + ' ' + vProject.SDKVersion;
+
+  if StrSDKVersion = Str_UIQ21 then SDKVersion := sdkUIQ21
+  else if StrSDKVersion = Str_UIQ3 then SDKVersion := sdkUIQ3;
+
+  case SDKVersion of
+   sdkUIQ21: LocateUIQ2SDK;
+   sdkUIQ3:  LocateUIQ3SDK;
+  end;
+end;
+
+procedure TSDKUtil.LocateUIQ2SDK;
+begin
+  SDKPartialFolder := '\Programas\UIQ21\';
+  SDKFolder := 'C:' + SDKPartialFolder;
+end;
+
+procedure TSDKUtil.LocateUIQ3SDK;
 var
   Reg: TRegistry;
   BufferStr: string;
@@ -65,24 +84,19 @@ begin
     if Reg.OpenKey('\SOFTWARE\Symbian\UIQ\SDK\UIQ3SDK', False) then
     begin
       BufferStr := Reg.ReadString('InstallPath');
-      vSDKFolder := IncludeTrailingBackslash(BufferStr);
-      vSDKPartialFolder := Copy(vSDKFolder, 3, Length(vSDKFolder) - 2);
+      SDKFolder := IncludeTrailingBackslash(BufferStr);
+      SDKPartialFolder := Copy(SDKFolder, 3, Length(SDKFolder) - 2);
     end
     else
     begin
       WriteLn('  ERROR: Could not locate the SDK, using default values');
-      vSDKPartialFolder := '\Symbian\UIQ3SDK\';
-      vSDKFolder := 'C:' + vSDKPartialFolder;
+      SDKPartialFolder := '\Symbian\UIQ3SDK\';
+      SDKFolder := 'C:' + SDKPartialFolder;
     end;
   finally
     Reg.Free;
   end;
 end;
 
-constructor TSDKUtil.Create;
-begin
-  LocateSDK;
-end;
-
 end.