aboutsummaryrefslogtreecommitdiffstats
path: root/src/ghdldrv/ghdllocal.ads
blob: 43f2de8cbb538d4a6012c3dc9975edb5c55c4bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
--  GHDL driver - local commands.
--  Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold
--
--  GHDL is free software; you can redistribute it and/or modify it under
--  the terms of the GNU General Public License as published by the Free
--  Software Foundation; either version 2, or (at your option) any later
--  version.
--
--  GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
--  WARRANTY; without even the implied warranty of MERCHANTABILITY or
--  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--  for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with GCC; see the file COPYING.  If not, write to the Free
--  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
--  02111-1307, USA.
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Ghdlmain; use Ghdlmain;
with Iirs; use Iirs;

package Ghdllocal is
   --  Init procedure for the functionnal interface.
   procedure Compile_Init;

   type Command_Lib is abstract new Command_Type with null record;

   --  Setup GHDL.  Same as Compile_Init.
   procedure Init (Cmd : in out Command_Lib);

   --  Handle:
   --  --std=xx, --work=xx, -Pxxx, --workdir=x, --ieee=x, -Px, and -v
   procedure Decode_Option (Cmd : in out Command_Lib;
                            Option : String;
                            Arg : String;
                            Res : out Option_Res);

   --  Disp detailled help.
   procedure Disp_Long_Help (Cmd : Command_Lib);

   --  Value of --PREFIX
   Switch_Prefix_Path : String_Access := null;

   --  getenv ("GHDL_PREFIX").  Set by Setup_Libraries.
   Prefix_Env : String_Access := null;

   --  Installation prefix (deduced from executable path).
   Exec_Prefix : String_Access;

   --  Path prefix for libraries.
   Lib_Prefix_Path : String_Access := null;

   --  Set with -v option.
   Flag_Verbose : Boolean := False;

   --  Suffix for asm files.
   Asm_Suffix : constant String := ".s";

   --  Suffix for llvm byte-code files.
   Llvm_Suffix : constant String := ".bc";

   --  Suffix for post files.
   Post_Suffix : constant String := ".on";

   --  Suffix for list files.
   List_Suffix : constant String := ".lst";

   --  Prefix for elab files.
   Elab_Prefix : constant String := "e~";

   Nul : constant Character := Character'Val (0);

   --  Return FILENAME without the extension.
   function Get_Base_Name (Filename : String; Remove_Dir : Boolean := True)
                          return String;

   --  Get the position of the last directory separator or Pathname'First - 1
   --  if none.
   function Get_Basename_Pos (Pathname : String) return Natural;

   --  Build a filename based on FILE. If IN_WORK is true, the result is
   --  the concatenation of the workdir, the basename of FILE and SUFFIX.
   --  If IN_WORK is false, the result is the concatenation of FILE and SUFFIX.
   function Append_Suffix
     (File : String; Suffix : String; In_Work : Boolean := True)
     return String_Access;

   --  Return TRUE is UNIT can be at the apex of a design hierarchy.
   function Is_Top_Entity (Unit : Iir) return Boolean;

   --  Display the name of library unit UNIT.
   procedure Disp_Library_Unit (Unit : Iir);

   --  Translate vhdl version into a path element.
   --  Used to search Std and IEEE libraries.
   function Get_Version_Path return String;

   -- Get Prefix_Path, but with 32 added if -m32 is requested
   function Get_Machine_Path_Prefix return String;

   --  Subprocedure for --disp-config: display prefixes.
   procedure Disp_Config_Prefixes;

   --  Setup standard libaries path.  If LOAD is true, then load them now.
   procedure Setup_Libraries (Load : Boolean);

   --  Setup library, analyze FILES, and if SAVE_LIBRARY is set save the
   --  work library only
   procedure Analyze_Files (Files : Argument_List; Save_Library : Boolean);

   --  Load and parse all libraries and files, starting from the work library.
   --  The work library must already be loaded.
   --  Raise errorout.compilation_error in case of error (parse error).
   procedure Load_All_Libraries_And_Files;

   function Build_Dependence (Prim : String_Access; Sec : String_Access)
     return Iir_List;

   --  Return True iff file FILE has been modified (the file time stamp does
   --  no correspond to what was recorded in the library).
   function Source_File_Modified (File : Iir_Design_File) return Boolean;

   --  Return True iff FILE need to be analyzed because one of its dependences
   --  has been analyzed more recently.
   function Is_File_Outdated (File : Iir_Design_File) return Boolean;

   Prim_Name : String_Access;
   Sec_Name : String_Access;

   --  Set PRIM_NAME and SEC_NAME.
   procedure Extract_Elab_Unit
     (Cmd_Name : String; Args : Argument_List; Next_Arg : out Natural);

   procedure Register_Commands;
end Ghdllocal;