summaryrefslogtreecommitdiff
path: root/fpcsrc/utils/mksymbian/projectparser.pas
blob: 5054d379729786724ba1bb963d060bb96bc619f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
projectparser.pas

Parses the project file

Copyright (C) 2006-2007 Felipe Monteiro de Carvalho

This file is part of MkSymbian build tool.

MkSymbian is free software;
you can redistribute it and/or modify it under the
terms of the GNU General Public License version 2
as published by the Free Software Foundation.

MkSymbian is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Please note that the General Public License version 2 does not permit
incorporating MkSymbian into proprietary programs.
}
unit projectparser;

{$ifdef fpc}
  {$mode delphi}{$H+}
{$endif}

interface

uses
  Classes, SysUtils, IniFiles,
  constants;

type

  { TProject }

  TProject = class(TObject)
  public
    opts: TMkSymbianOptions;
    { Main section }
    ExeName, Language, ProjectType, SDK, SDKVersion: string;
    Emulator: Boolean;
    { FPC section }
    CompilerPath, AssemblerPath, RTLUnitsDir: string;
    { UIDs section }
    UID2, UID3: string;
    { Files section }
    MainSource, MainSourceNoExt, MainSourceAsm, MainSourceObj,
     MainResource, RegResource: string;
    { Objects section }
    ObjectFiles: TStringList;
  public
    constructor Create;
    destructor Destroy; override;
    procedure ParseFile;
  end;

var
  vProject: TProject;

implementation

{ TProject }

constructor TProject.Create;
begin
  inherited Create;
  
  ObjectFiles := TStringList.Create;
end;

destructor TProject.Destroy;
begin
  ObjectFiles.Free;

  inherited Destroy;
end;

{*******************************************************************
*  TProject.ParseFile ()
*
*  DESCRIPTION:    Parses the project file
*
*  PARAMETERS:     None
*
*  RETURNS:        Nothing
*
*******************************************************************}
procedure TProject.ParseFile;
var
  IniFile: TIniFile;
begin
  IniFile := TIniFile.Create(opts.ProjectFile);
  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');
    RTLUnitsDir := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_RTLUnitsDir, 'C:\Programas\fpc21\rtl\units\i386-symbian\');

    UID2 := IniFile.ReadString(STR_PRJ_UIDs, STR_PRJ_UID2, '0x100039CE');
    UID3 := IniFile.ReadString(STR_PRJ_UIDs, STR_PRJ_UID3, '0xE1000002');

    MainSource := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_MainSource, 'default.pas');
    MainSourceNoExt := ExtractFileExt(MainSource);
    MainSourceAsm := ChangeFileExt(MainSource, STR_ASSEMBLER_EXT);
    MainSourceObj := ChangeFileExt(MainSource, STR_OBJECT_EXT);
    MainResource := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_MainResource, 'default.rss');
    RegResource :=  IniFile.ReadString(STR_PRJ_Files, STR_PRJ_RegResource, 'default_reg.rss');
    
    IniFile.ReadSection(STR_PRJ_Objects, ObjectFiles);
  finally
    IniFile.Free;
  end;
end;

end.