diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ghdldrv/ghdlcomp.adb | 9 | ||||
-rw-r--r-- | src/ghdldrv/ghdldrv.adb | 1 | ||||
-rw-r--r-- | src/ghdldrv/ghdlsynth.adb | 7 | ||||
-rw-r--r-- | src/libraries.adb | 13 | ||||
-rw-r--r-- | src/libraries.ads | 11 | ||||
-rw-r--r-- | src/options.adb | 4 | ||||
-rw-r--r-- | src/vhdl/translate/ortho_front.adb | 56 |
7 files changed, 65 insertions, 36 deletions
diff --git a/src/ghdldrv/ghdlcomp.adb b/src/ghdldrv/ghdlcomp.adb index a07fe0599..560a5ffd2 100644 --- a/src/ghdldrv/ghdlcomp.adb +++ b/src/ghdldrv/ghdlcomp.adb @@ -155,7 +155,7 @@ package body Ghdlcomp is end Perform_Action; - -- Command -c xx -r + -- Command -c xx -r/-e type Command_Compile is new Command_Comp with null record; function Decode_Command (Cmd : Command_Compile; Name : String) return Boolean; @@ -371,6 +371,13 @@ package body Ghdlcomp is if Arg = "-r" or else Arg = "-e" then Elab_Arg := I + 1; exit; + elsif Arg'Last > 7 and then Arg (1 .. 7) = "--work=" then + Libraries.Work_Library_Name := + Libraries.Decode_Work_Option (Arg); + if Libraries.Work_Library_Name = Null_Identifier then + raise Compilation_Error; + end if; + Libraries.Load_Work_Library (True); else Compile_Load_File (Arg); end if; diff --git a/src/ghdldrv/ghdldrv.adb b/src/ghdldrv/ghdldrv.adb index 90a64dc54..bac182572 100644 --- a/src/ghdldrv/ghdldrv.adb +++ b/src/ghdldrv/ghdldrv.adb @@ -1420,6 +1420,7 @@ package body Ghdldrv is end if; end loop; if Elab_Index < 0 then + -- No elaboration. Analyze_Files (Args, True, Error); if Error then raise Errorout.Compilation_Error; diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb index 08d980581..8ca51b81e 100644 --- a/src/ghdldrv/ghdlsynth.adb +++ b/src/ghdldrv/ghdlsynth.adb @@ -251,13 +251,14 @@ package body Ghdlsynth is declare Arg : String renames Args (I).all; pragma Assert (Arg'First = 1); + Id : Name_Id; begin if Arg'Last > 7 and then Arg (1 .. 7) = "--work=" then - if Libraries.Decode_Work_Option (Arg) then - Libraries.Load_Work_Library (True); - else + Id := Libraries.Decode_Work_Option (Arg); + if Id = Null_Identifier then return Null_Iir; end if; + Libraries.Load_Work_Library (True); else Ghdlcomp.Compile_Load_File (Arg); end if; diff --git a/src/libraries.adb b/src/libraries.adb index 6b1570d5a..0425030ad 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -1648,18 +1648,17 @@ package body Libraries is return Libraries_Chain; end Get_Libraries_Chain; - function Decode_Work_Option (Opt : String) return Boolean + function Decode_Work_Option (Opt : String) return Name_Id is - pragma Assert (Opt'First = 1); - Name : String (1 .. Opt'Last - 8 + 1); + Name : String (Opt'First + 7 .. Opt'Last); Err : Boolean; begin - Name := Opt (8 .. Opt'Last); + Name := Opt (Opt'First + 7 .. Opt'Last); Vhdl.Scanner.Convert_Identifier (Name, Err); if Err then - return False; + return Null_Identifier; end if; - Libraries.Work_Library_Name := Get_Identifier (Name); - return True; + return Get_Identifier (Name); + -- Libraries.Work_Library_Name := end Decode_Work_Option; end Libraries; diff --git a/src/libraries.ads b/src/libraries.ads index 1c954c938..66a80a747 100644 --- a/src/libraries.ads +++ b/src/libraries.ads @@ -167,11 +167,12 @@ package Libraries is -- If there are severals entities, return NULL_IIR; function Find_Entity_For_Component (Name: Name_Id) return Iir_Design_Unit; - -- Decode '--work=NAME' command line option and set the name of the - -- work library. The library has to be loaded later by calling - -- Load_Work_Library. - -- Return false if NAME is not a valid name. - function Decode_Work_Option (Opt : String) return Boolean; + -- Decode '--work=NAME' command line option and return the identifier + -- for the library. + -- To effectively use the library, assign Work_Library_Name and load the + -- library by calling Load_Work_Library. + -- Return Null_Identifier if NAME is not a valid name. + function Decode_Work_Option (Opt : String) return Name_Id; -- Get the chain of libraries. Can be used only to read (it musn't be -- modified). diff --git a/src/options.adb b/src/options.adb index 31f5c89b5..a68f949a4 100644 --- a/src/options.adb +++ b/src/options.adb @@ -18,6 +18,7 @@ with Simple_IO; with Errorout; use Errorout; +with Types; use Types; with Libraries; with Std_Names; with PSL.Nodes; @@ -138,7 +139,8 @@ package body Options is elsif Opt'Length > 2 and then Opt (1 .. 2) = "-W" then return Option_Warning (Opt (3 .. Opt'Last), True); elsif Opt'Length > 7 and then Opt (1 .. 7) = "--work=" then - if not Libraries.Decode_Work_Option (Opt) then + Libraries.Work_Library_Name := Libraries.Decode_Work_Option (Opt); + if Libraries.Work_Library_Name = Null_Identifier then return Option_Err; end if; elsif Opt = "-C" or else Opt = "--mb-comments" then diff --git a/src/vhdl/translate/ortho_front.adb b/src/vhdl/translate/ortho_front.adb index 77d5c73a3..6d75e2826 100644 --- a/src/vhdl/translate/ortho_front.adb +++ b/src/vhdl/translate/ortho_front.adb @@ -72,6 +72,9 @@ package body Ortho_Front is type Id_Link; type Id_Link_Acc is access Id_Link; type Id_Link is record + -- If true, ID is the name of a library (for --work=LIB) + -- If false, ID is the name of a file. + Is_Library : Boolean; Id : Name_Id; Link : Id_Link_Acc; end record; @@ -195,16 +198,26 @@ package body Ortho_Front is ("--ghdl-source option allowed only after --anaelab options"); return 0; end if; - if Arg /= null then - Error_Msg_Option ("no argument allowed after --ghdl-source"); - return 0; - end if; declare L : Id_Link_Acc; begin - L := new Id_Link'(Id => Name_Table.Get_Identifier - (Opt (Opt'First + 14 .. Opt'Last)), - Link => null); + if Opt'Length > 15 + and then Opt (Opt'First + 14 .. Opt'First + 20) = "--work=" + then + L := new Id_Link' (Is_Library => True, + Id => Libraries.Decode_Work_Option + (Opt (Opt'First + 14 .. Opt'Last)), + Link => null); + if L.Id = Null_Identifier then + return 0; + end if; + else + L := new Id_Link'(Is_Library => False, + Id => Name_Table.Get_Identifier + (Opt (Opt'First + 14 .. Opt'Last)), + Link => null); + end if; + if Anaelab_Files = null then Anaelab_Files := L; else @@ -587,19 +600,24 @@ package body Ortho_Front is begin L := Anaelab_Files; while L /= null loop - Res := Load_File_Name (L.Id); - if Errorout.Nbr_Errors > 0 then - raise Compilation_Error; + if L.Is_Library then + Libraries.Work_Library_Name := L.Id; + Libraries.Load_Work_Library (True); + else + Res := Load_File_Name (L.Id); + if Errorout.Nbr_Errors > 0 then + raise Compilation_Error; + end if; + + -- Put units into library. + Design := Get_First_Design_Unit (Res); + while not Is_Null (Design) loop + Next_Design := Get_Chain (Design); + Set_Chain (Design, Null_Iir); + Libraries.Add_Design_Unit_Into_Library (Design); + Design := Next_Design; + end loop; end if; - - -- Put units into library. - Design := Get_First_Design_Unit (Res); - while not Is_Null (Design) loop - Next_Design := Get_Chain (Design); - Set_Chain (Design, Null_Iir); - Libraries.Add_Design_Unit_Into_Library (Design); - Design := Next_Design; - end loop; L := L.Link; end loop; end; |