From acf68c6a935edaf9cd3f575a5606e8fc6bd0fecb Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 15 Oct 2019 06:41:36 +0200 Subject: ghdlsynth: allow --work= option in the middle of files. --- src/libraries.adb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/libraries.adb') diff --git a/src/libraries.adb b/src/libraries.adb index 93f3f772c..d4e809b63 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -694,6 +694,14 @@ package body Libraries is end if; Work_Library := Std_Library; else + -- If the library is already known, just switch to it. This is used + -- for --work= option in the middle of files. + Work_Library := Vhdl.Utils.Find_Name_In_Chain + (Libraries_Chain, Work_Library_Name); + if Work_Library /= Null_Iir then + return; + end if; + Work_Library := Create_Iir (Iir_Kind_Library_Declaration); Set_Location (Work_Library, Library_Location); Set_Library_Directory (Work_Library, Work_Directory); @@ -1633,4 +1641,23 @@ package body Libraries is begin return Libraries_Chain; end Get_Libraries_Chain; + + function Decode_Work_Option + (Opt : String; Immediate : Boolean; Load_Lib : Boolean) return Boolean + is + pragma Assert (Opt'First = 1); + Name : String (1 .. Opt'Last - 8 + 1); + Err : Boolean; + begin + Name := Opt (8 .. Opt'Last); + Vhdl.Scanner.Convert_Identifier (Name, Err); + if Err then + return False; + end if; + Libraries.Work_Library_Name := Get_Identifier (Name); + if Immediate then + Libraries.Load_Work_Library (not Load_Lib); + end if; + return True; + end Decode_Work_Option; end Libraries; -- cgit v1.2.3