1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2006-2013, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
27 with Makeutl
; use Makeutl
;
30 with Output
; use Output
;
35 with Prj
.Proc
; use Prj
.Proc
;
36 with Prj
.Tree
; use Prj
.Tree
;
37 with Prj
.Util
; use Prj
.Util
;
39 with Snames
; use Snames
;
41 with Ada
.Directories
; use Ada
.Directories
;
42 with Ada
.Exceptions
; use Ada
.Exceptions
;
44 with GNAT
.Case_Util
; use GNAT
.Case_Util
;
45 with GNAT
.HTable
; use GNAT
.HTable
;
47 package body Prj
.Conf
is
49 Auto_Cgpr
: constant String := "auto.cgpr";
51 Config_Project_Env_Var
: constant String := "GPR_CONFIG";
52 -- Name of the environment variable that provides the name of the
53 -- configuration file to use.
55 Gprconfig_Name
: constant String := "gprconfig";
57 package RTS_Languages
is new GNAT
.HTable
.Simple_HTable
58 (Header_Num
=> Prj
.Header_Num
,
60 No_Element
=> No_Name
,
64 -- Stores the runtime names for the various languages. This is in general
65 -- set from a --RTS command line option.
67 -----------------------
68 -- Local_Subprograms --
69 -----------------------
71 procedure Add_Attributes
72 (Project_Tree
: Project_Tree_Ref
;
73 Conf_Decl
: Declarations
;
74 User_Decl
: in out Declarations
);
75 -- Process the attributes in the config declarations.
76 -- For single string values, if the attribute is not declared in the user
77 -- declarations, declare it with the value in the config declarations.
78 -- For string list values, prepend the value in the user declarations with
79 -- the value in the config declarations.
82 (Config_File
: Prj
.Project_Id
;
83 Autoconf_Specified
: Boolean;
84 Project_Tree
: Prj
.Project_Tree_Ref
;
85 Target
: String := "") return Boolean;
86 -- Check that the config file's target matches Target.
87 -- Target should be set to the empty string when the user did not specify
88 -- a target. If the target in the configuration file is invalid, this
89 -- function will raise Invalid_Config with an appropriate message.
90 -- Autoconf_Specified should be set to True if the user has used
93 function Locate_Config_File
(Name
: String) return String_Access
;
94 -- Search for Name in the config files directory. Return full path if
95 -- found, or null otherwise.
97 procedure Raise_Invalid_Config
(Msg
: String);
98 pragma No_Return
(Raise_Invalid_Config
);
99 -- Raises exception Invalid_Config with given message
101 procedure Apply_Config_File
102 (Config_File
: Prj
.Project_Id
;
103 Project_Tree
: Prj
.Project_Tree_Ref
);
104 -- Apply the configuration file settings to all the projects in the
105 -- project tree. The Project_Tree must have been parsed first, and
106 -- processed through the first phase so that all its projects are known.
108 -- Currently, this will add new attributes and packages in the various
109 -- projects, so that when the second phase of the processing is performed
110 -- these attributes are automatically taken into account.
116 procedure Add_Attributes
117 (Project_Tree
: Project_Tree_Ref
;
118 Conf_Decl
: Declarations
;
119 User_Decl
: in out Declarations
)
121 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
122 Conf_Attr_Id
: Variable_Id
;
123 Conf_Attr
: Variable
;
124 Conf_Array_Id
: Array_Id
;
125 Conf_Array
: Array_Data
;
126 Conf_Array_Elem_Id
: Array_Element_Id
;
127 Conf_Array_Elem
: Array_Element
;
128 Conf_List
: String_List_Id
;
129 Conf_List_Elem
: String_Element
;
131 User_Attr_Id
: Variable_Id
;
132 User_Attr
: Variable
;
133 User_Array_Id
: Array_Id
;
134 User_Array
: Array_Data
;
135 User_Array_Elem_Id
: Array_Element_Id
;
136 User_Array_Elem
: Array_Element
;
139 Conf_Attr_Id
:= Conf_Decl
.Attributes
;
140 User_Attr_Id
:= User_Decl
.Attributes
;
141 while Conf_Attr_Id
/= No_Variable
loop
142 Conf_Attr
:= Shared
.Variable_Elements
.Table
(Conf_Attr_Id
);
143 User_Attr
:= Shared
.Variable_Elements
.Table
(User_Attr_Id
);
145 if not Conf_Attr
.Value
.Default
then
146 if User_Attr
.Value
.Default
then
148 -- No attribute declared in user project file: just copy the
149 -- value of the configuration attribute.
151 User_Attr
.Value
:= Conf_Attr
.Value
;
152 Shared
.Variable_Elements
.Table
(User_Attr_Id
) := User_Attr
;
154 elsif User_Attr
.Value
.Kind
= List
155 and then Conf_Attr
.Value
.Values
/= Nil_String
157 -- List attribute declared in both the user project and the
158 -- configuration project: prepend the user list with the
159 -- configuration list.
162 User_List
: constant String_List_Id
:=
163 User_Attr
.Value
.Values
;
164 Conf_List
: String_List_Id
:= Conf_Attr
.Value
.Values
;
165 Conf_Elem
: String_Element
;
166 New_List
: String_List_Id
;
167 New_Elem
: String_Element
;
172 String_Element_Table
.Increment_Last
173 (Shared
.String_Elements
);
175 String_Element_Table
.Last
(Shared
.String_Elements
);
177 -- Value of attribute is new list
179 User_Attr
.Value
.Values
:= New_List
;
180 Shared
.Variable_Elements
.Table
(User_Attr_Id
) := User_Attr
;
183 -- Get each element of configuration list
185 Conf_Elem
:= Shared
.String_Elements
.Table
(Conf_List
);
186 New_Elem
:= Conf_Elem
;
187 Conf_List
:= Conf_Elem
.Next
;
189 if Conf_List
= Nil_String
then
191 -- If it is the last element in the list, connect to
192 -- first element of user list, and we are done.
194 New_Elem
.Next
:= User_List
;
195 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
199 -- If it is not the last element in the list, add to
202 String_Element_Table
.Increment_Last
203 (Shared
.String_Elements
);
205 String_Element_Table
.Last
(Shared
.String_Elements
);
206 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
207 New_List
:= New_Elem
.Next
;
214 Conf_Attr_Id
:= Conf_Attr
.Next
;
215 User_Attr_Id
:= User_Attr
.Next
;
218 Conf_Array_Id
:= Conf_Decl
.Arrays
;
219 while Conf_Array_Id
/= No_Array
loop
220 Conf_Array
:= Shared
.Arrays
.Table
(Conf_Array_Id
);
222 User_Array_Id
:= User_Decl
.Arrays
;
223 while User_Array_Id
/= No_Array
loop
224 User_Array
:= Shared
.Arrays
.Table
(User_Array_Id
);
225 exit when User_Array
.Name
= Conf_Array
.Name
;
226 User_Array_Id
:= User_Array
.Next
;
229 -- If this associative array does not exist in the user project file,
230 -- do a shallow copy of the full associative array.
232 if User_Array_Id
= No_Array
then
233 Array_Table
.Increment_Last
(Shared
.Arrays
);
234 User_Array
:= Conf_Array
;
235 User_Array
.Next
:= User_Decl
.Arrays
;
236 User_Decl
.Arrays
:= Array_Table
.Last
(Shared
.Arrays
);
237 Shared
.Arrays
.Table
(User_Decl
.Arrays
) := User_Array
;
239 -- Otherwise, check each array element
242 Conf_Array_Elem_Id
:= Conf_Array
.Value
;
243 while Conf_Array_Elem_Id
/= No_Array_Element
loop
245 Shared
.Array_Elements
.Table
(Conf_Array_Elem_Id
);
247 User_Array_Elem_Id
:= User_Array
.Value
;
248 while User_Array_Elem_Id
/= No_Array_Element
loop
250 Shared
.Array_Elements
.Table
(User_Array_Elem_Id
);
251 exit when User_Array_Elem
.Index
= Conf_Array_Elem
.Index
;
252 User_Array_Elem_Id
:= User_Array_Elem
.Next
;
255 -- If the array element doesn't exist in the user array, insert
256 -- a shallow copy of the conf array element in the user array.
258 if User_Array_Elem_Id
= No_Array_Element
then
259 Array_Element_Table
.Increment_Last
(Shared
.Array_Elements
);
260 User_Array_Elem
:= Conf_Array_Elem
;
261 User_Array_Elem
.Next
:= User_Array
.Value
;
263 Array_Element_Table
.Last
(Shared
.Array_Elements
);
264 Shared
.Array_Elements
.Table
(User_Array
.Value
) :=
266 Shared
.Arrays
.Table
(User_Array_Id
) := User_Array
;
268 -- Otherwise, if the value is a string list, prepend the conf
269 -- array element value to the array element.
271 elsif Conf_Array_Elem
.Value
.Kind
= List
then
272 Conf_List
:= Conf_Array_Elem
.Value
.Values
;
274 if Conf_List
/= Nil_String
then
276 Link
: constant String_List_Id
:=
277 User_Array_Elem
.Value
.Values
;
278 Previous
: String_List_Id
:= Nil_String
;
279 Next
: String_List_Id
;
284 Shared
.String_Elements
.Table
(Conf_List
);
285 String_Element_Table
.Increment_Last
286 (Shared
.String_Elements
);
288 String_Element_Table
.Last
289 (Shared
.String_Elements
);
290 Shared
.String_Elements
.Table
(Next
) :=
293 if Previous
= Nil_String
then
294 User_Array_Elem
.Value
.Values
:= Next
;
295 Shared
.Array_Elements
.Table
296 (User_Array_Elem_Id
) := User_Array_Elem
;
299 Shared
.String_Elements
.Table
300 (Previous
).Next
:= Next
;
305 Conf_List
:= Conf_List_Elem
.Next
;
307 if Conf_List
= Nil_String
then
308 Shared
.String_Elements
.Table
(Previous
).Next
:=
317 Conf_Array_Elem_Id
:= Conf_Array_Elem
.Next
;
321 Conf_Array_Id
:= Conf_Array
.Next
;
325 ------------------------------------
326 -- Add_Default_GNAT_Naming_Scheme --
327 ------------------------------------
329 procedure Add_Default_GNAT_Naming_Scheme
330 (Config_File
: in out Project_Node_Id
;
331 Project_Tree
: Project_Node_Tree_Ref
)
333 procedure Create_Attribute
336 Index
: String := "";
337 Pkg
: Project_Node_Id
:= Empty_Node
);
339 ----------------------
340 -- Create_Attribute --
341 ----------------------
343 procedure Create_Attribute
346 Index
: String := "";
347 Pkg
: Project_Node_Id
:= Empty_Node
)
349 Attr
: Project_Node_Id
;
350 pragma Unreferenced
(Attr
);
352 Expr
: Name_Id
:= No_Name
;
353 Val
: Name_Id
:= No_Name
;
354 Parent
: Project_Node_Id
:= Config_File
;
358 Name_Len
:= Index
'Length;
359 Name_Buffer
(1 .. Name_Len
) := Index
;
363 if Pkg
/= Empty_Node
then
367 Name_Len
:= Value
'Length;
368 Name_Buffer
(1 .. Name_Len
) := Value
;
371 Attr
:= Create_Attribute
372 (Tree
=> Project_Tree
,
373 Prj_Or_Pkg
=> Parent
,
377 Value
=> Create_Literal_String
(Expr
, Project_Tree
));
378 end Create_Attribute
;
383 Naming
: Project_Node_Id
;
384 Compiler
: Project_Node_Id
;
386 -- Start of processing for Add_Default_GNAT_Naming_Scheme
389 if Config_File
= Empty_Node
then
391 -- Create a dummy config file is none was found
393 Name_Len
:= Auto_Cgpr
'Length;
394 Name_Buffer
(1 .. Name_Len
) := Auto_Cgpr
;
397 -- An invalid project name to avoid conflicts with user-created ones
400 Name_Buffer
(1 .. Name_Len
) := "_auto";
404 (In_Tree
=> Project_Tree
,
406 Full_Path
=> Path_Name_Type
(Name
),
407 Is_Config_File
=> True);
409 -- Setup library support
411 case MLib
.Tgt
.Support_For_Libraries
is
416 Create_Attribute
(Name_Library_Support
, "static_only");
419 Create_Attribute
(Name_Library_Support
, "full");
422 if MLib
.Tgt
.Standalone_Library_Auto_Init_Is_Supported
then
423 Create_Attribute
(Name_Library_Auto_Init_Supported
, "true");
425 Create_Attribute
(Name_Library_Auto_Init_Supported
, "false");
428 -- Setup Ada support (Ada is the default language here, since this
429 -- is only called when no config file existed initially, ie for
432 Create_Attribute
(Name_Default_Language
, "ada");
434 Compiler
:= Create_Package
(Project_Tree
, Config_File
, "compiler");
436 (Name_Driver
, "gcc", "ada", Pkg
=> Compiler
);
438 (Name_Language_Kind
, "unit_based", "ada", Pkg
=> Compiler
);
440 (Name_Dependency_Kind
, "ALI_File", "ada", Pkg
=> Compiler
);
442 Naming
:= Create_Package
(Project_Tree
, Config_File
, "naming");
443 Create_Attribute
(Name_Spec_Suffix
, ".ads", "ada", Pkg
=> Naming
);
444 Create_Attribute
(Name_Separate_Suffix
, ".adb", "ada", Pkg
=> Naming
);
445 Create_Attribute
(Name_Body_Suffix
, ".adb", "ada", Pkg
=> Naming
);
446 Create_Attribute
(Name_Dot_Replacement
, "-", Pkg
=> Naming
);
447 Create_Attribute
(Name_Casing
, "lowercase", Pkg
=> Naming
);
449 if Current_Verbosity
= High
then
450 Write_Line
("Automatically generated (in-memory) config file");
452 (Project
=> Config_File
,
453 In_Tree
=> Project_Tree
,
454 Backward_Compatibility
=> False);
457 end Add_Default_GNAT_Naming_Scheme
;
459 -----------------------
460 -- Apply_Config_File --
461 -----------------------
463 procedure Apply_Config_File
464 (Config_File
: Prj
.Project_Id
;
465 Project_Tree
: Prj
.Project_Tree_Ref
)
467 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
469 Conf_Decl
: constant Declarations
:= Config_File
.Decl
;
470 Conf_Pack_Id
: Package_Id
;
471 Conf_Pack
: Package_Element
;
473 User_Decl
: Declarations
;
474 User_Pack_Id
: Package_Id
;
475 User_Pack
: Package_Element
;
479 Debug_Output
("Applying config file to a project tree");
481 Proj
:= Project_Tree
.Projects
;
482 while Proj
/= null loop
483 if Proj
.Project
/= Config_File
then
484 User_Decl
:= Proj
.Project
.Decl
;
486 (Project_Tree
=> Project_Tree
,
487 Conf_Decl
=> Conf_Decl
,
488 User_Decl
=> User_Decl
);
490 Conf_Pack_Id
:= Conf_Decl
.Packages
;
491 while Conf_Pack_Id
/= No_Package
loop
492 Conf_Pack
:= Shared
.Packages
.Table
(Conf_Pack_Id
);
494 User_Pack_Id
:= User_Decl
.Packages
;
495 while User_Pack_Id
/= No_Package
loop
496 User_Pack
:= Shared
.Packages
.Table
(User_Pack_Id
);
497 exit when User_Pack
.Name
= Conf_Pack
.Name
;
498 User_Pack_Id
:= User_Pack
.Next
;
501 if User_Pack_Id
= No_Package
then
502 Package_Table
.Increment_Last
(Shared
.Packages
);
503 User_Pack
:= Conf_Pack
;
504 User_Pack
.Next
:= User_Decl
.Packages
;
505 User_Decl
.Packages
:= Package_Table
.Last
(Shared
.Packages
);
506 Shared
.Packages
.Table
(User_Decl
.Packages
) := User_Pack
;
510 (Project_Tree
=> Project_Tree
,
511 Conf_Decl
=> Conf_Pack
.Decl
,
512 User_Decl
=> Shared
.Packages
.Table
513 (User_Pack_Id
).Decl
);
516 Conf_Pack_Id
:= Conf_Pack
.Next
;
519 Proj
.Project
.Decl
:= User_Decl
;
521 -- For aggregate projects, we need to apply the config to all
522 -- their aggregated trees as well.
524 if Proj
.Project
.Qualifier
in Aggregate_Project
then
526 List
: Aggregated_Project_List
;
528 List
:= Proj
.Project
.Aggregated_Projects
;
529 while List
/= null loop
531 ("Recursively apply config to aggregated tree",
534 (Config_File
, Project_Tree
=> List
.Tree
);
543 end Apply_Config_File
;
549 function Check_Target
550 (Config_File
: Project_Id
;
551 Autoconf_Specified
: Boolean;
552 Project_Tree
: Prj
.Project_Tree_Ref
;
553 Target
: String := "") return Boolean
555 Shared
: constant Shared_Project_Tree_Data_Access
:=
557 Variable
: constant Variable_Value
:=
559 (Name_Target
, Config_File
.Decl
.Attributes
, Shared
);
560 Tgt_Name
: Name_Id
:= No_Name
;
564 if Variable
/= Nil_Variable_Value
and then not Variable
.Default
then
565 Tgt_Name
:= Variable
.Value
;
570 or else (Tgt_Name
/= No_Name
571 and then Target
= Get_Name_String
(Tgt_Name
));
574 if Autoconf_Specified
then
576 Write_Line
("inconsistent targets, performing autoconf");
582 if Tgt_Name
/= No_Name
then
584 ("invalid target name """
585 & Get_Name_String
(Tgt_Name
) & """ in configuration");
588 ("no target specified in configuration file");
596 --------------------------------------
597 -- Get_Or_Create_Configuration_File --
598 --------------------------------------
600 procedure Get_Or_Create_Configuration_File
601 (Project
: Project_Id
;
602 Conf_Project
: Project_Id
;
603 Project_Tree
: Project_Tree_Ref
;
604 Project_Node_Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
605 Env
: in out Prj
.Tree
.Environment
;
606 Allow_Automatic_Generation
: Boolean;
607 Config_File_Name
: String := "";
608 Autoconf_Specified
: Boolean;
609 Target_Name
: String := "";
610 Normalized_Hostname
: String;
611 Packages_To_Check
: String_List_Access
:= null;
612 Config
: out Prj
.Project_Id
;
613 Config_File_Path
: out String_Access
;
614 Automatically_Generated
: out Boolean;
615 On_Load_Config
: Config_File_Hook
:= null)
617 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
619 At_Least_One_Compiler_Command
: Boolean := False;
620 -- Set to True if at least one attribute Ide'Compiler_Command is
621 -- specified for one language of the system.
623 Conf_File_Name
: String_Access
:= new String'(Config_File_Name);
624 -- The configuration project file name. May be modified if there are
625 -- switches --config= in the Builder package of the main project.
627 Selected_Target : String_Access := new String'(Target_Name
);
629 function Default_File_Name
return String;
630 -- Return the name of the default config file that should be tested
632 procedure Do_Autoconf
;
633 -- Generate a new config file through gprconfig. In case of error, this
634 -- raises the Invalid_Config exception with an appropriate message
636 procedure Check_Builder_Switches
;
637 -- Check for switches --config and --RTS in package Builder
639 procedure Get_Project_Target
;
640 -- Target_Name is empty, get the specifiedtarget in the project file,
643 function Get_Config_Switches
return Argument_List_Access
;
644 -- Return the --config switches to use for gprconfig
646 function Get_Db_Switches
return Argument_List_Access
;
647 -- Return the --db switches to use for gprconfig
649 function Might_Have_Sources
(Project
: Project_Id
) return Boolean;
650 -- True if the specified project might have sources (ie the user has not
651 -- explicitly specified it. We haven't checked the file system, nor do
652 -- we need to at this stage.
654 ----------------------------
655 -- Check_Builder_Switches --
656 ----------------------------
658 procedure Check_Builder_Switches
is
659 Get_RTS_Switches
: constant Boolean :=
660 RTS_Languages
.Get_First
= No_Name
;
661 -- If no switch --RTS have been specified on the command line, look
662 -- for --RTS switches in the Builder switches.
664 Builder
: constant Package_Id
:=
665 Value_Of
(Name_Builder
, Project
.Decl
.Packages
, Shared
);
667 Switch_Array_Id
: Array_Element_Id
;
668 -- The Switches to be checked
670 procedure Check_Switches
;
671 -- Check the switches in Switch_Array_Id
677 procedure Check_Switches
is
678 Switch_Array
: Array_Element
;
679 Switch_List
: String_List_Id
:= Nil_String
;
680 Switch
: String_Element
;
682 Lang_Last
: Positive;
685 while Switch_Array_Id
/= No_Array_Element
loop
687 Shared
.Array_Elements
.Table
(Switch_Array_Id
);
689 Switch_List
:= Switch_Array
.Value
.Values
;
690 List_Loop
: while Switch_List
/= Nil_String
loop
691 Switch
:= Shared
.String_Elements
.Table
(Switch_List
);
693 if Switch
.Value
/= No_Name
then
694 Get_Name_String
(Switch
.Value
);
696 if Conf_File_Name
'Length = 0
697 and then Name_Len
> 9
698 and then Name_Buffer
(1 .. 9) = "--config="
701 new String'(Name_Buffer (10 .. Name_Len));
703 elsif Get_RTS_Switches
704 and then Name_Len >= 7
705 and then Name_Buffer (1 .. 5) = "--RTS"
707 if Name_Buffer (6) = '=' then
708 if not Runtime_Name_Set_For (Name_Ada) then
711 Name_Buffer (7 .. Name_Len));
712 Locate_Runtime (Name_Ada, Project_Tree);
716 and then Name_Buffer (6) = ':'
717 and then Name_Buffer (7) /= '='
720 while Lang_Last < Name_Len
721 and then Name_Buffer (Lang_Last + 1) /= '='
723 Lang_Last := Lang_Last + 1;
726 if Name_Buffer (Lang_Last + 1) = '=' then
728 RTS : constant String :=
729 Name_Buffer (Lang_Last + 2 .. Name_Len);
731 Name_Buffer (1 .. Lang_Last - 6) :=
732 Name_Buffer (7 .. Lang_Last);
733 Name_Len := Lang_Last - 6;
734 To_Lower (Name_Buffer (1 .. Name_Len));
737 if not Runtime_Name_Set_For (Lang) then
738 Set_Runtime_For (Lang, RTS);
739 Locate_Runtime (Lang, Project_Tree);
747 Switch_List := Switch.Next;
750 Switch_Array_Id := Switch_Array.Next;
754 -- Start of processing for Check_Builder_Switches
757 if Builder /= No_Package then
760 (Name => Name_Switches,
761 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
767 (Name => Name_Default_Switches,
768 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
772 end Check_Builder_Switches;
774 ------------------------
775 -- Get_Project_Target --
776 ------------------------
778 procedure Get_Project_Target is
780 if Selected_Target'Length = 0 then
782 -- Check if attribute Target is specified in the main
783 -- project, or in a project it extends. If it is, use this
784 -- target to invoke gprconfig.
787 Variable : Variable_Value;
789 Tgt_Name : Name_Id := No_Name;
794 while Proj /= No_Project loop
796 Value_Of (Name_Target, Proj.Decl.Attributes, Shared);
798 if Variable /= Nil_Variable_Value
799 and then not Variable.Default
800 and then Variable.Value /= No_Name
802 Tgt_Name := Variable.Value;
806 Proj := Proj.Extends;
807 end loop Project_Loop;
809 if Tgt_Name /= No_Name then
810 Selected_Target := new String'(Get_Name_String
(Tgt_Name
));
814 end Get_Project_Target
;
816 -----------------------
817 -- Default_File_Name --
818 -----------------------
820 function Default_File_Name
return String is
821 Ada_RTS
: constant String := Runtime_Name_For
(Name_Ada
);
825 if Selected_Target
'Length /= 0 then
826 if Ada_RTS
/= "" then
828 Selected_Target
.all & '-' &
829 Ada_RTS
& Config_Project_File_Extension
;
832 Selected_Target
.all & Config_Project_File_Extension
;
835 elsif Ada_RTS
/= "" then
836 return Ada_RTS
& Config_Project_File_Extension
;
839 Tmp
:= Getenv
(Config_Project_Env_Var
);
842 T
: constant String := Tmp
.all;
848 return Default_Config_Name
;
854 end Default_File_Name
;
860 procedure Do_Autoconf
is
861 Obj_Dir
: constant Variable_Value
:=
864 Conf_Project
.Decl
.Attributes
,
867 Gprconfig_Path
: String_Access
;
871 Gprconfig_Path
:= Locate_Exec_On_Path
(Gprconfig_Name
);
873 if Gprconfig_Path
= null then
875 ("could not locate gprconfig for auto-configuration");
878 -- First, find the object directory of the Conf_Project
880 if Obj_Dir
= Nil_Variable_Value
or else Obj_Dir
.Default
then
881 Get_Name_String
(Conf_Project
.Directory
.Display_Name
);
884 if Is_Absolute_Path
(Get_Name_String
(Obj_Dir
.Value
)) then
885 Get_Name_String
(Obj_Dir
.Value
);
889 Add_Str_To_Name_Buffer
890 (Get_Name_String
(Conf_Project
.Directory
.Display_Name
));
891 Add_Str_To_Name_Buffer
(Get_Name_String
(Obj_Dir
.Value
));
895 if Subdirs
/= null then
896 Add_Char_To_Name_Buffer
(Directory_Separator
);
897 Add_Str_To_Name_Buffer
(Subdirs
.all);
900 for J
in 1 .. Name_Len
loop
901 if Name_Buffer
(J
) = '/' then
902 Name_Buffer
(J
) := Directory_Separator
;
906 -- Make sure that Obj_Dir ends with a directory separator
908 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
909 Name_Len
:= Name_Len
+ 1;
910 Name_Buffer
(Name_Len
) := Directory_Separator
;
914 Obj_Dir
: constant String := Name_Buffer
(1 .. Name_Len
);
915 Config_Switches
: Argument_List_Access
;
916 Db_Switches
: Argument_List_Access
;
917 Args
: Argument_List
(1 .. 5);
919 Obj_Dir_Exists
: Boolean := True;
922 -- Check if the object directory exists. If Setup_Projects is True
923 -- (-p) and directory does not exist, attempt to create it.
924 -- Otherwise, if directory does not exist, fail without calling
927 if not Is_Directory
(Obj_Dir
)
928 and then (Setup_Projects
or else Subdirs
/= null)
931 Create_Path
(Obj_Dir
);
933 if not Quiet_Output
then
934 Write_Str
("object directory """);
936 Write_Line
(""" created");
942 ("could not create object directory " & Obj_Dir
);
946 if not Is_Directory
(Obj_Dir
) then
947 case Env
.Flags
.Require_Obj_Dirs
is
950 ("object directory " & Obj_Dir
& " does not exist");
955 "?object directory " & Obj_Dir
& " does not exist");
956 Obj_Dir_Exists
:= False;
963 -- Get the config switches. This should be done only now, as some
964 -- runtimes may have been found if the Builder switches.
966 Config_Switches
:= Get_Config_Switches
;
968 -- Get eventual --db switches
970 Db_Switches
:= Get_Db_Switches
;
974 Args
(1) := new String'("--batch");
975 Args (2) := new String'("-o");
977 -- If no config file was specified, set the auto.cgpr one
979 if Conf_File_Name
'Length = 0 then
980 if Obj_Dir_Exists
then
981 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
985 Path_FD : File_Descriptor;
986 Path_Name : Path_Name_Type;
989 Prj.Env.Create_Temp_File
990 (Shared => Project_Tree.Shared,
992 Path_Name => Path_Name,
993 File_Use => "configuration file");
995 if Path_FD /= Invalid_FD then
997 Temp_Dir : constant String :=
999 (Get_Name_String (Path_Name));
1001 GNAT.OS_Lib.Close (Path_FD);
1003 new String'(Temp_Dir
&
1004 Directory_Separator
&
1006 Delete_File
(Get_Name_String
(Path_Name
));
1010 -- We'll have an error message later on
1012 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
1017 Args (3) := Conf_File_Name;
1020 if Normalized_Hostname = "" then
1023 if Selected_Target'Length = 0 then
1024 if At_Least_One_Compiler_Command then
1026 new String'("--target=all");
1029 new String'("--target=" & Normalized_Hostname);
1034 new String'("--target=" & Selected_Target
.all);
1040 if not Verbose_Mode
then
1041 Arg_Last
:= Arg_Last
+ 1;
1042 Args
(Arg_Last
) := new String'("-q");
1045 if Verbose_Mode then
1046 Write_Str (Gprconfig_Name);
1048 for J in 1 .. Arg_Last loop
1050 Write_Str (Args (J).all);
1053 for J in Config_Switches'Range loop
1055 Write_Str (Config_Switches (J).all);
1058 for J in Db_Switches'Range loop
1060 Write_Str (Db_Switches (J).all);
1065 elsif not Quiet_Output then
1066 -- Display no message if we are creating auto.cgpr, unless in
1069 if Config_File_Name'Length > 0
1070 or else Verbose_Mode
1072 Write_Str ("creating ");
1073 Write_Str (Simple_Name (Args (3).all));
1078 Spawn (Gprconfig_Path.all, Args (1 .. Arg_Last) &
1079 Config_Switches.all & Db_Switches.all,
1082 Free (Config_Switches);
1084 Config_File_Path := Locate_Config_File (Args (3).all);
1086 if Config_File_Path = null then
1087 Raise_Invalid_Config
1088 ("could not create " & Args (3).all);
1091 for F in Args'Range loop
1097 ---------------------
1098 -- Get_Db_Switches --
1099 ---------------------
1101 function Get_Db_Switches return Argument_List_Access is
1102 Result : Argument_List_Access;
1106 (2 * Db_Switch_Args.Last) + Boolean'Pos (not Load_Standard_Base);
1107 Result := new Argument_List (1 .. Nmb_Arg);
1109 if Nmb_Arg /= 0 then
1110 for J in 1 .. Db_Switch_Args.Last loop
1111 Result (2 * J - 1) :=
1112 new String'("--db");
1114 new String'(Get_Name_String (Db_Switch_Args.Table (J)));
1117 if not Load_Standard_Base then
1118 Result (Result'Last) := new String'("--db-");
1123 end Get_Db_Switches
;
1125 -------------------------
1126 -- Get_Config_Switches --
1127 -------------------------
1129 function Get_Config_Switches
return Argument_List_Access
is
1131 package Language_Htable
is new GNAT
.HTable
.Simple_HTable
1132 (Header_Num
=> Prj
.Header_Num
,
1134 No_Element
=> No_Name
,
1138 -- Hash table to keep the languages used in the project tree
1140 IDE
: constant Package_Id
:=
1141 Value_Of
(Name_Ide
, Project
.Decl
.Packages
, Shared
);
1143 procedure Add_Config_Switches_For_Project
1144 (Project
: Project_Id
;
1145 Tree
: Project_Tree_Ref
;
1146 With_State
: in out Integer);
1147 -- Add all --config switches for this project. This is also called
1148 -- for aggregate projects.
1150 -------------------------------------
1151 -- Add_Config_Switches_For_Project --
1152 -------------------------------------
1154 procedure Add_Config_Switches_For_Project
1155 (Project
: Project_Id
;
1156 Tree
: Project_Tree_Ref
;
1157 With_State
: in out Integer)
1159 pragma Unreferenced
(With_State
);
1161 Shared
: constant Shared_Project_Tree_Data_Access
:= Tree
.Shared
;
1163 Variable
: Variable_Value
;
1164 Check_Default
: Boolean;
1166 List
: String_List_Id
;
1167 Elem
: String_Element
;
1170 if Might_Have_Sources
(Project
) then
1172 Value_Of
(Name_Languages
, Project
.Decl
.Attributes
, Shared
);
1174 if Variable
= Nil_Variable_Value
or else Variable
.Default
then
1176 -- Languages is not declared. If it is not an extending
1177 -- project, or if it extends a project with no Languages,
1178 -- check for Default_Language.
1180 Check_Default
:= Project
.Extends
= No_Project
;
1182 if not Check_Default
then
1186 Project
.Extends
.Decl
.Attributes
,
1189 Variable
/= Nil_Variable_Value
1190 and then Variable
.Values
= Nil_String
;
1193 if Check_Default
then
1196 (Name_Default_Language
,
1197 Project
.Decl
.Attributes
,
1200 if Variable
/= Nil_Variable_Value
1201 and then not Variable
.Default
1203 Get_Name_String
(Variable
.Value
);
1204 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1206 Language_Htable
.Set
(Lang
, Lang
);
1208 -- If no default language is declared, default to Ada
1211 Language_Htable
.Set
(Name_Ada
, Name_Ada
);
1215 elsif Variable
.Values
/= Nil_String
then
1217 -- Attribute Languages is declared with a non empty list:
1218 -- put all the languages in Language_HTable.
1220 List
:= Variable
.Values
;
1221 while List
/= Nil_String
loop
1222 Elem
:= Shared
.String_Elements
.Table
(List
);
1224 Get_Name_String
(Elem
.Value
);
1225 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1227 Language_Htable
.Set
(Lang
, Lang
);
1233 end Add_Config_Switches_For_Project
;
1235 procedure For_Every_Imported_Project
is new For_Every_Project_Imported
1236 (State
=> Integer, Action
=> Add_Config_Switches_For_Project
);
1237 -- Document this procedure ???
1243 Result
: Argument_List_Access
;
1244 Variable
: Variable_Value
;
1245 Dummy
: Integer := 0;
1247 -- Start of processing for Get_Config_Switches
1250 For_Every_Imported_Project
1252 Tree
=> Project_Tree
,
1253 With_State
=> Dummy
,
1254 Include_Aggregated
=> True);
1256 Name
:= Language_Htable
.Get_First
;
1258 while Name
/= No_Name
loop
1260 Name
:= Language_Htable
.Get_Next
;
1263 Result
:= new String_List
(1 .. Count
);
1266 Name
:= Language_Htable
.Get_First
;
1267 while Name
/= No_Name
loop
1269 -- Check if IDE'Compiler_Command is declared for the language.
1270 -- If it is, use its value to invoke gprconfig.
1275 Attribute_Or_Array_Name
=> Name_Compiler_Command
,
1278 Force_Lower_Case_Index
=> True);
1281 Config_Command
: constant String :=
1282 "--config=" & Get_Name_String
(Name
);
1284 Runtime_Name
: constant String :=
1285 Runtime_Name_For
(Name
);
1288 if Variable
= Nil_Variable_Value
1289 or else Length_Of_Name
(Variable
.Value
) = 0
1292 new String'(Config_Command & ",," & Runtime_Name);
1295 At_Least_One_Compiler_Command := True;
1298 Compiler_Command : constant String :=
1299 Get_Name_String (Variable.Value);
1302 if Is_Absolute_Path (Compiler_Command) then
1305 (Config_Command
& ",," & Runtime_Name
& "," &
1306 Containing_Directory
(Compiler_Command
) & "," &
1307 Simple_Name
(Compiler_Command
));
1311 (Config_Command & ",," & Runtime_Name & ",," &
1319 Name := Language_Htable.Get_Next;
1323 end Get_Config_Switches;
1325 ------------------------
1326 -- Might_Have_Sources --
1327 ------------------------
1329 function Might_Have_Sources (Project : Project_Id) return Boolean is
1330 Variable : Variable_Value;
1336 Project.Decl.Attributes,
1339 if Variable = Nil_Variable_Value
1340 or else Variable.Default
1341 or else Variable.Values /= Nil_String
1346 Project.Decl.Attributes,
1348 return Variable = Nil_Variable_Value
1349 or else Variable.Default
1350 or else Variable.Values /= Nil_String;
1355 end Might_Have_Sources;
1358 Config_Project_Node : Project_Node_Id := Empty_Node;
1361 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1363 Free (Config_File_Path);
1364 Config := No_Project;
1367 Check_Builder_Switches;
1369 if Conf_File_Name'Length > 0 then
1370 Config_File_Path := Locate_Config_File (Conf_File_Name.all);
1372 Config_File_Path := Locate_Config_File (Default_File_Name);
1375 if Config_File_Path = null then
1376 if not Allow_Automatic_Generation
1377 and then Conf_File_Name'Length > 0
1379 Raise_Invalid_Config
1380 ("could not locate main configuration project "
1381 & Conf_File_Name.all);
1385 Automatically_Generated :=
1386 Allow_Automatic_Generation and then Config_File_Path = null;
1388 <<Process_Config_File>>
1390 if Automatically_Generated then
1391 if Hostparm.OpenVMS then
1393 -- There is no gprconfig on VMS
1395 Raise_Invalid_Config
1396 ("could not locate any configuration project file");
1399 -- This might raise an Invalid_Config exception
1404 -- If the config file is not auto-generated, warn if there is any --RTS
1405 -- switch, but not when the config file is generated in memory.
1407 elsif RTS_Languages.Get_First /= No_Name
1408 and then Opt.Warning_Mode /= Opt.Suppress
1409 and then On_Load_Config = null
1412 ("warning: --RTS is taken into account only in auto-configuration");
1415 -- Parse the configuration file
1417 if Verbose_Mode and then Config_File_Path /= null then
1418 Write_Str ("Checking configuration ");
1419 Write_Line (Config_File_Path.all);
1422 if On_Load_Config /= null then
1424 (Config_File => Config_Project_Node,
1425 Project_Node_Tree => Project_Node_Tree);
1427 elsif Config_File_Path /= null then
1429 (In_Tree => Project_Node_Tree,
1430 Project => Config_Project_Node,
1431 Project_File_Name => Config_File_Path.all,
1432 Errout_Handling => Prj.Part.Finalize_If_Error,
1433 Packages_To_Check => Packages_To_Check,
1434 Current_Directory => Current_Directory,
1435 Is_Config_File => True,
1438 Config_Project_Node := Empty_Node;
1441 if Config_Project_Node /= Empty_Node then
1442 Prj.Proc.Process_Project_Tree_Phase_1
1443 (In_Tree => Project_Tree,
1445 Packages_To_Check => Packages_To_Check,
1447 From_Project_Node => Config_Project_Node,
1448 From_Project_Node_Tree => Project_Node_Tree,
1450 Reset_Tree => False);
1453 if Config_Project_Node = Empty_Node
1454 or else Config = No_Project
1456 Raise_Invalid_Config
1457 ("processing of configuration project """
1458 & Config_File_Path.all & """ failed");
1461 -- Check that the target of the configuration file is the one the user
1462 -- specified on the command line. We do not need to check that when in
1463 -- auto-conf mode, since the appropriate target was passed to gprconfig.
1465 if not Automatically_Generated
1468 (Config, Autoconf_Specified, Project_Tree, Selected_Target.all)
1470 Automatically_Generated := True;
1471 goto Process_Config_File;
1473 end Get_Or_Create_Configuration_File;
1475 ------------------------
1476 -- Locate_Config_File --
1477 ------------------------
1479 function Locate_Config_File (Name : String) return String_Access is
1480 Prefix_Path : constant String := Executable_Prefix_Path;
1482 if Prefix_Path'Length /= 0 then
1483 return Locate_Regular_File
1485 "." & Path_Separator &
1486 Prefix_Path & "share" & Directory_Separator & "gpr");
1488 return Locate_Regular_File (Name, ".");
1490 end Locate_Config_File;
1492 --------------------
1493 -- Locate_Runtime --
1494 --------------------
1496 procedure Locate_Runtime
1497 (Language : Name_Id;
1498 Project_Tree : Prj.Project_Tree_Ref)
1500 function Is_Base_Name (Path : String) return Boolean;
1501 -- Returns True if Path has no directory separator
1507 function Is_Base_Name (Path : String) return Boolean is
1509 for I in Path'Range loop
1510 if Path (I) = Directory_Separator or else Path (I) = '/' then
1517 -- Local declarations
1519 function Find_Rts_In_Path is new Prj.Env.Find_Name_In_Path
1520 (Check_Filename => Is_Directory);
1522 RTS_Name : constant String := Runtime_Name_For (Language);
1524 Full_Path : String_Access;
1526 -- Start of processing for Locate_Runtime
1529 if not Is_Base_Name (RTS_Name) then
1531 Find_Rts_In_Path (Root_Environment.Project_Path, RTS_Name);
1533 if Full_Path = null then
1534 Fail_Program (Project_Tree, "cannot find RTS " & RTS_Name);
1537 Set_Runtime_For (Language, Normalize_Pathname (Full_Path.all));
1542 ------------------------------------
1543 -- Parse_Project_And_Apply_Config --
1544 ------------------------------------
1546 procedure Parse_Project_And_Apply_Config
1547 (Main_Project : out Prj.Project_Id;
1548 User_Project_Node : out Prj.Tree.Project_Node_Id;
1549 Config_File_Name : String := "";
1550 Autoconf_Specified : Boolean;
1551 Project_File_Name : String;
1552 Project_Tree : Prj.Project_Tree_Ref;
1553 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1554 Env : in out Prj.Tree.Environment;
1555 Packages_To_Check : String_List_Access;
1556 Allow_Automatic_Generation : Boolean := True;
1557 Automatically_Generated : out Boolean;
1558 Config_File_Path : out String_Access;
1559 Target_Name : String := "";
1560 Normalized_Hostname : String;
1561 On_Load_Config : Config_File_Hook := null;
1562 Implicit_Project : Boolean := False)
1565 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1567 -- Parse the user project tree
1569 Prj.Initialize (Project_Tree);
1571 Main_Project := No_Project;
1572 Automatically_Generated := False;
1575 (In_Tree => Project_Node_Tree,
1576 Project => User_Project_Node,
1577 Project_File_Name => Project_File_Name,
1578 Errout_Handling => Prj.Part.Finalize_If_Error,
1579 Packages_To_Check => Packages_To_Check,
1580 Current_Directory => Current_Directory,
1581 Is_Config_File => False,
1583 Implicit_Project => Implicit_Project);
1585 if User_Project_Node = Empty_Node then
1586 User_Project_Node := Empty_Node;
1590 Process_Project_And_Apply_Config
1591 (Main_Project => Main_Project,
1592 User_Project_Node => User_Project_Node,
1593 Config_File_Name => Config_File_Name,
1594 Autoconf_Specified => Autoconf_Specified,
1595 Project_Tree => Project_Tree,
1596 Project_Node_Tree => Project_Node_Tree,
1598 Packages_To_Check => Packages_To_Check,
1599 Allow_Automatic_Generation => Allow_Automatic_Generation,
1600 Automatically_Generated => Automatically_Generated,
1601 Config_File_Path => Config_File_Path,
1602 Target_Name => Target_Name,
1603 Normalized_Hostname => Normalized_Hostname,
1604 On_Load_Config => On_Load_Config);
1605 end Parse_Project_And_Apply_Config;
1607 --------------------------------------
1608 -- Process_Project_And_Apply_Config --
1609 --------------------------------------
1611 procedure Process_Project_And_Apply_Config
1612 (Main_Project : out Prj.Project_Id;
1613 User_Project_Node : Prj.Tree.Project_Node_Id;
1614 Config_File_Name : String := "";
1615 Autoconf_Specified : Boolean;
1616 Project_Tree : Prj.Project_Tree_Ref;
1617 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1618 Env : in out Prj.Tree.Environment;
1619 Packages_To_Check : String_List_Access;
1620 Allow_Automatic_Generation : Boolean := True;
1621 Automatically_Generated : out Boolean;
1622 Config_File_Path : out String_Access;
1623 Target_Name : String := "";
1624 Normalized_Hostname : String;
1625 On_Load_Config : Config_File_Hook := null;
1626 Reset_Tree : Boolean := True)
1628 Shared : constant Shared_Project_Tree_Data_Access :=
1629 Project_Tree.Shared;
1630 Main_Config_Project : Project_Id;
1633 Conf_Project : Project_Id := No_Project;
1634 -- The object directory of this project is used to store the config
1635 -- project file in auto-configuration. Set by Check_Project below.
1637 procedure Check_Project (Project : Project_Id);
1638 -- Look for a non aggregate project. If one is found, put its project Id
1645 procedure Check_Project (Project : Project_Id) is
1647 if Project.Qualifier = Aggregate
1649 Project.Qualifier = Aggregate_Library
1652 List : Aggregated_Project_List := Project.Aggregated_Projects;
1655 -- Look for a non aggregate project until one is found
1657 while Conf_Project = No_Project and then List /= null loop
1658 Check_Project (List.Project);
1664 Conf_Project := Project;
1668 -- Start of processing for Process_Project_And_Apply_Config
1671 Main_Project := No_Project;
1672 Automatically_Generated := False;
1674 Process_Project_Tree_Phase_1
1675 (In_Tree => Project_Tree,
1676 Project => Main_Project,
1677 Packages_To_Check => Packages_To_Check,
1679 From_Project_Node => User_Project_Node,
1680 From_Project_Node_Tree => Project_Node_Tree,
1682 Reset_Tree => Reset_Tree);
1685 Main_Project := No_Project;
1689 if Project_Tree.Source_Info_File_Name /= null then
1690 if not Is_Absolute_Path (Project_Tree.Source_Info_File_Name.all) then
1692 Obj_Dir : constant Variable_Value :=
1695 Main_Project.Decl.Attributes,
1699 if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then
1700 Get_Name_String (Main_Project.Directory.Display_Name);
1703 if Is_Absolute_Path (Get_Name_String (Obj_Dir.Value)) then
1704 Get_Name_String (Obj_Dir.Value);
1708 Add_Str_To_Name_Buffer
1709 (Get_Name_String (Main_Project.Directory.Display_Name));
1710 Add_Str_To_Name_Buffer (Get_Name_String (Obj_Dir.Value));
1714 Add_Char_To_Name_Buffer (Directory_Separator);
1715 Add_Str_To_Name_Buffer (Project_Tree.Source_Info_File_Name.all);
1716 Free (Project_Tree.Source_Info_File_Name);
1717 Project_Tree.Source_Info_File_Name :=
1718 new String'(Name_Buffer
(1 .. Name_Len
));
1722 Read_Source_Info_File
(Project_Tree
);
1725 -- Get the first project that is not an aggregate project or an
1726 -- aggregate library project. The object directory of this project will
1727 -- be used to store the config project file in auto-configuration.
1729 Check_Project
(Main_Project
);
1731 -- Fail if there is only aggregate projects and aggregate library
1732 -- projects in the project tree.
1734 if Conf_Project
= No_Project
then
1735 Raise_Invalid_Config
("there are no non-aggregate projects");
1738 -- Find configuration file
1740 Get_Or_Create_Configuration_File
1741 (Config
=> Main_Config_Project
,
1742 Project
=> Main_Project
,
1743 Conf_Project
=> Conf_Project
,
1744 Project_Tree
=> Project_Tree
,
1745 Project_Node_Tree
=> Project_Node_Tree
,
1747 Allow_Automatic_Generation
=> Allow_Automatic_Generation
,
1748 Config_File_Name
=> Config_File_Name
,
1749 Autoconf_Specified
=> Autoconf_Specified
,
1750 Target_Name
=> Target_Name
,
1751 Normalized_Hostname
=> Normalized_Hostname
,
1752 Packages_To_Check
=> Packages_To_Check
,
1753 Config_File_Path
=> Config_File_Path
,
1754 Automatically_Generated
=> Automatically_Generated
,
1755 On_Load_Config
=> On_Load_Config
);
1757 Apply_Config_File
(Main_Config_Project
, Project_Tree
);
1759 -- Finish processing the user's project
1761 Prj
.Proc
.Process_Project_Tree_Phase_2
1762 (In_Tree
=> Project_Tree
,
1763 Project
=> Main_Project
,
1765 From_Project_Node
=> User_Project_Node
,
1766 From_Project_Node_Tree
=> Project_Node_Tree
,
1770 if Project_Tree
.Source_Info_File_Name
/= null
1771 and then not Project_Tree
.Source_Info_File_Exists
1773 Write_Source_Info_File
(Project_Tree
);
1777 Main_Project
:= No_Project
;
1779 end Process_Project_And_Apply_Config
;
1781 --------------------------
1782 -- Raise_Invalid_Config --
1783 --------------------------
1785 procedure Raise_Invalid_Config
(Msg
: String) is
1787 Raise_Exception
(Invalid_Config
'Identity, Msg
);
1788 end Raise_Invalid_Config
;
1790 ----------------------
1791 -- Runtime_Name_For --
1792 ----------------------
1794 function Runtime_Name_For
(Language
: Name_Id
) return String is
1796 if RTS_Languages
.Get
(Language
) /= No_Name
then
1797 return Get_Name_String
(RTS_Languages
.Get
(Language
));
1801 end Runtime_Name_For
;
1803 --------------------------
1804 -- Runtime_Name_Set_For --
1805 --------------------------
1807 function Runtime_Name_Set_For
(Language
: Name_Id
) return Boolean is
1809 return RTS_Languages
.Get
(Language
) /= No_Name
;
1810 end Runtime_Name_Set_For
;
1812 ---------------------
1813 -- Set_Runtime_For --
1814 ---------------------
1816 procedure Set_Runtime_For
(Language
: Name_Id
; RTS_Name
: String) is
1818 Name_Len
:= RTS_Name
'Length;
1819 Name_Buffer
(1 .. Name_Len
) := RTS_Name
;
1820 RTS_Languages
.Set
(Language
, Name_Find
);
1821 end Set_Runtime_For
;