2
0

compiler.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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 file ' + vProject.MainSource);
  147. WriteLn('');
  148. AProcess.CommandLine := vProject.CompilerPath + ' -a -s -Fu' + vProject.RTLUnitsDir +
  149. ' -Tsymbian ' + vProject.MainSource;
  150. WriteLn(AProcess.CommandLine);
  151. AProcess.Execute;
  152. WriteLn('');
  153. WriteLn('Assembling file '+ vProject.MainSourceAsm);
  154. WriteLn('');
  155. AProcess.CommandLine := vProject.AssemblerPath + ' ' +
  156. vProject.MainSourceAsm + ' -o ' + vProject.MainSourceObj;
  157. WriteLn(AProcess.CommandLine);
  158. AProcess.Execute;
  159. { Linking and library creation }
  160. WriteLn('');
  161. WriteLn('Linking and library creation');
  162. WriteLn('');
  163. EPOCSTATLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
  164. EPOCLINKUREL := vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\THUMB\UREL\';
  165. LIBSUREL := EPOCSTATLINKUREL + 'EDLLSTUB.LIB '
  166. + EPOCSTATLINKUREL + 'EGCC.LIB '
  167. + EPOCLINKUREL + 'EUSER.LIB '
  168. + EPOCLINKUREL + 'APPARC.LIB '
  169. + EPOCLINKUREL + 'CONE.LIB '
  170. + EPOCLINKUREL + 'EIKCORE.LIB '
  171. + EPOCLINKUREL + 'EIKCOCTL.LIB ';
  172. AProcess.CommandLine := 'dlltool -m thumb '
  173. + '--output-def "' + MakePartialFolder + 'HELLOWORLD.inf" "'
  174. + MakePartialFolder + 'HELLOWORLD.in" ';
  175. WriteLn('');
  176. WriteLn(AProcess.CommandLine);
  177. WriteLn('');
  178. AProcess.Execute;
  179. AProcess.CommandLine := 'perl -S ' + vSdkUtil.SDKFolder + Str_Path_UIQ2_Makmake
  180. + ' -Deffile "' + MakePartialFolder + 'HELLOWORLD.inf" -1 NewApplication__Fv "'
  181. + MakePartialFolder + 'HELLOWORLD.dev"';
  182. WriteLn('');
  183. WriteLn(AProcess.CommandLine);
  184. WriteLn('');
  185. AProcess.Execute;
  186. { -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.inf" }
  187. AProcess.CommandLine := 'dlltool -m thumb --def "'
  188. + MakePartialFolder + 'HELLOWORLD.def" --output-exp "'
  189. + MakePartialFolder + 'HELLOWORLD.exp" --dllname "HELLOWORLD[101f6163].APP"';
  190. WriteLn('');
  191. WriteLn(AProcess.CommandLine);
  192. WriteLn('');
  193. AProcess.Execute;
  194. AProcess.CommandLine := 'ld -s --thumb-entry _E32Dll '
  195. + '-u _E32Dll "' + MakePartialFolder + 'HELLOWORLD.exp" '
  196. + '--dll --base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
  197. + '-o "' + MakePartialFolder + 'HELLOWORLD.APP" "'
  198. + EPOCSTATLINKUREL + 'EDLL.LIB" '
  199. + '--whole-archive "' + MakePartialFolder + 'HELLOWORLD.in" '
  200. + '--no-whole-archive ' + LIBSUREL;
  201. WriteLn('');
  202. WriteLn(AProcess.CommandLine);
  203. WriteLn('');
  204. AProcess.Execute;
  205. { -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.exp"
  206. -$(ERASE) "$(EPOCBLDUREL)\HELLOWORLD.APP"
  207. }
  208. AProcess.CommandLine := 'dlltool -m thumb '
  209. + '--def "' + MakePartialFolder + 'HELLOWORLD.def" '
  210. + '--dllname "HELLOWORLD[101f6163].APP" '
  211. + '--base-file "' + MakePartialFolder + 'HELLOWORLD.bas" '
  212. + '--output-exp ' + MakePartialFolder + 'HELLOWORLD.exp"';
  213. WriteLn('');
  214. WriteLn(AProcess.CommandLine);
  215. WriteLn('');
  216. AProcess.Execute;
  217. AProcess.CommandLine := 'ld -s --thumb-entry _E32Dll -u _E32Dll --dll "'
  218. + MakePartialFolder + 'HELLOWORLD.exp" -Map "'
  219. + MakePartialFolder + 'HELLOWORLD.APP.map" -o "'
  220. + MakePartialFolder + 'HELLOWORLD.APP" "'
  221. + EPOCSTATLINKUREL + 'EDLL.LIB" --whole-archive "'
  222. + MakePartialFolder + 'HELLOWORLD.in" --no-whole-archive '
  223. + LIBSUREL;
  224. WriteLn('');
  225. WriteLn(AProcess.CommandLine);
  226. WriteLn('');
  227. AProcess.Execute;
  228. AProcess.CommandLine := 'petran "'
  229. + MakePartialFolder + 'HELLOWORLD.APP" "'
  230. + MakePartialFolder + 'HELLOWORLD.APP" '
  231. + '-nocall -uid1 0x10000079 -uid2 0x100039ce -uid3 0x101f6163';
  232. WriteLn('');
  233. WriteLn(AProcess.CommandLine);
  234. WriteLn('');
  235. AProcess.Execute;
  236. end;
  237. procedure TCompiler.MakeBuildPascal_UIQ3_Emulator;
  238. var
  239. STR_LINK_FLAGSUDEB, STR_EPOCBLDUDEB, STR_LINK_OBJSUDEB: string;
  240. STR_FPC_RTL_OBJECTS: string;
  241. i: Integer;
  242. begin
  243. WriteLn('');
  244. WriteLn('Preparations for compiling');
  245. WriteLn('');
  246. // First command
  247. { AProcess.CommandLine := 'perl -S makmake.pl -D ' + MakePartialFolder + 'QHELLOWORLD WINSCW';
  248. WriteLn(AProcess.CommandLine);
  249. AProcess.Execute;}
  250. { Creation of directories }
  251. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\DATA\Z\private\10003a3f\apps');
  252. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\RELEASE\WINSCW\UDEB\Z\private\10003a3f\apps');
  253. ForceDirectories(MakeFolder + 'WINSCW\UDEB');
  254. { Compilation }
  255. WriteLn('');
  256. WriteLn('Compiling file ' + vProject.MainSource);
  257. WriteLn('');
  258. AProcess.CommandLine := vProject.CompilerPath + ' -a -s -Fu' + vProject.RTLUnitsDir +
  259. ' -Tsymbian ' + vProject.MainSource;
  260. WriteLn(AProcess.CommandLine);
  261. AProcess.Execute;
  262. WriteLn('');
  263. WriteLn('Assembling file '+ vProject.MainSourceAsm);
  264. WriteLn('');
  265. AProcess.CommandLine := vProject.AssemblerPath + ' ' +
  266. vProject.MainSourceAsm + ' -o ' + vProject.MainSourceObj;
  267. WriteLn(AProcess.CommandLine);
  268. AProcess.Execute;
  269. { UID File }
  270. BuildUIDFile;
  271. { Linking }
  272. STR_LINK_FLAGSUDEB := '-msgstyle gcc -stdlib "' +
  273. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EEXE.LIB" -m' +
  274. ' "?_E32Bootstrap@@YGXXZ" -subsystem windows -g ' +
  275. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EUSER.LIB ' +
  276. '-o "' + MakeFolder + 'QPasHello.exe" -noimplib';
  277. STR_EPOCBLDUDEB := MakeFolder + 'WINSCW\UDEB';
  278. STR_LINK_OBJSUDEB :=
  279. ' ' + MakeFolder + UID_OBJECT_FILENAME;
  280. for i := 0 to vProject.ObjectFiles.Count - 1 do
  281. STR_LINK_OBJSUDEB := STR_LINK_OBJSUDEB +
  282. ' ' + MakeFolder + vProject.ObjectFiles.Strings[i];
  283. STR_FPC_RTL_OBJECTS :=
  284. ' ' + vProject.RTLUnitsDir + 'system.o' +
  285. ' ' + vProject.RTLUnitsDir + 'symbian.o' +
  286. ' ' + vProject.RTLUnitsDir + 'ctypes.o' +
  287. ' ' + vProject.RTLUnitsDir + 'objpas.o' +
  288. ' ' + vProject.RTLUnitsDir + 'pbeexe.o';
  289. WriteLn('');
  290. WriteLn('Linking stage');
  291. WriteLn('');
  292. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_CWTools +
  293. 'mwldsym2.exe ' + STR_LINK_FLAGSUDEB +
  294. ' -l ' + MakeFolder +
  295. ' -search ' + STR_LINK_OBJSUDEB + STR_FPC_RTL_OBJECTS;
  296. WriteLn(AProcess.CommandLine);
  297. AProcess.Execute;
  298. FileCopy(MakeFolder + 'QPasHello.exe',
  299. vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\' + 'QPasHello.exe');
  300. end;
  301. {*******************************************************************
  302. * TCompiler.MakeBuildCpp ()
  303. *
  304. * DESCRIPTION: Builds and links a C++ project
  305. *
  306. * PARAMETERS: None
  307. *
  308. * RETURNS: Nothing
  309. *
  310. *******************************************************************}
  311. procedure TCompiler.MakeBuildCpp;
  312. var
  313. STR_LINK_FLAGSUDEB, STR_EPOCBLDUDEB, STR_LINK_OBJSUDEB,
  314. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB: string;
  315. begin
  316. WriteLn('');
  317. WriteLn('Preparations for compiling');
  318. WriteLn('');
  319. // First command
  320. AProcess.CommandLine := 'perl -S makmake.pl -D ' + MakePartialFolder + 'QHELLOWORLD WINSCW';
  321. WriteLn(AProcess.CommandLine);
  322. AProcess.Execute;
  323. { Creation of directories }
  324. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\DATA\Z\private\10003a3f\apps');
  325. ForceDirectories(vSDKUtil.SDKFolder + 'EPOC32\RELEASE\WINSCW\UDEB\Z\private\10003a3f\apps');
  326. ForceDirectories(MakeFolder + 'WINSCW\UDEB');
  327. // TODO: Check if this can be safely removed
  328. // ForceDirectories(MakeFolder + 'QHelloWorld\WINSCW');
  329. { Compilation }
  330. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  331. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  332. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  333. STR_INCDIR := '-cwd source -i- ' +
  334. '-i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include" ' +
  335. '-i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant" ' +
  336. '-i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ " ' +
  337. '-include "UIQ_3.0.hrh"';
  338. STR_CWUDEB := 'mwccsym2.exe -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  339. WriteLn('');
  340. WriteLn('Compiling file ' + vProject.MainSource);
  341. WriteLn('');
  342. AProcess.CommandLine := STR_CWUDEB +
  343. ' -o "' + MakeFolder + 'WINSCW\UDEB\' + vProject.MainSourceNoExt + '.o"' +
  344. ' -c "' + MakeFolder + 'src\' + vProject.MainSource + '"';
  345. WriteLn(AProcess.CommandLine);
  346. AProcess.Execute;
  347. { UID File }
  348. BuildUIDFile;
  349. { Linking }
  350. STR_LINK_FLAGSUDEB := '-msgstyle gcc' +
  351. ' -stdlib "' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EEXE.LIB"' +
  352. ' -m "?_E32Bootstrap@@YGXXZ" -subsystem windows' +
  353. ' -g ' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\EUSER.LIB' +
  354. ' -o "' + vSDKUtil.SDKPartialFolder + 'EPOC32\RELEASE\WINSCW\UDEB\' + vProject.MainSourceNoExt + '.exe"' +
  355. ' -noimplib';
  356. STR_EPOCBLDUDEB := MakeFolder + 'WINSCW\UDEB';
  357. STR_LINK_OBJSUDEB := vProject.MainSourceNoExt + '.o ' + UID_OBJECT_FILENAME;
  358. WriteLn('');
  359. WriteLn('Linking stage');
  360. WriteLn('');
  361. AProcess.CommandLine := 'mwldsym2.exe ' + STR_LINK_FLAGSUDEB +
  362. ' -l ' + STR_EPOCBLDUDEB +
  363. ' -search ' + STR_LINK_OBJSUDEB;
  364. WriteLn(AProcess.CommandLine);
  365. AProcess.Execute;
  366. end;
  367. {*******************************************************************
  368. * TCompiler.MakeBuildBindings ()
  369. *
  370. * DESCRIPTION: Builds and links the C interface for the symbian libraries
  371. *
  372. * Note the we use a output directory relative to the current directory
  373. *
  374. * PARAMETERS: None
  375. *
  376. * RETURNS: Nothing
  377. *
  378. *******************************************************************}
  379. procedure TCompiler.MakeBuildBindings;
  380. var
  381. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB, STR_CWCOMPILER: string;
  382. begin
  383. { Makes sure that the output directory exists }
  384. SysUtils.ForceDirectories(BindingsUnitsFolder);
  385. { Compilation }
  386. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  387. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  388. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  389. STR_INCDIR := '-cwd source -i-' +
  390. ' -i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include"' +
  391. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant"' +
  392. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ "' +
  393. ' -include "UIQ_3.0.hrh"';
  394. STR_CWCOMPILER := vSDKUtil.SDKFolder + Str_Path_CWTools + 'mwccsym2.exe';
  395. STR_CWUDEB := STR_CWCOMPILER + ' -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  396. WriteLn('');
  397. WriteLn('Compiling file pbeexe.cpp');
  398. WriteLn('');
  399. AProcess.CommandLine := STR_CWUDEB +
  400. ' -o "' + BindingsUnitsFolder + 'pbeexe.o" ' +
  401. '-c "' + MakePartialFolder + 'pbeexe.cpp"';
  402. WriteLn(AProcess.CommandLine);
  403. AProcess.Execute;
  404. end;
  405. {*******************************************************************
  406. * TCompiler.BuildUIDFile ()
  407. *
  408. * DESCRIPTION: Generates and compiles a UID file
  409. *
  410. * PARAMETERS: None
  411. *
  412. * RETURNS: Nothing
  413. *
  414. *******************************************************************}
  415. procedure TCompiler.BuildUIDFile;
  416. var
  417. Str_UIDFile: string;
  418. UIDFile: TFileStream;
  419. STR_CWUFLAGS, STR_CWDEFS, STR_INCDIR, STR_CWUDEB, STR_CWCOMPILER: string;
  420. begin
  421. { First creates the UID file }
  422. WriteLn('');
  423. WriteLn('Creating UID file');
  424. WriteLn('');
  425. Str_UIDFile :=
  426. '// mksymbian-generated uid source file' + LineEnding +
  427. '#include <e32cmn.h>' + LineEnding +
  428. '#pragma data_seg(".SYMBIAN")' + LineEnding +
  429. '__EMULATOR_IMAGE_HEADER2(0x1000007a,' + vProject.UID2 + ',' + vProject.UID3 +
  430. ',EPriorityForeground,0x00000000u,0x00000000u,0x01000001,0,0x00010000,0)' + LineEnding +
  431. '#pragma data_seg()' + LineEnding;
  432. UIDFile := TFileStream.Create(UID_SOURCE_FILENAME, fmCreate);
  433. try
  434. UIDFile.Write(Pointer(Str_UIDFile)^, Length(Str_UIDFile));
  435. finally
  436. UIDFile.Free;
  437. end;
  438. { Compilation }
  439. STR_CWUFLAGS := '-wchar_t off -align 4 -warnings on ' +
  440. '-w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostdinc';
  441. STR_CWDEFS := '-d "__SYMBIAN32__" -d "__CW32__" -d "__WINS__" -d "__WINSCW__" -d "__EXE__" -d "__SUPPORT_CPP_EXCEPTIONS__" ';
  442. STR_INCDIR := '-cwd source -i- ' +
  443. ' -i "' + vSDKUtil.SDKPartialFolder + 'EPOC32\include" ' +
  444. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant" ' +
  445. ' -i "' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant\ "' +
  446. ' -include "UIQ_3.0.hrh"';
  447. STR_CWCOMPILER := vSDKUtil.SDKFolder + Str_Path_CWTools + 'mwccsym2.exe';
  448. STR_CWUDEB := STR_CWCOMPILER + ' -g -O0 -inline off ' + STR_CWUFLAGS + ' -d _DEBUG -d _UNICODE ' + STR_CWDEFS + STR_INCDIR;
  449. WriteLn('');
  450. WriteLn('Compiling file ' + UID_SOURCE_FILENAME);
  451. WriteLn('');
  452. AProcess.CommandLine := STR_CWUDEB +
  453. ' -o "' + MakeFolder + UID_OBJECT_FILENAME + '"' +
  454. ' -c "' + MakeFolder + UID_SOURCE_FILENAME + '"';
  455. WriteLn(AProcess.CommandLine);
  456. AProcess.Execute;
  457. end;
  458. {*******************************************************************
  459. * TCompiler.BuildResource ()
  460. *
  461. * DESCRIPTION: Builds a resource file
  462. *
  463. * PARAMETERS: None
  464. *
  465. * RETURNS: Nothing
  466. *
  467. *******************************************************************}
  468. procedure TCompiler.BuildResource(AFileName: string);
  469. begin
  470. WriteLn('');
  471. WriteLn('Preprocessing resource file: ' + AFileName);
  472. WriteLn('');
  473. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_Cpp +
  474. ' -lang-c++' +
  475. ' -I ' + vSDKUtil.SDKPartialFolder + 'EPOC32\include' +
  476. ' -I ' + vSDKUtil.SDKPartialFolder + 'epoc32\include\variant' +
  477. ' ' + MakeFolder + AFileName +
  478. ' ' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_TMP_EXT);
  479. WriteLn(AProcess.CommandLine);
  480. AProcess.Execute;
  481. WriteLn('');
  482. WriteLn('Building resource file: ' + AFileName);
  483. WriteLn('');
  484. AProcess.CommandLine := vSDKUtil.SDKFolder + Str_Path_RComp +
  485. ' -v -u' +
  486. ' -o"' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_EXT) + '"' +
  487. ' -s"' + MakeFolder + ChangeFileExt(AFileName, STR_RESOURCE_TMP_EXT) + '"';
  488. WriteLn(AProcess.CommandLine);
  489. WriteLn('');
  490. System.Flush(System.StdOut);
  491. AProcess.Execute;
  492. end;
  493. {*******************************************************************
  494. * TCompiler.InstallResource ()
  495. *
  496. * DESCRIPTION: Install a resource file
  497. *
  498. * PARAMETERS: None
  499. *
  500. * RETURNS: Nothing
  501. *
  502. *******************************************************************}
  503. procedure TCompiler.InstallResource(AFileName: string);
  504. var
  505. StrFrom, StrTo: string;
  506. begin
  507. WriteLn('');
  508. WriteLn('Installing resource file: ', AFileName);
  509. WriteLn('');
  510. StrFrom := MakeFolder + ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  511. StrTo := vSDKUtil.SDKFolder + Str_Path_Resource_Files +
  512. ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  513. FileCopy(StrFrom, StrTo);
  514. end;
  515. {*******************************************************************
  516. * TCompiler.RegisterInEmulator ()
  517. *
  518. * DESCRIPTION: Registers a software in the emulator
  519. * At this point the resource file must already be compiled
  520. *
  521. * PARAMETERS: None
  522. *
  523. * RETURNS: Nothing
  524. *
  525. *******************************************************************}
  526. procedure TCompiler.RegisterInEmulator;
  527. var
  528. StrFrom, StrTo: string;
  529. begin
  530. WriteLn('');
  531. WriteLn('Registering the software on the emulator');
  532. WriteLn('');
  533. StrFrom := MakeFolder + ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  534. StrTo := vSDKUtil.SDKFolder + Str_Path_Emulator_Registration +
  535. ChangeFileExt(vProject.MainResource, STR_RESOURCE_EXT);
  536. FileCopy(StrFrom, StrTo);
  537. end;
  538. end.