Parcourir la source

* Manually backported r12545 (by Vincent): pass parameters to windres using short path names and forward slashes (issue #12645)

git-svn-id: branches/fixes_2_2@12670 -
joost il y a 16 ans
Parent
commit
24d69efcd4
1 fichiers modifiés avec 30 ajouts et 7 suppressions
  1. 30 7
      compiler/comprsrc.pas

+ 30 - 7
compiler/comprsrc.pas

@@ -110,16 +110,31 @@ procedure tresourcefile.compile(output: tresoutput; const OutName: ansistring);
     else
       SelectBin:=Bin2;  
   end;
-  
+
+  function WindresFileName(filename: TCmdStr): TCmdStr;
+  // to be on the safe side, only give short file names with forward slashes to
+  // windres
+  var
+    i: longint;
+  begin
+    Result := GetShortName(filename);
+    for I:=1 to Length(Result) do
+    if Result[I] in AllowDirectorySeparators then
+      Result[i]:='/';
+  end;
+
 var
   respath,
   srcfilepath,
   preprocessorbin,
   s,
   bin,
-  resbin   : TCmdStr;
+  resbin,
+  fnameparam : TCmdStr;
+  usewindres,
   resfound,
   objused  : boolean;
+
 begin
   if output=roRES then
     Bin:=SelectBin(RCCompiler,target_res.rcbin)
@@ -128,6 +143,7 @@ begin
   if bin='' then
     exit;
   resfound:=false;
+  usewindres:= bin='windres';
   if utilsdirectory<>'' then
     resfound:=FindFile(utilsprefix+bin+source_info.exeext,utilsdirectory,false,resbin);
   if not resfound then
@@ -140,11 +156,15 @@ begin
      current_settings.globalswitches:=current_settings.globalswitches+[cs_link_nolink];
    end;
   srcfilepath:=ExtractFilePath(current_module.mainsource^);
+  if usewindres then
+    fnameparam:=WindresFileName(fname)
+  else
+    fnameparam:=maybequoted(fname);
   if output=roRES then
     begin
       s:=target_res.rccmd;
       Replace(s,'$RES',maybequoted(OutName));
-      Replace(s,'$RC',maybequoted(fname));
+      Replace(s,'$RC',fnameparam);
       ObjUsed:=False;
     end
   else
@@ -152,20 +172,23 @@ begin
       s:=target_res.rescmd;
       ObjUsed:=(pos('$OBJ',s)>0);
       Replace(s,'$OBJ',maybequoted(OutName));
-      Replace(s,'$RES',maybequoted(fname));
+      Replace(s,'$RES',fnameparam);
     end;
   { windres doesn't like empty include paths }
   if respath='' then
     respath:='.';
-  Replace(s,'$INC',maybequoted(respath));
+  if usewindres then
+    Replace(s,'$INC',WindresFileName(respath))
+  else
+    Replace(s,'$INC',maybequoted(respath));
   if (target_res.resbin='windres') then
    begin
      if (srcfilepath<>'') then
-       s:=s+' --include '+maybequoted(srcfilepath);
+       s:=s+' --include '+WindresFileName(srcfilepath);
      { try to find a preprocessor }
      preprocessorbin := respath+'cpp'+source_info.exeext;
      if FileExists(preprocessorbin,true) then
-       s:=s+' --preprocessor='+preprocessorbin;
+       s:=s+' --preprocessor='+maybequoted(preprocessorbin);
    end;
 { Execute the command }
   if not (cs_link_nolink in current_settings.globalswitches) then