2
0

comprsrc.pas 3.1 KB

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