comprsrc.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. {$endif Delphi}
  26. Dos,
  27. Systems,Globtype,Globals,Verbose,Files,
  28. Script;
  29. procedure CompileResourceFiles;
  30. var
  31. resnr : longint;
  32. s : string;
  33. procedure CompileResource(const fn:string);
  34. var
  35. s,
  36. resobj,
  37. respath,
  38. resbin : string;
  39. resfound : boolean;
  40. begin
  41. if utilsdirectory<>'' then
  42. begin
  43. respath:=Search(target_res.resbin+source_os.exeext,
  44. utilsdirectory,resfound);
  45. end
  46. else
  47. {$ifdef Delphi}
  48. respath:=Search(target_res.resbin+source_os.exeext,'.;'+exepath+';'+dmisc.getenv('PATH'),resfound);
  49. {$else Delphi}
  50. respath:=Search(target_res.resbin+source_os.exeext,'.;'+exepath+';'+dos.getenv('PATH'),resfound);
  51. {$endif Delphi}
  52. resbin:=respath+target_res.resbin+source_os.exeext;
  53. if (not resfound) and not(cs_link_extern in aktglobalswitches) then
  54. begin
  55. Message(exec_w_res_not_found);
  56. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  57. end;
  58. resobj:=ForceExtension(current_module^.objfilename^,target_info.resobjext);
  59. s:=target_res.rescmd;
  60. Replace(s,'$OBJ',resobj);
  61. Replace(s,'$RES',fn);
  62. Replace(s,'$INC',respath);
  63. { Exec the command }
  64. if not (cs_link_extern in aktglobalswitches) then
  65. begin
  66. Message1(exec_i_compilingresource,fn);
  67. swapvectors;
  68. exec(resbin,s);
  69. swapvectors;
  70. if (doserror<>0) then
  71. begin
  72. Message(exec_w_cant_call_linker);
  73. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  74. end
  75. else
  76. if (dosexitcode<>0) then
  77. begin
  78. Message(exec_w_error_while_linking);
  79. aktglobalswitches:=aktglobalswitches+[cs_link_extern];
  80. end;
  81. end;
  82. { Update asmres when externmode is set }
  83. if cs_link_extern in aktglobalswitches then
  84. AsmRes.AddLinkCommand(resbin,s,'');
  85. current_module^.linkofiles.insert(resobj);
  86. end;
  87. begin
  88. resnr:=0;
  89. While not Current_module^.ResourceFiles.Empty do
  90. begin
  91. S:=Current_module^.ResourceFiles.Get;
  92. CompileResource(s);
  93. end;
  94. end;
  95. end.
  96. {
  97. $Log$
  98. Revision 1.4 1999-05-04 21:44:40 florian
  99. * changes to compile it with Delphi 4.0
  100. Revision 1.3 1999/01/06 14:38:09 michael
  101. + Fixed wrong unit name.
  102. Revision 1.2 1999/01/06 12:56:01 peter
  103. * fixed typo :(
  104. Revision 1.1 1999/01/06 12:39:46 peter
  105. * renamed resource -> comprsrc (conflicted with FV)
  106. Revision 1.1 1998/12/28 23:26:25 peter
  107. + resource file handling ($R directive) for Win32
  108. }