浏览代码

+ Made a single Amiga/MorphOS-specific PathConv import to cfileutl.pas, instead of importing it every single place it is needed.
+ Forced PathConv argument to ShortString. Made a note about implementing AnsiString-aware PathConv later.
+ Made code to use the unified PathConv import (named Unix2AmigaPath(), which explains its functionality better).
+ The above changes fixed various compiler crashes in TAsmScriptAmiga, caused by invoking PathConv with AnsiString arguments, while it only supports ShortString

git-svn-id: trunk@12485 -

Károly Balogh 16 年之前
父节点
当前提交
446e2161ce
共有 5 个文件被更改,包括 41 次插入56 次删除
  1. 24 0
      compiler/cfileutl.pas
  2. 3 12
      compiler/powerpc/agppcvasm.pas
  3. 2 14
      compiler/script.pas
  4. 7 16
      compiler/systems/t_amiga.pas
  5. 5 14
      compiler/systems/t_morph.pas

+ 24 - 0
compiler/cfileutl.pas

@@ -131,6 +131,19 @@ interface
     procedure DoneFileUtils;
     procedure DoneFileUtils;
 
 
 
 
+{ * Since native Amiga commands can't handle Unix-style relative paths used by the compiler,
+    and some GNU tools, Unix2AmigaPath is needed to handle such situations (KB) * }
+
+{$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
+{ * PATHCONV is implemented in the Amiga/MorphOS system unit * }
+{$WARNING TODO Amiga: implement PathConv() in System unit, which works with AnsiString}
+function Unix2AmigaPath(path: ShortString): ShortString; external name 'PATHCONV';
+{$ELSE}
+function Unix2AmigaPath(path: String): String;{$IFDEF USEINLINE}inline;{$ENDIF}
+{$ENDIF}
+
+
+
 implementation
 implementation
 
 
     uses
     uses
@@ -164,6 +177,17 @@ implementation
       DirCache : TDirectoryCache;
       DirCache : TDirectoryCache;
 
 
 
 
+{$IF NOT (DEFINED(MORPHOS) OR DEFINED(AMIGA))}
+{ Stub function for Unix2Amiga Path conversion functionality, only available in
+  Amiga/MorphOS RTL. I'm open for better solutions. (KB) }
+function Unix2AmigaPath(path: String): String;{$IFDEF USEINLINE}inline;{$ENDIF}
+begin
+  Unix2AmigaPath:=path;
+end;
+{$ENDIF}
+
+
+
 {****************************************************************************
 {****************************************************************************
                            TCachedDirectory
                            TCachedDirectory
 ****************************************************************************}
 ****************************************************************************}

+ 3 - 12
compiler/powerpc/agppcvasm.pas

@@ -58,7 +58,7 @@ unit agppcvasm;
   implementation
   implementation
 
 
     uses
     uses
-       cutils,globals,verbose,
+       cutils,cfileutl,globals,verbose,
        cgbase,systems,
        cgbase,systems,
        assemble,script,
        assemble,script,
        itcpugas,cpuinfo,
        itcpugas,cpuinfo,
@@ -358,15 +358,6 @@ unit agppcvasm;
 {                         GNU PPC Assembler writer                           }
 {                         GNU PPC Assembler writer                           }
 {****************************************************************************}
 {****************************************************************************}
 
 
-{$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
-{ * PathConv is implemented in the system unit! * }
-function PathConv(path: string): string; external name 'PATHCONV';
-{$ELSE}
-function PathConv(path: string): string;
-begin
-  PathConv:=path;
-end;
-{$ENDIF}
 
 
     constructor TPPCVASM.create(smart: boolean);
     constructor TPPCVASM.create(smart: boolean);
       begin
       begin
@@ -385,8 +376,8 @@ end;
          end
          end
         else
         else
          begin
          begin
-           Replace(result,'$ASM',maybequoted(PathConv(AsmFileName)));
-           Replace(result,'$OBJ',maybequoted(PathConv(ObjFileName)));
+           Replace(result,'$ASM',maybequoted(Unix2AmigaPath(AsmFileName)));
+           Replace(result,'$OBJ',maybequoted(Unix2AmigaPath(ObjFileName)));
          end;
          end;
       end;
       end;
 
 

+ 2 - 14
compiler/script.pas

@@ -278,18 +278,6 @@ end;
                                   Amiga Asm Response
                                   Amiga Asm Response
 ****************************************************************************}
 ****************************************************************************}
 
 
-{ * PathConv is required, since Amiga commands can't handle Unix-style
-    relative paths used by the compiler (KB) * }
-
-{$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
-{ * PathConv is implemented in the system unit! * }
-function PathConv(path: TCmdStr): TCmdStr; external name 'PATHCONV';
-{$ELSE}
-function PathConv(path: TCmdStr): TCmdStr;
-begin
-  PathConv:=path;
-end;
-{$ENDIF}
 
 
 Constructor TAsmScriptAmiga.Create (Const ScriptName : TCmdStr);
 Constructor TAsmScriptAmiga.Create (Const ScriptName : TCmdStr);
 begin
 begin
@@ -330,13 +318,13 @@ end;
 
 
 Procedure TAsmScriptAmiga.AddDeleteCommand (Const FileName : TCmdStr);
 Procedure TAsmScriptAmiga.AddDeleteCommand (Const FileName : TCmdStr);
 begin
 begin
- Add('Delete ' + PathConv(MaybeQuoted(ScriptFixFileName(FileName))) + ' Quiet');
+ Add('Delete ' + Unix2AmigaPath(MaybeQuoted(ScriptFixFileName(FileName))) + ' Quiet');
 end;
 end;
 
 
 
 
 Procedure TAsmScriptAmiga.AddDeleteDirCommand (Const FileName : TCmdStr);
 Procedure TAsmScriptAmiga.AddDeleteDirCommand (Const FileName : TCmdStr);
 begin
 begin
- Add('Delete ' + PathConv(MaybeQuoted(ScriptFixFileName(FileName))) + ' All Quiet');
+ Add('Delete ' + Unix2AmigaPath(MaybeQuoted(ScriptFixFileName(FileName))) + ' All Quiet');
 end;
 end;
 
 
 
 

+ 7 - 16
compiler/systems/t_amiga.pas

@@ -53,15 +53,6 @@ implementation
        cutils,cfileutl,cclasses,
        cutils,cfileutl,cclasses,
        globtype,globals,systems,verbose,script,fmodule,i_amiga;
        globtype,globals,systems,verbose,script,fmodule,i_amiga;
 
 
-{$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
-{ * PathConv is implemented in the system unit! * }
-function PathConv(path: string): string; external name 'PATHCONV';
-{$ELSE}
-function PathConv(path: string): string;
-begin
-  PathConv:=path;
-end;
-{$ENDIF}
 
 
 
 
 {****************************************************************************
 {****************************************************************************
@@ -127,7 +118,7 @@ begin
    begin
    begin
     s:=HPath.Str;
     s:=HPath.Str;
     if s<>'' then
     if s<>'' then
-     LinkRes.Add('SEARCH_DIR('+PathConv(maybequoted(s))+')');
+     LinkRes.Add('SEARCH_DIR('+Unix2AmigaPath(maybequoted(s))+')');
     HPath:=TCmdStrListItem(HPath.Next);
     HPath:=TCmdStrListItem(HPath.Next);
    end;
    end;
 
 
@@ -140,7 +131,7 @@ begin
     s:=ObjectFiles.GetFirst;
     s:=ObjectFiles.GetFirst;
     if s<>'' then
     if s<>'' then
      begin
      begin
-      LinkRes.AddFileName(PathConv(maybequoted(s)));
+      LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
      end;
      end;
    end;
    end;
 
 
@@ -152,7 +143,7 @@ begin
     while not StaticLibFiles.Empty do
     while not StaticLibFiles.Empty do
      begin
      begin
       S:=StaticLibFiles.GetFirst;
       S:=StaticLibFiles.GetFirst;
-      LinkRes.AddFileName(PathConv(maybequoted(s)));
+      LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
      end;
      end;
    end;
    end;
 
 
@@ -216,8 +207,8 @@ begin
   { Call linker }
   { Call linker }
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
-  Replace(cmdstr,'$EXE',PathConv(maybequoted(ScriptFixFileName(current_module.exefilename^))));
-  Replace(cmdstr,'$RES',PathConv(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
+  Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename^))));
+  Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
   MakeAmiga68kExe:=DoExec(FindUtil(BinStr),CmdStr,true,false);
   MakeAmiga68kExe:=DoExec(FindUtil(BinStr),CmdStr,true,false);
 end;
 end;
@@ -235,8 +226,8 @@ begin
   { Call linker }
   { Call linker }
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
-  Replace(cmdstr,'$EXE',PathConv(maybequoted(ScriptFixFileName(current_module.exefilename^))));
-  Replace(cmdstr,'$RES',PathConv(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
+  Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename^))));
+  Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$STRIP',StripStr);
   MakeAmigaPPCExe:=DoExec(FindUtil(BinStr),CmdStr,true,false);
   MakeAmigaPPCExe:=DoExec(FindUtil(BinStr),CmdStr,true,false);
 end;
 end;

+ 5 - 14
compiler/systems/t_morph.pas

@@ -45,15 +45,6 @@ implementation
           function  MakeExecutable:boolean; override;
           function  MakeExecutable:boolean; override;
        end;
        end;
 
 
-{$IFDEF MORPHOS}
-{ * PathConv is implemented in the system unit! * }
-function PathConv(path: string): string; external name 'PATHCONV';
-{$ELSE}
-function PathConv(path: string): string;
-begin
-  PathConv:=path;
-end;
-{$ENDIF}
 
 
 {****************************************************************************
 {****************************************************************************
                                TLinkerMorphOS
                                TLinkerMorphOS
@@ -113,7 +104,7 @@ begin
    begin
    begin
     s:=HPath.Str;
     s:=HPath.Str;
     if s<>'' then
     if s<>'' then
-     LinkRes.Add('SEARCH_DIR('+PathConv(maybequoted(s))+')');
+     LinkRes.Add('SEARCH_DIR('+Unix2AmigaPath(maybequoted(s))+')');
     HPath:=TCmdStrListItem(HPath.Next);
     HPath:=TCmdStrListItem(HPath.Next);
    end;
    end;
 
 
@@ -129,7 +120,7 @@ begin
       { vlink doesn't use SEARCH_DIR for object files }
       { vlink doesn't use SEARCH_DIR for object files }
       if not(cs_link_on_target in current_settings.globalswitches) then
       if not(cs_link_on_target in current_settings.globalswitches) then
        s:=FindObjectFile(s,'',false);
        s:=FindObjectFile(s,'',false);
-      LinkRes.AddFileName(PathConv(maybequoted(s)));
+      LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
      end;
      end;
    end;
    end;
 
 
@@ -145,7 +136,7 @@ begin
     while not StaticLibFiles.Empty do
     while not StaticLibFiles.Empty do
      begin
      begin
       S:=StaticLibFiles.GetFirst;
       S:=StaticLibFiles.GetFirst;
-      LinkRes.AddFileName(PathConv(maybequoted(s)));
+      LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
      end;
      end;
    end;
    end;
 
 
@@ -225,8 +216,8 @@ begin
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   if not(cs_link_on_target in current_settings.globalswitches) then
   if not(cs_link_on_target in current_settings.globalswitches) then
    begin
    begin
-    Replace(cmdstr,'$EXE',PathConv(maybequoted(ScriptFixFileName(current_module.exefilename^))));
-    Replace(cmdstr,'$RES',PathConv(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
+    Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename^))));
+    Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
     Replace(cmdstr,'$STRIP',StripStr);
     Replace(cmdstr,'$STRIP',StripStr);
    end
    end
   else
   else