comprsrc.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. interface
  20. type
  21. presourcefile=^tresourcefile;
  22. tresourcefile=object
  23. private
  24. fname : string;
  25. public
  26. constructor Init(const fn:string);
  27. destructor Done;
  28. procedure Compile;virtual;
  29. end;
  30. procedure CompileResourceFiles;
  31. implementation
  32. uses
  33. {$ifdef Delphi}
  34. dmisc,
  35. {$else Delphi}
  36. dos,
  37. {$endif Delphi}
  38. Systems,Globtype,Globals,Verbose,Files,
  39. Script;
  40. {****************************************************************************
  41. TRESOURCEFILE
  42. ****************************************************************************}
  43. constructor tresourcefile.init(const fn:string);
  44. begin
  45. fname:=fn;
  46. end;
  47. destructor tresourcefile.done;
  48. begin
  49. end;
  50. procedure tresourcefile.compile;
  51. var
  52. s,
  53. resobj,
  54. respath,
  55. resbin : string;
  56. resfound : boolean;
  57. begin
  58. if utilsdirectory<>'' then
  59. respath:=FindFile(target_res.resbin+source_os.exeext,utilsdirectory,resfound)
  60. else
  61. respath:=FindExe(target_res.resbin,resfound);
  62. resbin:=respath+target_res.resbin+source_os.exeext;
  63. if (not resfound) and not(cs_link_extern in aktglobalswitches) then
  64. begin
  65. Message(exec_w_res_not_found);
  66. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  67. end;
  68. resobj:=ForceExtension(current_module^.objfilename^,target_info.resobjext);
  69. s:=target_res.rescmd;
  70. Replace(s,'$OBJ',resobj);
  71. Replace(s,'$RES',fname);
  72. Replace(s,'$INC',respath);
  73. { Exec the command }
  74. if not (cs_link_extern in aktglobalswitches) then
  75. begin
  76. Message1(exec_i_compilingresource,fname);
  77. swapvectors;
  78. exec(resbin,s);
  79. swapvectors;
  80. if (doserror<>0) then
  81. begin
  82. Message(exec_w_cant_call_linker);
  83. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  84. end
  85. else
  86. if (dosexitcode<>0) then
  87. begin
  88. Message(exec_w_error_while_linking);
  89. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  90. end;
  91. end;
  92. { Update asmres when externmode is set }
  93. if cs_link_extern in aktglobalswitches then
  94. AsmRes.AddLinkCommand(resbin,s,'');
  95. current_module^.linkotherofiles.insert(resobj,link_allways);
  96. end;
  97. procedure CompileResourceFiles;
  98. var
  99. hr : presourcefile;
  100. begin
  101. (* OS/2 (EMX) must be processed elsewhere (in the linking/binding stage). *)
  102. if target_info.target <> target_i386_os2 then
  103. While not Current_module^.ResourceFiles.Empty do
  104. begin
  105. case target_info.target of
  106. target_i386_win32:
  107. hr:=new(presourcefile,init(Current_module^.ResourceFiles.get));
  108. else
  109. Message(scan_e_resourcefiles_not_supported);
  110. end;
  111. hr^.compile;
  112. dispose(hr,done);
  113. end;
  114. end;
  115. end.
  116. {
  117. $Log$
  118. Revision 1.2 2000-07-13 11:32:38 michael
  119. + removed logs
  120. }