2
0
Эх сурвалжийг харах

* resource compiling supported on OS/2 via wrc
* CompileResourceFiles and CollectResourceFiles don't do target-specific checks anymore
* refactored a bit

git-svn-id: branches/resources@10201 -

giulio 17 жил өмнө
parent
commit
1bb7f29106

+ 31 - 26
compiler/comprsrc.pas

@@ -353,17 +353,43 @@ begin
 end;
 
 
+function CopyResFile(inf,outf : TCmdStr) : boolean;
+var
+  src,dst : TCFileStream;
+begin
+  { Copy .res file to units output dir. }
+  Result:=false;
+  src:=TCFileStream.Create(inf,fmOpenRead or fmShareDenyNone);
+  if CStreamError<>0 then
+    begin
+      Message1(exec_e_cant_open_resource_file, src.FileName);
+      Include(current_settings.globalswitches, cs_link_nolink);
+      exit;
+    end;
+  dst:=TCFileStream.Create(current_module.outputpath^+outf,fmCreate);
+  if CStreamError<>0 then
+    begin
+      Message1(exec_e_cant_write_resource_file, dst.FileName);
+      Include(current_settings.globalswitches, cs_link_nolink);
+      exit;
+    end;
+  dst.CopyFrom(src,src.Size);
+  dst.Free;
+  src.Free;
+  Result:=true;
+end;
+ 
 procedure CompileResourceFiles;
 var
   resourcefile : tresourcefile;
   res: TCmdStrListItem;
   p,s : TCmdStr;
-  src,dst : TCFileStream;
   outfmt : tresoutput;
 begin
-  { OS/2 (EMX) must be processed elsewhere (in the linking/binding stage).
-    same with MacOS}
-  if target_info.system in [system_i386_os2,system_i386_emx,system_powerpc_macos] then exit;
+  { Don't do anything for systems supporting resources without using resource
+    file classes (e.g. Mac OS). They process resources elsewhere. }
+  if (target_info.res<>res_none) and (target_res.resourcefileclass=nil) then
+    exit;
 
   p:=ExtractFilePath(current_module.mainsource^);
   res:=TCmdStrListItem(current_module.ResourceFiles.First);
@@ -388,24 +414,7 @@ begin
             begin
               { Copy .res file to units output dir. Otherwise .res file will not be found
                 when only compiled units path is available }
-              res.FPStr:=ExtractFileName(res.FPStr);
-              src:=TCFileStream.Create(s,fmOpenRead or fmShareDenyNone);
-              if CStreamError<>0 then
-                begin
-                  Message1(exec_e_cant_open_resource_file, src.FileName);
-                  Include(current_settings.globalswitches, cs_link_nolink);
-                  exit;
-                end;
-              dst:=TCFileStream.Create(current_module.outputpath^+res.FPStr,fmCreate);
-              if CStreamError<>0 then
-                begin
-                  Message1(exec_e_cant_write_resource_file, dst.FileName);
-                  Include(current_settings.globalswitches, cs_link_nolink);
-                  exit;
-                end;
-              dst.CopyFrom(src,src.Size);
-              dst.Free;
-              src.Free;
+              if not CopyResFile(s,ExtractFileName(res.FPStr)) then exit;
             end;
         end
       else
@@ -459,10 +468,6 @@ var
   hp : tused_unit;
   s : TCmdStr;
 begin
-  { OS/2 (EMX) must be processed elsewhere (in the linking/binding stage).
-    same with MacOS}
-  if target_info.system in [system_i386_os2,system_i386_emx,system_powerpc_macos] then exit;
-
   if (target_info.res=res_none) or ((target_res.resbin='')
     and (ResCompiler='')) then
       exit;

+ 1 - 1
compiler/scandir.pas

@@ -980,7 +980,7 @@ implementation
         if target_info.res<>res_none then
           begin
           current_module.flags:=current_module.flags or uf_has_resourcefiles;
-          if (target_info.res = res_emxbind) and
+          if (res_single_file in target_res.resflags) and
                                  not (Current_module.ResourceFiles.Empty) then
             Message(scan_w_only_one_resourcefile_supported)
           else

+ 6 - 3
compiler/systems.pas

@@ -180,13 +180,14 @@ interface
        );
 
        tres = (res_none
-            ,res_gnu_windres,res_emxbind
+            ,res_gnu_windres,res_watcom_wrc_os2
             ,res_m68k_palmos,res_m68k_mpw
             ,res_powerpc_mpw,res_elf
             ,res_win64_gorc, res_macho, res_ext
        );
        
-       tresinfoflags = (res_external_file,res_arch_in_file_name);
+       tresinfoflags = (res_external_file,res_arch_in_file_name
+            ,res_single_file);
 
        tdbg = (dbg_none
             ,dbg_stabs,dbg_dwarf2,dbg_dwarf3
@@ -570,7 +571,9 @@ begin
      target_res:=resinfos[t]^;
      result:=true;
      exit;
-   end;
+   end
+  else
+   FillByte(target_res,sizeof(target_res),0);
 end;
 
 

+ 9 - 6
compiler/systems/i_emx.pas

@@ -27,12 +27,15 @@ unit i_emx;
        systems;
 
     const
-       res_emxbind_info : tresinfo =
+       res_wrc_os2_info : tresinfo =
           (
-            id     : res_emxbind;
-            resbin : 'emxbind';
-            rescmd : '-b -r $RES $OBJ'
-            (* Not really used - see TLinkerEMX.SetDefaultInfo in t_emx.pas. *)
+             id     : res_watcom_wrc_os2;
+             resbin : '';
+             rescmd : '';
+             rcbin  : 'wrc';
+             rccmd  : '-r -zm -q -bt=os2 -fo=$RES $RC';
+             resourcefileclass : nil;
+             resflags : [res_single_file];
           );
 
        system_i386_emx_info : tsysteminfo =
@@ -70,7 +73,7 @@ unit i_emx;
             link         : nil;
             linkextern   : nil;
             ar           : ar_gnu_ar;
-            res          : res_emxbind;
+            res          : res_watcom_wrc_os2;
             dbg          : dbg_stabs;
             script       : script_dos;
             endian       : endian_little;

+ 9 - 6
compiler/systems/i_os2.pas

@@ -27,12 +27,15 @@ unit i_os2;
        systems;
 
     const
-       res_emxbind_info : tresinfo =
+       res_wrc_os2_info : tresinfo =
           (
-            id     : res_emxbind;
-            resbin : 'emxbind';
-            rescmd : '-b -r $RES $OBJ'
-            (* Not really used - see TLinkeros2.SetDefaultInfo in t_os2.pas. *)
+             id     : res_watcom_wrc_os2;
+             resbin : '';
+             rescmd : '';
+             rcbin  : 'wrc';
+             rccmd  : '-r -zm -q -bt=os2 -fo=$RES $RC';
+             resourcefileclass : nil;
+             resflags : [res_single_file];
           );
 
        system_i386_os2_info : tsysteminfo =
@@ -70,7 +73,7 @@ unit i_os2;
             link         : nil;
             linkextern   : nil;
             ar           : ar_gnu_ar;
-            res          : res_emxbind;
+            res          : res_watcom_wrc_os2;
             dbg          : dbg_stabs;
             script       : script_dos;
             endian       : endian_little;

+ 1 - 1
compiler/systems/t_emx.pas

@@ -526,6 +526,6 @@ end;
 initialization
   RegisterExternalLinker(system_i386_emx_info,TLinkerEMX);
   RegisterImport(system_i386_emx,TImportLibEMX);
-  RegisterRes(res_emxbind_info,TResourceFile);
+  RegisterRes(res_wrc_os2_info,TResourceFile);
   RegisterTarget(system_i386_emx_info);
 end.

+ 1 - 1
compiler/systems/t_os2.pas

@@ -552,6 +552,6 @@ end;
 initialization
   RegisterExternalLinker(system_i386_os2_info,TLinkerOS2);
   RegisterImport(system_i386_os2,TImportLibOS2);
-{  RegisterRes(res_emxbind_info);}
+{  RegisterRes(res_wrc_os2_info,TResourceFile);}
   RegisterTarget(system_i386_os2_info);
 end.