aboutsummaryrefslogtreecommitdiffstats
path: root/src/libraries.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-15 06:41:36 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-15 06:41:36 +0200
commitacf68c6a935edaf9cd3f575a5606e8fc6bd0fecb (patch)
tree9bc90b9c564e3bc20cadf8516f4854de0587ed70 /src/libraries.adb
parent2485c247d5eae5f88c37708c2346c015caf22dbc (diff)
downloadghdl-acf68c6a935edaf9cd3f575a5606e8fc6bd0fecb.tar.gz
ghdl-acf68c6a935edaf9cd3f575a5606e8fc6bd0fecb.tar.bz2
ghdl-acf68c6a935edaf9cd3f575a5606e8fc6bd0fecb.zip
ghdlsynth: allow --work= option in the middle of files.
Diffstat (limited to 'src/libraries.adb')
-rw-r--r--src/libraries.adb27
1 files changed, 27 insertions, 0 deletions
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;