comprsrc.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. 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. 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:=FindFile(target_res.resbin+source_os.exeext,
  44. utilsdirectory,resfound);
  45. end
  46. else
  47. {$ifdef Delphi}
  48. respath:=FindFile(target_res.resbin+source_os.exeext,'.;'+exepath+';'+dmisc.getenv('PATH'),resfound);
  49. {$else Delphi}
  50. respath:=FindFile(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^.linkotherofiles.insert(resobj,link_allways);
  86. end;
  87. begin
  88. While not Current_module^.ResourceFiles.Empty do
  89. begin
  90. S:=Current_module^.ResourceFiles.get;
  91. CompileResource(s);
  92. end;
  93. end;
  94. end.
  95. {
  96. $Log$
  97. Revision 1.10 2000-02-09 13:22:50 peter
  98. * log truncated
  99. Revision 1.9 2000/01/07 01:14:23 peter
  100. * updated copyright to 2000
  101. Revision 1.8 1999/12/01 12:42:32 peter
  102. * fixed bug 698
  103. * removed some notes about unused vars
  104. Revision 1.7 1999/11/12 11:03:50 peter
  105. * searchpaths changed to stringqueue object
  106. }