compiler.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. {
  2. compiler.pas
  3. Compiling, Linking and Registering in Emulator methods
  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 compiler;
  18. {$ifdef fpc}
  19. {$mode delphi}{$H+}
  20. {$endif}
  21. interface
  22. uses
  23. Classes, SysUtils, Process,
  24. constants;
  25. type
  26. { TCompiler }
  27. TCompiler = class(TObject)
  28. private
  29. AProcess: TProcess;
  30. CurrentDirectory: string;
  31. MakeFolder, MakePartialFolder, BindingsUnitsFolder: string;
  32. public
  33. opts: TMkSymbianOptions;
  34. constructor Create;
  35. destructor Destroy; override;
  36. procedure FileCopy(source, dest: string);
  37. procedure MakeBuildPascal;
  38. procedure MakeBuildPascal_UIQ21_ARM;
  39. procedure MakeBuildPascal_UIQ3_Emulator;
  40. procedure MakeBuildCpp;
  41. procedure MakeBuildBindings;
  42. procedure BuildUIDFile;
  43. procedure BuildResource(AFileName: string);
  44. procedure InstallResource(AFileName: string);
  45. procedure RegisterInEmulator;
  46. end;
  47. var
  48. vCompiler: TCompiler;
  49. implementation
  50. uses sdkutil, projectparser;
  51. { TCompiler }
  52. {*******************************************************************
  53. * TCompiler.Create ()
  54. *
  55. * DESCRIPTION: Initializes the compiler controlling object
  56. *
  57. * PARAMETERS: None
  58. *
  59. * RETURNS: Nothing
  60. *
  61. *******************************************************************}
  62. constructor TCompiler.Create;
  63. begin
  64. inherited Create;
  65. AProcess := TProcess.Create(nil);
  66. CurrentDirectory := ExtractFilePath(ParamStr(0));
  67. MakePartialFolder := Copy(CurrentDirectory, 3, Length(CurrentDirectory) - 2);
  68. MakeFolder := IncludeTrailingBackslash(CurrentDirectory);
  69. { When compiling the bindings we use a relative directory to get the output dir }
  70. BindingsUnitsFolder := MakeFolder + '../../units/i386-symbian/';
  71. AProcess.Options := AProcess.Options + [poWaitOnExit];
  72. end;
  73. {*******************************************************************
  74. * TCompiler.Destroy ()
  75. *
  76. * DESCRIPTION: Finalizes the compiler controlling object
  77. *
  78. * PARAMETERS: None
  79. *
  80. * RETURNS: Nothing
  81. *
  82. *******************************************************************}
  83. destructor TCompiler.Destroy;
  84. begin
  85. AProcess.Free;
  86. inherited Destroy;
  87. end;
  88. {*******************************************************************
  89. * TCompiler.FileCopy ()
  90. *
  91. * DESCRIPTION: Copyes a file from source to dest
  92. *
  93. * PARAMETERS: source - Source file
  94. * dest - Destination file
  95. *
  96. * RETURNS: Nothing
  97. *
  98. *******************************************************************}
  99. procedure TCompiler.FileCopy(source, dest: string);
  100. var
  101. SourceStream, DestStream: TFileStream;
  102. begin
  103. WriteLn('');
  104. WriteLn('Copying file: ', source);
  105. WriteLn('To: ', dest);
  106. WriteLn('');
  107. SourceStream := TFileStream.Create(source, fmOpenRead);
  108. try
  109. DestStream := TFileStream.Create(dest, fmCreate);
  110. try
  111. DestStream.CopyFrom(SourceStream, 0);
  112. finally
  113. DestStream.Free;
  114. end;
  115. finally
  116. SourceStream.Free;
  117. end;
  118. end;
  119. {*******************************************************************
  120. * TCompiler.MakeBuildPascal ()
  121. *
  122. * DESCRIPTION: Builds and links a Object Pascal project
  123. *
  124. * PARAMETERS: None
  125. *
  126. * RETURNS: Nothing
  127. *
  128. *******************************************************************}
  129. procedure TCompiler.MakeBuildPascal;
  130. begin
  131. case vSDKUtil.SDKVersion of
  132. sdkUIQ21: MakeBuildPascal_UIQ21_ARM;
  133. sdkUIQ3: MakeBuildPascal_UIQ3_Emulator;
  134. end;
  135. end;
  136. procedure TCompiler.MakeBuildPascal_UIQ21_ARM;
  137. var
  138. EPOCSTATLINKUREL, EPOCLINKUREL, LIBSUREL: string;
  139. begin
  140. WriteLn('');
  141. WriteLn('Preparations for compiling');
  142. WriteLn('');
  143. { Creation of directories }
  144. { Compiling the source files }
  145. WriteLn('');
  146. WriteLn('Compiling the source files');
  147. WriteLn('');
  148. { Linking and library creation }
  149. WriteLn('');
  150. WriteLn('Linking and library creation');
  151. WriteLn('');
  152. EPOCSTATLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
  153. EPOCLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
  154. LIBSUREL := EPOCSTATLINKUREL + 'EDLLSTUB.LIB '
  155. + EPOCSTATLINKUREL + 'EGCC.LIB '
  156. + EPOCLINKUREL + 'EUSER.LIB '
  157. + EPOCLINKUREL + 'APPARC.LIB '
  158. + EPOCLINKUREL + 'CONE.LIB '
  159. + EPOCLINKUREL + 'EIKCORE.LIB '
  160. + EPOCLINKUREL + 'EIKCOCTL.LIB ';
  161. AProcess.CommandLine := 'dlltool -m thumb '
  162. + '--output-def "' + MakePartialFolder + 'HELLOWORLD.inf" "'
  163. + MakePartialFolder + 'HELLOWORLD.in" ';
  164. WriteLn('');
  165. WriteLn(AProcess.CommandLine);
  166. WriteLn('');
  167. AProcess.Execute;
  168. AProcess.CommandLine := 'perl -S ' + vSdkUtil.SDKFolder + Str_Path_UIQ2_Makmake
  169. + ' -Deffile "' + MakePartialFolder + 'HELLOWORLD.inf" -1 NewApplication__Fv "'
  170. + MakePartialFolder + 'HELLOWORLD.dev"';
  171. WriteLn('');
  172. WriteLn(AProcess.CommandLine);
  173. WriteLn('');
  174. AProcess.Execute;
  175. { -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.inf" }
  176. AProcess.CommandLine := 'dlltool -m thumb --def "'
  177. + MakePartialFolder + 'HELLOWORLD.def" --output-exp "'
  178. + MakePartialFolder + 'HELLOWORLD.exp" --dllname "HELLOWORLD[101f6163].APP"';
  179. WriteLn('');
  180. WriteLn(AProcess.CommandLine);
  181. WriteLn('');
  182. AProcess.Execute;
  183. AProcess.CommandLine := 'ld -s --thumb-entry _E32Dll '
  184. + '-u _E32Dll "' + MakePartialFolder + 'HELLOWORLD.exp" '
  185. + '--dll --base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
  186. + '-o "' + MakePartialFolder + 'HELLOWORLD.APP" "'
  187. + EPOCSTATLINKUREL + 'EDLL.LIB" '
  188. + '--whole-archive "' + MakePartialFolder + 'HELLOWORLD.in" '
  189. + '--no-whole-archive ' + LIBSUREL;
  190. WriteLn('');
  191. WriteLn(AProcess.CommandLine);
  192. WriteLn('');
  193. AProcess.Execute;
  194. { -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.exp"
  195. -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.APP"
  196. }
  197. AProcess.CommandLine := 'dlltool -m thumb '
  198. + '--def "' + MakePartialFolder + 'HELLOWORLD.def" '
  199. + '--dllname "HELLOWORLD[101f6163].APP" '
  200. + '--base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
  201. + '--output-exp ' + MakePartialFolder + 'HELLOWORLD.exp"';
  202. WriteLn('');
  203. WriteLn(AProcess.CommandLine);
  204. WriteLn('');
  205. AProcess.Execute;
  206. AProcess.CommandLine := 'ld -s --thumb-entry _E32Dll -u _E32Dll --dll "'
  207. + MakePartialFolder + 'HELLOWORLD.exp" -Map "'
  208. + MakePartialFolder + 'HELLOWORLD.APP.map" -o "'
  209. + MakePartialFolder + 'HELLOWORLD.APP" "'
  210. + EPOCSTATLINKUREL + 'EDLL.LIB" --whole-archive "'
  211. + MakePartialFolder + 'HELLOWORLD.in" --no-whole-archive '
  212. + LIBSUREL;
  213. WriteLn('');
  214. WriteLn(AProcess.CommandLine);
  215. WriteLn('');
  216. AProcess.Execute;
  217. AProcess.CommandLine := 'petran "'
  218. + MakePartialFolder + 'HELLOWORLD.APP" "'
  219. + MakePartialFolder + 'HELLOWORLD.APP" '
  220. + '-nocall -uid1 0x10000079 -uid2 0x100039ce -uid3 0x101f6163';
  221. WriteLn('');
  222. WriteLn(AProcess.CommandLine);
  223. WriteLn('');
  224. AProcess.Execute;
  225. end;
  226. procedure TCompiler.MakeBuildPascal_UIQ3_Emulator;
  227. var
  228. STR_LINK_FLAGSUDEB, STR_EPOCBLDUDEB, STR_LINK_OBJSUDEB: string;
  229. STR_FPC_RTL_OBJECTS: string;
  230. i: Integer;
  231. begin
  232. WriteLn('');
  233. WriteLn('Preparations for compiling');
  234. WriteLn('');
  235. // First command
  236. { AProcess.CommandLine := 'perl -S makmake.pl -D ' + MakePartialFolder + 'QHELLOWORLD WINSCW';
  237. WriteLn(AProcess.CommandLine);
  238. AProcess.Execute;}
  239. { Creation of directories }
  240. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\DATA\Z\private\10003a3f\apps');
  241. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\RELEASE\WINSCW\UDEB\Z\private\10003a3f\apps');
  242. ForceDirectories(MakeFolder + 'WINSCW\UDEB');
  243. { Compilation }
  244. WriteLn('');
  245. WriteLn('Compiling file ' + vProject.MainSource);
  246. WriteLn('');
  247. AProcess.CommandLine := vProject.CompilerPath + ' -a -s -Fu' + vProject.RTLUnitsDir +
  248. ' -Tsymbian QPasHello.pas';
  249. WriteLn(AProcess.CommandLine);
  250. AProcess.Execute;
  251. WriteLn('');
  252. WriteLn('Assembling file QPasHello.s');
  253. WriteLn('');
  254. AProcess.CommandLine := vProject.AssemblerPath + ' QPasHello.s -o QPasHello.o';
  255. WriteLn(AProcess.CommandLine);
  256. AProcess.Execute;
  257. { UID File }
  258. BuildUIDFile;
  259. { Linking }
  260. STR_LINK_FLAGSUDEB := '-msgstyle gcc -stdlib "' +
  261. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EEXE.LIB" -m' +
  262. ' "?_E32Bootstrap@@YGXXZ" -subsystem windows -g ' +
  263. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EUSER.LIB ' +
  264. '-o "' + MakeFolder + 'QPasHello.exe" -noimplib';
  265. STR_EPOCBLDUDEB := MakeFolder + 'WINSCW\UDEB';
  266. STR_LINK_OBJSUDEB :=
  267. ' ' + MakeFolder + UID_OBJECT_FILENAME;
  268. for i := 0 to vProject.ObjectFiles.Count - 1 do
  269. STR_LINK_OBJSUDEB := STR_LINK_OBJSUDEB +
  270. ' ' + MakeFolder + vProject.ObjectFiles.Strings[i];
  271. STR_FPC_RTL_OBJECTS :=
  272. ' ' + vProject.RTLUnitsDir + 'system.o' +
  273. ' ' + vProject.RTLUnitsDir + 'symbian.o' +
  274. ' ' + vProject.RTLUnitsDir + 'ctypes.o' +
  275. ' ' + vProject.RTLUnitsDir + 'objpas.o' +
  276. ' ' + vProject.RTLUnitsDir + 'pbeexe.o';
  277. WriteLn('');
  278. WriteLn('Linking stage');
  279. WriteLn('');
  280. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_CWTools +
  281. 'mwldsym2.exe ' + STR_LINK_FLAGSUDEB +
  282. ' -l ' + MakeFolder +
  283. ' -search ' + STR_LINK_OBJSUDEB + STR_FPC_RTL_OBJECTS;
  284. WriteLn(AProcess.CommandLine);
  285. AProcess.Execute;
  286. FileCopy(MakeFolder + 'QPasHello.exe',
  287. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\' + 'QPasHello.exe');
  288. end;
  289. {*******************************************************************
  290. * TCompiler.MakeBuildCpp ()
  291. *
  292. * DESCRIPTION: Builds and links a C++ project
  293. *
  294. * PARAMETERS: None
  295. *
  296. * RETURNS: Nothing
  297. *
  298. *******************************************************************}
  299. procedure TCompiler.MakeBuildCpp;
  300. var
  301. STR_LINK_FLAGSUDEB, STR_EPOCBLDUDEB, STR_LINK_OBJSUDEB,
  302. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB: string;
  303. begin
  304. WriteLn('');
  305. WriteLn('Preparations for compiling');
  306. WriteLn('');
  307. // First command
  308. AProcess.CommandLine := 'perl -S makmake.pl -D ' + MakePartialFolder + 'QHELLOWORLD WINSCW';
  309. WriteLn(AProcess.CommandLine);
  310. AProcess.Execute;
  311. { Creation of directories }
  312. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\DATA\Z\private\10003a3f\apps');
  313. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\RELEASE\WINSCW\UDEB\Z\private\10003a3f\apps');
  314. ForceDirectories(MakeFolder + 'WINSCW\UDEB');
  315. // TODO: Check if this can be safely removed
  316. // ForceDirectories(MakeFolder + 'QHelloWorld\WINSCW');
  317. { Compilation }
  318. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  319. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  320. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  321. STR_INCDIR := '-cwd source -i- ' +
  322. '-i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include" ' +
  323. '-i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant" ' +
  324. '-i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ " ' +
  325. '-include "UIQ_3.0.hrh"';
  326. STR_CWUDEB := 'mwccsym2.exe -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  327. WriteLn('');
  328. WriteLn('Compiling file ' + vProject.MainSource);
  329. WriteLn('');
  330. AProcess.CommandLine := STR_CWUDEB +
  331. ' -o "' + MakeFolder + 'WINSCW\UDEB\' + vProject.MainSourceNoExt + '.o"' +
  332. ' -c "' + MakeFolder + 'src\' + vProject.MainSource + '"';
  333. WriteLn(AProcess.CommandLine);
  334. AProcess.Execute;
  335. { UID File }
  336. BuildUIDFile;
  337. { Linking }
  338. STR_LINK_FLAGSUDEB := '-msgstyle gcc' +
  339. ' -stdlib "' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EEXE.LIB"' +
  340. ' -m "?_E32Bootstrap@@YGXXZ" -subsystem windows' +
  341. ' -g ' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EUSER.LIB' +
  342. ' -o "' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\' + vProject.MainSourceNoExt + '.exe"' +
  343. ' -noimplib';
  344. STR_EPOCBLDUDEB := MakeFolder + 'WINSCW\UDEB';
  345. STR_LINK_OBJSUDEB := vProject.MainSourceNoExt + '.o ' + UID_OBJECT_FILENAME;
  346. WriteLn('');
  347. WriteLn('Linking stage');
  348. WriteLn('');
  349. AProcess.CommandLine := 'mwldsym2.exe ' + STR_LINK_FLAGSUDEB +
  350. ' -l ' + STR_EPOCBLDUDEB +
  351. ' -search ' + STR_LINK_OBJSUDEB;
  352. WriteLn(AProcess.CommandLine);
  353. AProcess.Execute;
  354. end;
  355. {*******************************************************************
  356. * TCompiler.MakeBuildBindings ()
  357. *
  358. * DESCRIPTION: Builds and links the C interface for the symbian libraries
  359. *
  360. * Note the we use a output directory relative to the current directory
  361. *
  362. * PARAMETERS: None
  363. *
  364. * RETURNS: Nothing
  365. *
  366. *******************************************************************}
  367. procedure TCompiler.MakeBuildBindings;
  368. var
  369. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB, STR_CWCOMPILER: string;
  370. begin
  371. { Makes sure that the output directory exists }
  372. SysUtils.ForceDirectories(BindingsUnitsFolder);
  373. { Compilation }
  374. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  375. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  376. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  377. STR_INCDIR := '-cwd source -i-' +
  378. ' -i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include"' +
  379. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant"' +
  380. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ "' +
  381. ' -include "UIQ_3.0.hrh"';
  382. STR_CWCOMPILER := vSDKUtil.SDKFolder + Str_Path_CWTools + 'mwccsym2.exe';
  383. STR_CWUDEB := STR_CWCOMPILER + ' -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  384. WriteLn('');
  385. WriteLn('Compiling file pbeexe.cpp');
  386. WriteLn('');
  387. AProcess.CommandLine := STR_CWUDEB +
  388. ' -o "' + BindingsUnitsFolder + 'pbeexe.o" ' +
  389. '-c "' + MakePartialFolder + 'pbeexe.cpp"';
  390. WriteLn(AProcess.CommandLine);
  391. AProcess.Execute;
  392. end;
  393. {*******************************************************************
  394. * TCompiler.BuildUIDFile ()
  395. *
  396. * DESCRIPTION: Generates and compiles a UID file
  397. *
  398. * PARAMETERS: None
  399. *
  400. * RETURNS: Nothing
  401. *
  402. *******************************************************************}
  403. procedure TCompiler.BuildUIDFile;
  404. var
  405. Str_UIDFile: string;
  406. UIDFile: TFileStream;
  407. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB, STR_CWCOMPILER: string;
  408. begin
  409. { First creates the UID file }
  410. WriteLn('');
  411. WriteLn('Creating UID file');
  412. WriteLn('');
  413. Str_UIDFile :=
  414. '// mksymbian-generated uid source file' + LineEnding +
  415. '#include <e32cmn.h>' + LineEnding +
  416. '#pragma data_seg(".SYMBIAN")' + LineEnding +
  417. '__EMULATOR_IMAGE_HEADER2(0x1000007a,' + vProject.UID2 + ',' + vProject.UID3 +
  418. ',EPriorityForeground,0x00000000u,0x00000000u,0x01000001,0,0x00010000,0)' + LineEnding +
  419. '#pragma data_seg()' + LineEnding;
  420. UIDFile := TFileStream.Create(UID_SOURCE_FILENAME, fmCreate);
  421. try
  422. UIDFile.Write(Pointer(Str_UIDFile)^, Length(Str_UIDFile));
  423. finally
  424. UIDFile.Free;
  425. end;
  426. { Compilation }
  427. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  428. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  429. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  430. STR_INCDIR := '-cwd source -i- ' +
  431. ' -i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include" ' +
  432. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant" ' +
  433. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ "' +
  434. ' -include "UIQ_3.0.hrh"';
  435. STR_CWCOMPILER := vSDKUtil.SDKFolder + Str_Path_CWTools + 'mwccsym2.exe';
  436. STR_CWUDEB := STR_CWCOMPILER + ' -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  437. WriteLn('');
  438. WriteLn('Compiling file ' + UID_SOURCE_FILENAME);
  439. WriteLn('');
  440. AProcess.CommandLine := STR_CWUDEB +
  441. ' -o "' + MakeFolder + UID_OBJECT_FILENAME + '"' +
  442. ' -c "' + MakeFolder + UID_SOURCE_FILENAME + '"';
  443. WriteLn(AProcess.CommandLine);
  444. AProcess.Execute;
  445. end;
  446. {*******************************************************************
  447. * TCompiler.BuildResource ()
  448. *
  449. * DESCRIPTION: Builds a resource file
  450. *
  451. * PARAMETERS: None
  452. *
  453. * RETURNS: Nothing
  454. *
  455. *******************************************************************}
  456. procedure TCompiler.BuildResource(AFileName: string);
  457. begin
  458. WriteLn('');
  459. WriteLn('Preprocessing resource file: ' + AFileName);
  460. WriteLn('');
  461. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_Cpp +
  462. ' -lang-c++' +
  463. ' -I ' + vSDKUtil.SDKPartialFolder + 'EPOC32\include' +
  464. ' -I ' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant' +
  465. ' ' + MakeFolder + AFileName +
  466. ' ' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_TMP_EXT);
  467. WriteLn(AProcess.CommandLine);
  468. AProcess.Execute;
  469. WriteLn('');
  470. WriteLn('Building resource file: ' + AFileName);
  471. WriteLn('');
  472. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_RComp +
  473. ' -v -u' +
  474. ' -o"' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_EXT) + '"' +
  475. ' -s"' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_TMP_EXT) + '"';
  476. WriteLn(AProcess.CommandLine);
  477. WriteLn('');
  478. System.Flush(System.StdOut);
  479. AProcess.Execute;
  480. end;
  481. {*******************************************************************
  482. * TCompiler.InstallResource ()
  483. *
  484. * DESCRIPTION: Install a resource file
  485. *
  486. * PARAMETERS: None
  487. *
  488. * RETURNS: Nothing
  489. *
  490. *******************************************************************}
  491. procedure TCompiler.InstallResource(AFileName: string);
  492. var
  493. StrFrom, StrTo: string;
  494. begin
  495. WriteLn('');
  496. WriteLn('Installing resource file: ', AFileName);
  497. WriteLn('');
  498. StrFrom := MakeFolder + ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  499. StrTo := vSDKUtil.SDKFolder + Str_Path_Resource_Files +
  500. ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  501. FileCopy(StrFrom, StrTo);
  502. end;
  503. {*******************************************************************
  504. * TCompiler.RegisterInEmulator ()
  505. *
  506. * DESCRIPTION: Registers a software in the emulator
  507. * At this point the resource file must already be compiled
  508. *
  509. * PARAMETERS: None
  510. *
  511. * RETURNS: Nothing
  512. *
  513. *******************************************************************}
  514. procedure TCompiler.RegisterInEmulator;
  515. var
  516. StrFrom, StrTo: string;
  517. begin
  518. WriteLn('');
  519. WriteLn('Registering the software on the emulator');
  520. WriteLn('');
  521. StrFrom := MakeFolder + ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  522. StrTo := vSDKUtil.SDKFolder + Str_Path_Emulator_Registration +
  523. ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  524. FileCopy(StrFrom, StrTo);
  525. end;
  526. end.