comprsrc.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {
  2. $Id$
  3. Copyright (c) 1998 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. procedure CompileResourceFiles;
  21. implementation
  22. uses
  23. {$ifdef Delphi}
  24. dmisc,
  25. {$else Delphi}
  26. dos,
  27. {$endif Delphi}
  28. Systems,Globtype,Globals,Verbose,Files,
  29. Script;
  30. procedure CompileResourceFiles;
  31. var
  32. resnr : longint;
  33. s : string;
  34. procedure CompileResource(const fn:string);
  35. var
  36. s,
  37. resobj,
  38. respath,
  39. resbin : string;
  40. resfound : boolean;
  41. begin
  42. if utilsdirectory<>'' then
  43. begin
  44. respath:=Search(target_res.resbin+source_os.exeext,
  45. utilsdirectory,resfound);
  46. end
  47. else
  48. {$ifdef Delphi}
  49. respath:=Search(target_res.resbin+source_os.exeext,'.;'+exepath+';'+dmisc.getenv('PATH'),resfound);
  50. {$else Delphi}
  51. respath:=Search(target_res.resbin+source_os.exeext,'.;'+exepath+';'+dos.getenv('PATH'),resfound);
  52. {$endif Delphi}
  53. resbin:=respath+target_res.resbin+source_os.exeext;
  54. if (not resfound) and not(cs_link_extern in aktglobalswitches) then
  55. begin
  56. Message(exec_w_res_not_found);
  57. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  58. end;
  59. resobj:=ForceExtension(current_module^.objfilename^,target_info.resobjext);
  60. s:=target_res.rescmd;
  61. Replace(s,'$OBJ',resobj);
  62. Replace(s,'$RES',fn);
  63. Replace(s,'$INC',respath);
  64. { Exec the command }
  65. if not (cs_link_extern in aktglobalswitches) then
  66. begin
  67. Message1(exec_i_compilingresource,fn);
  68. swapvectors;
  69. exec(resbin,s);
  70. swapvectors;
  71. if (doserror<>0) then
  72. begin
  73. Message(exec_w_cant_call_linker);
  74. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  75. end
  76. else
  77. if (dosexitcode<>0) then
  78. begin
  79. Message(exec_w_error_while_linking);
  80. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  81. end;
  82. end;
  83. { Update asmres when externmode is set }
  84. if cs_link_extern in aktglobalswitches then
  85. AsmRes.AddLinkCommand(resbin,s,'');
  86. current_module^.linkotherofiles.insert(resobj,link_allways);
  87. end;
  88. begin
  89. resnr:=0;
  90. While not Current_module^.ResourceFiles.Empty do
  91. begin
  92. S:=Current_module^.ResourceFiles.get;
  93. CompileResource(s);
  94. end;
  95. end;
  96. end.
  97. {
  98. $Log$
  99. Revision 1.6 1999-07-18 10:19:49 florian
  100. * made it compilable with Dlephi 4 again
  101. + fixed problem with large stack allocations on win32
  102. Revision 1.5 1999/07/03 00:29:46 peter
  103. * new link writing to the ppu, one .ppu is needed for all link types,
  104. static (.o) is now always created also when smartlinking is used
  105. Revision 1.4 1999/05/04 21:44:40 florian
  106. * changes to compile it with Delphi 4.0
  107. Revision 1.3 1999/01/06 14:38:09 michael
  108. + Fixed wrong unit name.
  109. Revision 1.2 1999/01/06 12:56:01 peter
  110. * fixed typo :(
  111. Revision 1.1 1999/01/06 12:39:46 peter
  112. * renamed resource -> comprsrc (conflicted with FV)
  113. Revision 1.1 1998/12/28 23:26:25 peter
  114. + resource file handling ($R directive) for Win32
  115. }