Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / compiler / comprsrc.pas
blob576527b7eb43b63549580b8c5bb3427b51ed6b7b
2 $Id$
3 Copyright (c) 1998-2000 by Florian Klaempfl
5 Handles the resource files handling
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ****************************************************************************
23 unit comprsrc;
25 interface
27 type
28 presourcefile=^tresourcefile;
29 tresourcefile=object
30 private
31 fname : string;
32 public
33 constructor Init(const fn:string);
34 destructor Done;
35 procedure Compile;virtual;
36 end;
38 procedure CompileResourceFiles;
41 implementation
43 uses
44 {$ifdef Delphi}
45 dmisc,
46 {$else Delphi}
47 dos,
48 {$endif Delphi}
49 Systems,Globtype,Globals,Verbose,Files,
50 Script;
52 {****************************************************************************
53 TRESOURCEFILE
54 ****************************************************************************}
56 constructor tresourcefile.init(const fn:string);
57 begin
58 fname:=fn;
59 end;
62 destructor tresourcefile.done;
63 begin
64 end;
67 procedure tresourcefile.compile;
68 var
69 respath : pathstr;
70 n : namestr;
71 e : extstr;
73 resobj,
74 resbin : string;
75 resfound : boolean;
76 begin
77 resbin:='';
78 if utilsdirectory<>'' then
79 resbin:=FindFile(target_res.resbin+source_os.exeext,utilsdirectory,resfound)+target_res.resbin+source_os.exeext;
80 if resbin='' then
81 resbin:=FindExe(target_res.resbin,resfound);
82 { get also the path to be searched for the windres.h }
83 fsplit(resbin,respath,n,e);
84 if (not resfound) and not(cs_link_extern in aktglobalswitches) then
85 begin
86 Message(exec_w_res_not_found);
87 aktglobalswitches:=aktglobalswitches+[cs_link_extern];
88 end;
89 resobj:=ForceExtension(current_module^.objfilename^,target_info.resobjext);
90 s:=target_res.rescmd;
91 Replace(s,'$OBJ',resobj);
92 Replace(s,'$RES',fname);
93 Replace(s,'$INC',respath);
94 { Exec the command }
95 if not (cs_link_extern in aktglobalswitches) then
96 begin
97 Message1(exec_i_compilingresource,fname);
98 swapvectors;
99 exec(resbin,s);
100 swapvectors;
101 if (doserror<>0) then
102 begin
103 Message(exec_w_cant_call_linker);
104 aktglobalswitches:=aktglobalswitches+[cs_link_extern];
106 else
107 if (dosexitcode<>0) then
108 begin
109 Message(exec_w_error_while_linking);
110 aktglobalswitches:=aktglobalswitches+[cs_link_extern];
111 end;
112 end;
113 { Update asmres when externmode is set }
114 if cs_link_extern in aktglobalswitches then
115 AsmRes.AddLinkCommand(resbin,s,'');
116 current_module^.linkotherofiles.insert(resobj,link_allways);
117 end;
120 procedure CompileResourceFiles;
122 hr : presourcefile;
123 begin
124 (* OS/2 (EMX) must be processed elsewhere (in the linking/binding stage). *)
125 if target_info.target <> target_i386_os2 then
126 While not Current_module^.ResourceFiles.Empty do
127 begin
128 case target_info.target of
129 target_i386_win32:
130 hr:=new(presourcefile,init(Current_module^.ResourceFiles.get));
131 else
132 Message(scan_e_resourcefiles_not_supported);
133 end;
134 hr^.compile;
135 dispose(hr,done);
136 end;
137 end;
140 end.
142 $Log$
143 Revision 1.1 2002/02/19 08:21:58 sasu
144 Initial revision
146 Revision 1.1.2.2 2000/08/02 19:37:01 peter
147 * fixed resbin and respath generation, previous patch was also wrong
149 Revision 1.1.2.1 2000/07/31 20:05:33 peter
150 * fixed windres.exewindres.exe filename generation, from mailinglist
152 Revision 1.1 2000/07/13 06:29:48 michael
153 + Initial import
155 Revision 1.12 2000/06/25 19:08:28 hajny
156 + $R support for OS/2 (EMX) added
158 Revision 1.11 2000/06/23 20:11:05 peter
159 * made resourcecompiling object so it can be inherited and replaced
160 for other targets if needed
162 Revision 1.10 2000/02/09 13:22:50 peter
163 * log truncated
165 Revision 1.9 2000/01/07 01:14:23 peter
166 * updated copyright to 2000
168 Revision 1.8 1999/12/01 12:42:32 peter
169 * fixed bug 698
170 * removed some notes about unused vars
172 Revision 1.7 1999/11/12 11:03:50 peter
173 * searchpaths changed to stringqueue object