comprsrc.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Handles the resource files handling
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit comprsrc;
  19. {$i defines.inc}
  20. interface
  21. type
  22. presourcefile=^tresourcefile;
  23. tresourcefile=object
  24. private
  25. fname : string;
  26. public
  27. constructor Init(const fn:string);
  28. destructor Done;
  29. procedure Compile;virtual;
  30. end;
  31. procedure CompileResourceFiles;
  32. implementation
  33. uses
  34. {$ifdef Delphi}
  35. dmisc,
  36. {$else Delphi}
  37. dos,
  38. {$endif Delphi}
  39. Systems,cutils,Globtype,Globals,Verbose,Fmodule,
  40. Script;
  41. {****************************************************************************
  42. TRESOURCEFILE
  43. ****************************************************************************}
  44. constructor tresourcefile.init(const fn:string);
  45. begin
  46. fname:=fn;
  47. end;
  48. destructor tresourcefile.done;
  49. begin
  50. end;
  51. procedure tresourcefile.compile;
  52. var
  53. respath : pathstr;
  54. n : namestr;
  55. e : extstr;
  56. s,
  57. resobj,
  58. resbin : string;
  59. resfound : boolean;
  60. begin
  61. resbin:='';
  62. if utilsdirectory<>'' then
  63. resbin:=FindFile(target_res.resbin+source_os.exeext,utilsdirectory,resfound)+target_res.resbin+source_os.exeext;
  64. if resbin='' then
  65. resbin:=FindExe(target_res.resbin,resfound);
  66. { get also the path to be searched for the windres.h }
  67. fsplit(resbin,respath,n,e);
  68. if (not resfound) and not(cs_link_extern in aktglobalswitches) then
  69. begin
  70. Message(exec_w_res_not_found);
  71. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  72. end;
  73. resobj:=ForceExtension(current_module^.objfilename^,target_info.resobjext);
  74. s:=target_res.rescmd;
  75. Replace(s,'$OBJ',resobj);
  76. Replace(s,'$RES',fname);
  77. Replace(s,'$INC',respath);
  78. { Exec the command }
  79. if not (cs_link_extern in aktglobalswitches) then
  80. begin
  81. Message1(exec_i_compilingresource,fname);
  82. swapvectors;
  83. exec(resbin,s);
  84. swapvectors;
  85. if (doserror<>0) then
  86. begin
  87. Message(exec_w_cant_call_linker);
  88. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  89. end
  90. else
  91. if (dosexitcode<>0) then
  92. begin
  93. Message(exec_w_error_while_linking);
  94. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  95. end;
  96. end;
  97. { Update asmres when externmode is set }
  98. if cs_link_extern in aktglobalswitches then
  99. AsmRes.AddLinkCommand(resbin,s,'');
  100. current_module^.linkotherofiles.insert(resobj,link_allways);
  101. end;
  102. procedure CompileResourceFiles;
  103. var
  104. hr : presourcefile;
  105. begin
  106. (* OS/2 (EMX) must be processed elsewhere (in the linking/binding stage). *)
  107. if target_info.target <> target_i386_os2 then
  108. While not Current_module^.ResourceFiles.Empty do
  109. begin
  110. case target_info.target of
  111. target_i386_win32:
  112. hr:=new(presourcefile,init(Current_module^.ResourceFiles.get));
  113. else
  114. Message(scan_e_resourcefiles_not_supported);
  115. end;
  116. hr^.compile;
  117. dispose(hr,done);
  118. end;
  119. end;
  120. end.
  121. {
  122. $Log$
  123. Revision 1.5 2000-09-24 15:06:14 peter
  124. * use defines.inc
  125. Revision 1.4 2000/08/27 16:11:50 peter
  126. * moved some util functions from globals,cobjects to cutils
  127. * splitted files into finput,fmodule
  128. Revision 1.3 2000/08/04 22:00:51 peter
  129. * merges from fixes
  130. Revision 1.2 2000/07/13 11:32:38 michael
  131. + removed logs
  132. }