2
0

projectparser.pas 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {
  2. projectparser.pas
  3. Parses the project file
  4. Copyright (C) 2006-2007 Felipe Monteiro de Carvalho
  5. This file is part of MkSymbian build tool.
  6. MkSymbian is free software;
  7. you can redistribute it and/or modify it under the
  8. terms of the GNU General Public License version 2
  9. as published by the Free Software Foundation.
  10. MkSymbian is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even
  12. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE. See the GNU General Public License for more details.
  14. Please note that the General Public License version 2 does not permit
  15. incorporating MkSymbian into proprietary programs.
  16. }
  17. unit projectparser;
  18. {$ifdef fpc}
  19. {$mode delphi}{$H+}
  20. {$endif}
  21. interface
  22. uses
  23. Classes, SysUtils, IniFiles,
  24. constants;
  25. type
  26. { TProject }
  27. TProject = class(TObject)
  28. public
  29. opts: TMkSymbianOptions;
  30. { Main section }
  31. ExeName, Language, ProjectType, SDK, SDKVersion: string;
  32. Emulator: Boolean;
  33. { FPC section }
  34. CompilerPath, AssemblerPath, RTLUnitsDir: string;
  35. { UIDs section }
  36. UID2, UID3: string;
  37. { Files section }
  38. MainSource, MainSourceNoExt, MainSourceAsm, MainSourceObj,
  39. MainResource, RegResource: string;
  40. { Objects section }
  41. ObjectFiles: TStringList;
  42. public
  43. constructor Create;
  44. destructor Destroy; override;
  45. procedure ParseFile;
  46. end;
  47. var
  48. vProject: TProject;
  49. implementation
  50. { TProject }
  51. constructor TProject.Create;
  52. begin
  53. inherited Create;
  54. ObjectFiles := TStringList.Create;
  55. end;
  56. destructor TProject.Destroy;
  57. begin
  58. ObjectFiles.Free;
  59. inherited Destroy;
  60. end;
  61. {*******************************************************************
  62. * TProject.ParseFile ()
  63. *
  64. * DESCRIPTION: Parses the project file
  65. *
  66. * PARAMETERS: None
  67. *
  68. * RETURNS: Nothing
  69. *
  70. *******************************************************************}
  71. procedure TProject.ParseFile;
  72. var
  73. IniFile: TIniFile;
  74. begin
  75. IniFile := TIniFile.Create(opts.ProjectFile);
  76. try
  77. ExeName := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_ExeName, 'default.exe');
  78. Language := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_Language, 'Pascal');
  79. ProjectType := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_ProjectType, 'EXE');
  80. SDK := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_SDK, 'UIQ');
  81. SDKVersion := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_SDKVersion, '2.1');
  82. Emulator := IniFile.ReadBool(STR_PRJ_Files, STR_PRJ_Emulator, False);
  83. CompilerPath := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_CompilerPath, 'C:\Programas\fpc21\compiler\ppc386.exe');
  84. AssemblerPath := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_AssemblerPath, 'C:\Programas\lazarus20\fpc\2.1.5\bin\i386-win32\as.exe');
  85. RTLUnitsDir := IniFile.ReadString(STR_PRJ_FPC, STR_PRJ_RTLUnitsDir, 'C:\Programas\fpc21\rtl\units\i386-symbian\');
  86. UID2 := IniFile.ReadString(STR_PRJ_UIDs, STR_PRJ_UID2, '0x100039CE');
  87. UID3 := IniFile.ReadString(STR_PRJ_UIDs, STR_PRJ_UID3, '0xE1000002');
  88. MainSource := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_MainSource, 'default.pas');
  89. MainSourceNoExt := ExtractFileExt(MainSource);
  90. MainSourceAsm := ChangeFileExt(MainSource, STR_ASSEMBLER_EXT);
  91. MainSourceObj := ChangeFileExt(MainSource, STR_OBJECT_EXT);
  92. MainResource := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_MainResource, 'default.rss');
  93. RegResource := IniFile.ReadString(STR_PRJ_Files, STR_PRJ_RegResource, 'default_reg.rss');
  94. IniFile.ReadSection(STR_PRJ_Objects, ObjectFiles);
  95. finally
  96. IniFile.Free;
  97. end;
  98. end;
  99. end.