From 0aac4efd094b6b7ec0254f2bc4c2b994ed35c417 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 13 Apr 2020 17:02:45 +0200 Subject: synth: also try to open files (during synthesis) relative to current unit. Fix #1190 --- src/grt/grt-files_operations.adb | 8 +++++++- src/grt/grt-files_operations.ads | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/grt') diff --git a/src/grt/grt-files_operations.adb b/src/grt/grt-files_operations.adb index b1f504dc9..a98579bb7 100644 --- a/src/grt/grt-files_operations.adb +++ b/src/grt/grt-files_operations.adb @@ -249,6 +249,12 @@ package body Grt.Files_Operations is return; end Ghdl_File_Endfile; + function Simple_Open (Name : Ghdl_C_String; Mode : Ghdl_C_String) + return C_Files is + begin + return fopen (To_Address (Name), To_Address (Mode)); + end Simple_Open; + Sig_Header : constant String := "#GHDL-BINARY-FILE-0.0" & Nl; Std_Output_Name : constant String := "STD_OUTPUT" & NUL; @@ -309,7 +315,7 @@ package body Grt.Files_Operations is Str_Mode (2) := 'b'; Str_Mode (3) := NUL; end if; - F := fopen (To_Address (Name), Str_Mode'Address); + F := Open_Handler (Name, To_Ghdl_C_String (Str_Mode'Address)); if F = NULL_Stream then Status := Op_Name_Error; return; diff --git a/src/grt/grt-files_operations.ads b/src/grt/grt-files_operations.ads index 176d4f06c..4dfee186f 100644 --- a/src/grt/grt-files_operations.ads +++ b/src/grt/grt-files_operations.ads @@ -22,9 +22,12 @@ -- covered by the GNU General Public License. This exception does not -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. -with Grt.Types; use Grt.Types; + with Interfaces; +with Grt.Types; use Grt.Types; +with Grt.Stdio; + package Grt.Files_Operations is type Ghdl_File_Index is new Interfaces.Integer_32; @@ -143,4 +146,15 @@ package Grt.Files_Operations is Status : out Op_Status); procedure Ghdl_File_Flush (File : Ghdl_File_Index; Status : out Op_Status); + + type Open_Handler_Acc is access function + (Name : Ghdl_C_String; Mode : Ghdl_C_String) return Grt.Stdio.FILEs; + + -- Like fopen(3) + function Simple_Open (Name : Ghdl_C_String; Mode : Ghdl_C_String) + return Grt.Stdio.FILEs; + + -- Function called to open a file. This hook can be used to search a file + -- on a path. + Open_Handler : Open_Handler_Acc := Simple_Open'Access; end Grt.Files_Operations; -- cgit v1.2.3