1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2006-2014, 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 ------------------------------------------------------------------------------
26 with Makeutl
; use Makeutl
;
29 with Output
; use Output
;
34 with Prj
.Proc
; use Prj
.Proc
;
35 with Prj
.Tree
; use Prj
.Tree
;
36 with Prj
.Util
; use Prj
.Util
;
38 with Snames
; use Snames
;
40 with Ada
.Directories
; use Ada
.Directories
;
41 with Ada
.Exceptions
; use Ada
.Exceptions
;
43 with GNAT
.Case_Util
; use GNAT
.Case_Util
;
44 with GNAT
.HTable
; use GNAT
.HTable
;
46 package body Prj
.Conf
is
48 Auto_Cgpr
: constant String := "auto.cgpr";
50 Config_Project_Env_Var
: constant String := "GPR_CONFIG";
51 -- Name of the environment variable that provides the name of the
52 -- configuration file to use.
54 Gprconfig_Name
: constant String := "gprconfig";
56 package RTS_Languages
is new GNAT
.HTable
.Simple_HTable
57 (Header_Num
=> Prj
.Header_Num
,
59 No_Element
=> No_Name
,
63 -- Stores the runtime names for the various languages. This is in general
64 -- set from a --RTS command line option.
66 procedure Locate_Runtime
68 Env
: Prj
.Tree
.Environment
);
69 -- If RTS_Name is a base name (a name without path separator), then
70 -- do nothing. Otherwise, convert it to an absolute path (possibly by
71 -- searching it in the project path) and call Set_Runtime_For with the
72 -- absolute path. Raise Invalid_Config if the path does not exist.
74 -----------------------
75 -- Local_Subprograms --
76 -----------------------
79 (Config_File
: Prj
.Project_Id
;
80 Autoconf_Specified
: Boolean;
81 Project_Tree
: Prj
.Project_Tree_Ref
;
82 Target
: String := "") return Boolean;
83 -- Check that the config file's target matches Target.
84 -- Target should be set to the empty string when the user did not specify
85 -- a target. If the target in the configuration file is invalid, this
86 -- function will raise Invalid_Config with an appropriate message.
87 -- Autoconf_Specified should be set to True if the user has used
90 function Locate_Config_File
(Name
: String) return String_Access
;
91 -- Search for Name in the config files directory. Return full path if
92 -- found, or null otherwise.
94 procedure Raise_Invalid_Config
(Msg
: String);
95 pragma No_Return
(Raise_Invalid_Config
);
96 -- Raises exception Invalid_Config with given message
98 procedure Apply_Config_File
99 (Config_File
: Prj
.Project_Id
;
100 Project_Tree
: Prj
.Project_Tree_Ref
);
101 -- Apply the configuration file settings to all the projects in the
102 -- project tree. The Project_Tree must have been parsed first, and
103 -- processed through the first phase so that all its projects are known.
105 -- Currently, this will add new attributes and packages in the various
106 -- projects, so that when the second phase of the processing is performed
107 -- these attributes are automatically taken into account.
109 ------------------------------------
110 -- Add_Default_GNAT_Naming_Scheme --
111 ------------------------------------
113 procedure Add_Default_GNAT_Naming_Scheme
114 (Config_File
: in out Project_Node_Id
;
115 Project_Tree
: Project_Node_Tree_Ref
)
117 procedure Create_Attribute
120 Index
: String := "";
121 Pkg
: Project_Node_Id
:= Empty_Node
);
123 ----------------------
124 -- Create_Attribute --
125 ----------------------
127 procedure Create_Attribute
130 Index
: String := "";
131 Pkg
: Project_Node_Id
:= Empty_Node
)
133 Attr
: Project_Node_Id
;
134 pragma Unreferenced
(Attr
);
136 Expr
: Name_Id
:= No_Name
;
137 Val
: Name_Id
:= No_Name
;
138 Parent
: Project_Node_Id
:= Config_File
;
142 Name_Len
:= Index
'Length;
143 Name_Buffer
(1 .. Name_Len
) := Index
;
147 if Pkg
/= Empty_Node
then
151 Name_Len
:= Value
'Length;
152 Name_Buffer
(1 .. Name_Len
) := Value
;
155 Attr
:= Create_Attribute
156 (Tree
=> Project_Tree
,
157 Prj_Or_Pkg
=> Parent
,
161 Value
=> Create_Literal_String
(Expr
, Project_Tree
));
162 end Create_Attribute
;
167 Naming
: Project_Node_Id
;
168 Compiler
: Project_Node_Id
;
170 -- Start of processing for Add_Default_GNAT_Naming_Scheme
173 if Config_File
= Empty_Node
then
175 -- Create a dummy config file is none was found
177 Name_Len
:= Auto_Cgpr
'Length;
178 Name_Buffer
(1 .. Name_Len
) := Auto_Cgpr
;
181 -- An invalid project name to avoid conflicts with user-created ones
184 Name_Buffer
(1 .. Name_Len
) := "_auto";
188 (In_Tree
=> Project_Tree
,
190 Full_Path
=> Path_Name_Type
(Name
),
191 Is_Config_File
=> True);
193 -- Setup library support
195 case MLib
.Tgt
.Support_For_Libraries
is
200 Create_Attribute
(Name_Library_Support
, "static_only");
203 Create_Attribute
(Name_Library_Support
, "full");
206 if MLib
.Tgt
.Standalone_Library_Auto_Init_Is_Supported
then
207 Create_Attribute
(Name_Library_Auto_Init_Supported
, "true");
209 Create_Attribute
(Name_Library_Auto_Init_Supported
, "false");
212 -- Declare an empty target
214 Create_Attribute
(Name_Target
, "");
216 -- Setup Ada support (Ada is the default language here, since this
217 -- is only called when no config file existed initially, ie for
220 Create_Attribute
(Name_Default_Language
, "ada");
222 Compiler
:= Create_Package
(Project_Tree
, Config_File
, "compiler");
224 (Name_Driver
, "gcc", "ada", Pkg
=> Compiler
);
226 (Name_Language_Kind
, "unit_based", "ada", Pkg
=> Compiler
);
228 (Name_Dependency_Kind
, "ALI_File", "ada", Pkg
=> Compiler
);
230 Naming
:= Create_Package
(Project_Tree
, Config_File
, "naming");
231 Create_Attribute
(Name_Spec_Suffix
, ".ads", "ada", Pkg
=> Naming
);
232 Create_Attribute
(Name_Separate_Suffix
, ".adb", "ada", Pkg
=> Naming
);
233 Create_Attribute
(Name_Body_Suffix
, ".adb", "ada", Pkg
=> Naming
);
234 Create_Attribute
(Name_Dot_Replacement
, "-", Pkg
=> Naming
);
235 Create_Attribute
(Name_Casing
, "lowercase", Pkg
=> Naming
);
237 if Current_Verbosity
= High
then
238 Write_Line
("Automatically generated (in-memory) config file");
240 (Project
=> Config_File
,
241 In_Tree
=> Project_Tree
,
242 Backward_Compatibility
=> False);
245 end Add_Default_GNAT_Naming_Scheme
;
247 -----------------------
248 -- Apply_Config_File --
249 -----------------------
251 procedure Apply_Config_File
252 (Config_File
: Prj
.Project_Id
;
253 Project_Tree
: Prj
.Project_Tree_Ref
)
255 procedure Add_Attributes
256 (Project_Tree
: Project_Tree_Ref
;
257 Conf_Decl
: Declarations
;
258 User_Decl
: in out Declarations
);
259 -- Process the attributes in the config declarations. For
260 -- single string values, if the attribute is not declared in
261 -- the user declarations, declare it with the value in the
262 -- config declarations. For string list values, prepend the
263 -- value in the user declarations with the value in the config
270 procedure Add_Attributes
271 (Project_Tree
: Project_Tree_Ref
;
272 Conf_Decl
: Declarations
;
273 User_Decl
: in out Declarations
)
275 Shared
: constant Shared_Project_Tree_Data_Access
:=
277 Conf_Attr_Id
: Variable_Id
;
278 Conf_Attr
: Variable
;
279 Conf_Array_Id
: Array_Id
;
280 Conf_Array
: Array_Data
;
281 Conf_Array_Elem_Id
: Array_Element_Id
;
282 Conf_Array_Elem
: Array_Element
;
283 Conf_List
: String_List_Id
;
284 Conf_List_Elem
: String_Element
;
286 User_Attr_Id
: Variable_Id
;
287 User_Attr
: Variable
;
288 User_Array_Id
: Array_Id
;
289 User_Array
: Array_Data
;
290 User_Array_Elem_Id
: Array_Element_Id
;
291 User_Array_Elem
: Array_Element
;
294 Conf_Attr_Id
:= Conf_Decl
.Attributes
;
295 User_Attr_Id
:= User_Decl
.Attributes
;
297 while Conf_Attr_Id
/= No_Variable
loop
298 Conf_Attr
:= Shared
.Variable_Elements
.Table
(Conf_Attr_Id
);
299 User_Attr
:= Shared
.Variable_Elements
.Table
(User_Attr_Id
);
301 if not Conf_Attr
.Value
.Default
then
302 if User_Attr
.Value
.Default
then
304 -- No attribute declared in user project file: just copy
305 -- the value of the configuration attribute.
307 User_Attr
.Value
:= Conf_Attr
.Value
;
308 Shared
.Variable_Elements
.Table
(User_Attr_Id
) := User_Attr
;
310 elsif User_Attr
.Value
.Kind
= List
311 and then Conf_Attr
.Value
.Values
/= Nil_String
313 -- List attribute declared in both the user project and the
314 -- configuration project: prepend the user list with the
315 -- configuration list.
318 User_List
: constant String_List_Id
:=
319 User_Attr
.Value
.Values
;
320 Conf_List
: String_List_Id
:= Conf_Attr
.Value
.Values
;
321 Conf_Elem
: String_Element
;
322 New_List
: String_List_Id
;
323 New_Elem
: String_Element
;
328 String_Element_Table
.Increment_Last
329 (Shared
.String_Elements
);
331 String_Element_Table
.Last
(Shared
.String_Elements
);
333 -- Value of attribute is new list
335 User_Attr
.Value
.Values
:= New_List
;
336 Shared
.Variable_Elements
.Table
(User_Attr_Id
) :=
340 -- Get each element of configuration list
342 Conf_Elem
:= Shared
.String_Elements
.Table
(Conf_List
);
343 New_Elem
:= Conf_Elem
;
344 Conf_List
:= Conf_Elem
.Next
;
346 if Conf_List
= Nil_String
then
348 -- If it is the last element in the list, connect
349 -- to first element of user list, and we are done.
351 New_Elem
.Next
:= User_List
;
352 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
356 -- If it is not the last element in the list, add
359 String_Element_Table
.Increment_Last
360 (Shared
.String_Elements
);
361 New_Elem
.Next
:= String_Element_Table
.Last
362 (Shared
.String_Elements
);
363 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
364 New_List
:= New_Elem
.Next
;
371 Conf_Attr_Id
:= Conf_Attr
.Next
;
372 User_Attr_Id
:= User_Attr
.Next
;
375 Conf_Array_Id
:= Conf_Decl
.Arrays
;
376 while Conf_Array_Id
/= No_Array
loop
377 Conf_Array
:= Shared
.Arrays
.Table
(Conf_Array_Id
);
379 User_Array_Id
:= User_Decl
.Arrays
;
380 while User_Array_Id
/= No_Array
loop
381 User_Array
:= Shared
.Arrays
.Table
(User_Array_Id
);
382 exit when User_Array
.Name
= Conf_Array
.Name
;
383 User_Array_Id
:= User_Array
.Next
;
386 -- If this associative array does not exist in the user project
387 -- file, do a shallow copy of the full associative array.
389 if User_Array_Id
= No_Array
then
390 Array_Table
.Increment_Last
(Shared
.Arrays
);
391 User_Array
:= Conf_Array
;
392 User_Array
.Next
:= User_Decl
.Arrays
;
393 User_Decl
.Arrays
:= Array_Table
.Last
(Shared
.Arrays
);
394 Shared
.Arrays
.Table
(User_Decl
.Arrays
) := User_Array
;
396 -- Otherwise, check each array element
399 Conf_Array_Elem_Id
:= Conf_Array
.Value
;
400 while Conf_Array_Elem_Id
/= No_Array_Element
loop
402 Shared
.Array_Elements
.Table
(Conf_Array_Elem_Id
);
404 User_Array_Elem_Id
:= User_Array
.Value
;
405 while User_Array_Elem_Id
/= No_Array_Element
loop
407 Shared
.Array_Elements
.Table
(User_Array_Elem_Id
);
408 exit when User_Array_Elem
.Index
= Conf_Array_Elem
.Index
;
409 User_Array_Elem_Id
:= User_Array_Elem
.Next
;
412 -- If the array element doesn't exist in the user array,
413 -- insert a shallow copy of the conf array element in the
416 if User_Array_Elem_Id
= No_Array_Element
then
417 Array_Element_Table
.Increment_Last
418 (Shared
.Array_Elements
);
419 User_Array_Elem
:= Conf_Array_Elem
;
420 User_Array_Elem
.Next
:= User_Array
.Value
;
422 Array_Element_Table
.Last
(Shared
.Array_Elements
);
423 Shared
.Array_Elements
.Table
(User_Array
.Value
) :=
425 Shared
.Arrays
.Table
(User_Array_Id
) := User_Array
;
427 -- Otherwise, if the value is a string list, prepend the
428 -- conf array element value to the array element.
430 elsif Conf_Array_Elem
.Value
.Kind
= List
then
431 Conf_List
:= Conf_Array_Elem
.Value
.Values
;
433 if Conf_List
/= Nil_String
then
435 Link
: constant String_List_Id
:=
436 User_Array_Elem
.Value
.Values
;
437 Previous
: String_List_Id
:= Nil_String
;
438 Next
: String_List_Id
;
443 Shared
.String_Elements
.Table
(Conf_List
);
444 String_Element_Table
.Increment_Last
445 (Shared
.String_Elements
);
447 String_Element_Table
.Last
448 (Shared
.String_Elements
);
449 Shared
.String_Elements
.Table
(Next
) :=
452 if Previous
= Nil_String
then
453 User_Array_Elem
.Value
.Values
:= Next
;
454 Shared
.Array_Elements
.Table
455 (User_Array_Elem_Id
) := User_Array_Elem
;
458 Shared
.String_Elements
.Table
459 (Previous
).Next
:= Next
;
464 Conf_List
:= Conf_List_Elem
.Next
;
466 if Conf_List
= Nil_String
then
467 Shared
.String_Elements
.Table
468 (Previous
).Next
:= Link
;
476 Conf_Array_Elem_Id
:= Conf_Array_Elem
.Next
;
480 Conf_Array_Id
:= Conf_Array
.Next
;
484 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
486 Conf_Decl
: constant Declarations
:= Config_File
.Decl
;
487 Conf_Pack_Id
: Package_Id
;
488 Conf_Pack
: Package_Element
;
490 User_Decl
: Declarations
;
491 User_Pack_Id
: Package_Id
;
492 User_Pack
: Package_Element
;
496 Debug_Output
("Applying config file to a project tree");
498 Proj
:= Project_Tree
.Projects
;
499 while Proj
/= null loop
500 if Proj
.Project
/= Config_File
then
501 User_Decl
:= Proj
.Project
.Decl
;
503 (Project_Tree
=> Project_Tree
,
504 Conf_Decl
=> Conf_Decl
,
505 User_Decl
=> User_Decl
);
507 Conf_Pack_Id
:= Conf_Decl
.Packages
;
508 while Conf_Pack_Id
/= No_Package
loop
509 Conf_Pack
:= Shared
.Packages
.Table
(Conf_Pack_Id
);
511 User_Pack_Id
:= User_Decl
.Packages
;
512 while User_Pack_Id
/= No_Package
loop
513 User_Pack
:= Shared
.Packages
.Table
(User_Pack_Id
);
514 exit when User_Pack
.Name
= Conf_Pack
.Name
;
515 User_Pack_Id
:= User_Pack
.Next
;
518 if User_Pack_Id
= No_Package
then
519 Package_Table
.Increment_Last
(Shared
.Packages
);
520 User_Pack
:= Conf_Pack
;
521 User_Pack
.Next
:= User_Decl
.Packages
;
522 User_Decl
.Packages
:= Package_Table
.Last
(Shared
.Packages
);
523 Shared
.Packages
.Table
(User_Decl
.Packages
) := User_Pack
;
527 (Project_Tree
=> Project_Tree
,
528 Conf_Decl
=> Conf_Pack
.Decl
,
529 User_Decl
=> Shared
.Packages
.Table
530 (User_Pack_Id
).Decl
);
533 Conf_Pack_Id
:= Conf_Pack
.Next
;
536 Proj
.Project
.Decl
:= User_Decl
;
538 -- For aggregate projects, we need to apply the config to all
539 -- their aggregated trees as well.
541 if Proj
.Project
.Qualifier
in Aggregate_Project
then
543 List
: Aggregated_Project_List
;
545 List
:= Proj
.Project
.Aggregated_Projects
;
546 while List
/= null loop
548 ("Recursively apply config to aggregated tree",
551 (Config_File
, Project_Tree
=> List
.Tree
);
560 end Apply_Config_File
;
566 function Check_Target
567 (Config_File
: Project_Id
;
568 Autoconf_Specified
: Boolean;
569 Project_Tree
: Prj
.Project_Tree_Ref
;
570 Target
: String := "") return Boolean
572 Shared
: constant Shared_Project_Tree_Data_Access
:=
574 Variable
: constant Variable_Value
:=
576 (Name_Target
, Config_File
.Decl
.Attributes
, Shared
);
577 Tgt_Name
: Name_Id
:= No_Name
;
581 if Variable
/= Nil_Variable_Value
and then not Variable
.Default
then
582 Tgt_Name
:= Variable
.Value
;
589 and then (Length_Of_Name
(Tgt_Name
) = 0
590 or else Target
= Get_Name_String
(Tgt_Name
)));
593 if Autoconf_Specified
then
595 Write_Line
("inconsistent targets, performing autoconf");
601 if Tgt_Name
/= No_Name
then
603 ("invalid target name """
604 & Get_Name_String
(Tgt_Name
) & """ in configuration");
607 ("no target specified in configuration file");
615 --------------------------------------
616 -- Get_Or_Create_Configuration_File --
617 --------------------------------------
619 procedure Get_Or_Create_Configuration_File
620 (Project
: Project_Id
;
621 Conf_Project
: Project_Id
;
622 Project_Tree
: Project_Tree_Ref
;
623 Project_Node_Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
624 Env
: in out Prj
.Tree
.Environment
;
625 Allow_Automatic_Generation
: Boolean;
626 Config_File_Name
: String := "";
627 Autoconf_Specified
: Boolean;
628 Target_Name
: String := "";
629 Normalized_Hostname
: String;
630 Packages_To_Check
: String_List_Access
:= null;
631 Config
: out Prj
.Project_Id
;
632 Config_File_Path
: out String_Access
;
633 Automatically_Generated
: out Boolean;
634 On_Load_Config
: Config_File_Hook
:= null)
636 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
638 At_Least_One_Compiler_Command
: Boolean := False;
639 -- Set to True if at least one attribute Ide'Compiler_Command is
640 -- specified for one language of the system.
642 Conf_File_Name
: String_Access
:= new String'(Config_File_Name);
643 -- The configuration project file name. May be modified if there are
644 -- switches --config= in the Builder package of the main project.
646 Selected_Target : String_Access := new String'(Target_Name
);
648 function Default_File_Name
return String;
649 -- Return the name of the default config file that should be tested
651 procedure Do_Autoconf
;
652 -- Generate a new config file through gprconfig. In case of error, this
653 -- raises the Invalid_Config exception with an appropriate message
655 procedure Check_Builder_Switches
;
656 -- Check for switches --config and --RTS in package Builder
658 procedure Get_Project_Target
;
659 -- If Target_Name is empty, get the specified target in the project
662 function Get_Config_Switches
return Argument_List_Access
;
663 -- Return the --config switches to use for gprconfig
665 function Get_Db_Switches
return Argument_List_Access
;
666 -- Return the --db switches to use for gprconfig
668 function Might_Have_Sources
(Project
: Project_Id
) return Boolean;
669 -- True if the specified project might have sources (ie the user has not
670 -- explicitly specified it. We haven't checked the file system, nor do
671 -- we need to at this stage.
673 ----------------------------
674 -- Check_Builder_Switches --
675 ----------------------------
677 procedure Check_Builder_Switches
is
678 Get_RTS_Switches
: constant Boolean :=
679 RTS_Languages
.Get_First
= No_Name
;
680 -- If no switch --RTS have been specified on the command line, look
681 -- for --RTS switches in the Builder switches.
683 Builder
: constant Package_Id
:=
684 Value_Of
(Name_Builder
, Project
.Decl
.Packages
, Shared
);
686 Switch_Array_Id
: Array_Element_Id
;
687 -- The Switches to be checked
689 procedure Check_Switches
;
690 -- Check the switches in Switch_Array_Id
696 procedure Check_Switches
is
697 Switch_Array
: Array_Element
;
698 Switch_List
: String_List_Id
:= Nil_String
;
699 Switch
: String_Element
;
701 Lang_Last
: Positive;
704 while Switch_Array_Id
/= No_Array_Element
loop
706 Shared
.Array_Elements
.Table
(Switch_Array_Id
);
708 Switch_List
:= Switch_Array
.Value
.Values
;
709 List_Loop
: while Switch_List
/= Nil_String
loop
710 Switch
:= Shared
.String_Elements
.Table
(Switch_List
);
712 if Switch
.Value
/= No_Name
then
713 Get_Name_String
(Switch
.Value
);
715 if Conf_File_Name
'Length = 0
716 and then Name_Len
> 9
717 and then Name_Buffer
(1 .. 9) = "--config="
720 new String'(Name_Buffer (10 .. Name_Len));
722 elsif Get_RTS_Switches
723 and then Name_Len >= 7
724 and then Name_Buffer (1 .. 5) = "--RTS"
726 if Name_Buffer (6) = '=' then
727 if not Runtime_Name_Set_For (Name_Ada) then
730 Name_Buffer (7 .. Name_Len));
731 Locate_Runtime (Name_Ada, Env);
735 and then Name_Buffer (6) = ':'
736 and then Name_Buffer (7) /= '='
739 while Lang_Last < Name_Len
740 and then Name_Buffer (Lang_Last + 1) /= '='
742 Lang_Last := Lang_Last + 1;
745 if Name_Buffer (Lang_Last + 1) = '=' then
747 RTS : constant String :=
748 Name_Buffer (Lang_Last + 2 .. Name_Len);
750 Name_Buffer (1 .. Lang_Last - 6) :=
751 Name_Buffer (7 .. Lang_Last);
752 Name_Len := Lang_Last - 6;
753 To_Lower (Name_Buffer (1 .. Name_Len));
756 if not Runtime_Name_Set_For (Lang) then
757 Set_Runtime_For (Lang, RTS);
758 Locate_Runtime (Lang, Env);
766 Switch_List := Switch.Next;
769 Switch_Array_Id := Switch_Array.Next;
773 -- Start of processing for Check_Builder_Switches
776 if Builder /= No_Package then
779 (Name => Name_Switches,
780 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
786 (Name => Name_Default_Switches,
787 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
791 end Check_Builder_Switches;
793 ------------------------
794 -- Get_Project_Target --
795 ------------------------
797 procedure Get_Project_Target is
799 if Selected_Target'Length = 0 then
801 -- Check if attribute Target is specified in the main
802 -- project, or in a project it extends. If it is, use this
803 -- target to invoke gprconfig.
806 Variable : Variable_Value;
808 Tgt_Name : Name_Id := No_Name;
813 while Proj /= No_Project loop
815 Value_Of (Name_Target, Proj.Decl.Attributes, Shared);
817 if Variable /= Nil_Variable_Value
818 and then not Variable.Default
819 and then Variable.Value /= No_Name
821 Tgt_Name := Variable.Value;
825 Proj := Proj.Extends;
826 end loop Project_Loop;
828 if Tgt_Name /= No_Name then
829 Selected_Target := new String'(Get_Name_String
(Tgt_Name
));
833 end Get_Project_Target
;
835 -----------------------
836 -- Default_File_Name --
837 -----------------------
839 function Default_File_Name
return String is
840 Ada_RTS
: constant String := Runtime_Name_For
(Name_Ada
);
844 if Selected_Target
'Length /= 0 then
845 if Ada_RTS
/= "" then
847 Selected_Target
.all & '-' &
848 Ada_RTS
& Config_Project_File_Extension
;
851 Selected_Target
.all & Config_Project_File_Extension
;
854 elsif Ada_RTS
/= "" then
855 return Ada_RTS
& Config_Project_File_Extension
;
858 Tmp
:= Getenv
(Config_Project_Env_Var
);
861 T
: constant String := Tmp
.all;
867 return Default_Config_Name
;
873 end Default_File_Name
;
879 procedure Do_Autoconf
is
880 Obj_Dir
: constant Variable_Value
:=
883 Conf_Project
.Decl
.Attributes
,
886 Gprconfig_Path
: String_Access
;
890 Gprconfig_Path
:= Locate_Exec_On_Path
(Gprconfig_Name
);
892 if Gprconfig_Path
= null then
894 ("could not locate gprconfig for auto-configuration");
897 -- First, find the object directory of the Conf_Project
899 if Obj_Dir
= Nil_Variable_Value
or else Obj_Dir
.Default
then
900 Get_Name_String
(Conf_Project
.Directory
.Display_Name
);
903 if Is_Absolute_Path
(Get_Name_String
(Obj_Dir
.Value
)) then
904 Get_Name_String
(Obj_Dir
.Value
);
908 Add_Str_To_Name_Buffer
909 (Get_Name_String
(Conf_Project
.Directory
.Display_Name
));
910 Add_Str_To_Name_Buffer
(Get_Name_String
(Obj_Dir
.Value
));
914 if Subdirs
/= null then
915 Add_Char_To_Name_Buffer
(Directory_Separator
);
916 Add_Str_To_Name_Buffer
(Subdirs
.all);
919 for J
in 1 .. Name_Len
loop
920 if Name_Buffer
(J
) = '/' then
921 Name_Buffer
(J
) := Directory_Separator
;
925 -- Make sure that Obj_Dir ends with a directory separator
927 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
928 Name_Len
:= Name_Len
+ 1;
929 Name_Buffer
(Name_Len
) := Directory_Separator
;
933 Obj_Dir
: constant String := Name_Buffer
(1 .. Name_Len
);
934 Config_Switches
: Argument_List_Access
;
935 Db_Switches
: Argument_List_Access
;
936 Args
: Argument_List
(1 .. 5);
938 Obj_Dir_Exists
: Boolean := True;
941 -- Check if the object directory exists. If Setup_Projects is True
942 -- (-p) and directory does not exist, attempt to create it.
943 -- Otherwise, if directory does not exist, fail without calling
946 if not Is_Directory
(Obj_Dir
)
947 and then (Setup_Projects
or else Subdirs
/= null)
950 Create_Path
(Obj_Dir
);
952 if not Quiet_Output
then
953 Write_Str
("object directory """);
955 Write_Line
(""" created");
961 ("could not create object directory " & Obj_Dir
);
965 if not Is_Directory
(Obj_Dir
) then
966 case Env
.Flags
.Require_Obj_Dirs
is
969 ("object directory " & Obj_Dir
& " does not exist");
974 "?object directory " & Obj_Dir
& " does not exist");
975 Obj_Dir_Exists
:= False;
982 -- Get the config switches. This should be done only now, as some
983 -- runtimes may have been found if the Builder switches.
985 Config_Switches
:= Get_Config_Switches
;
987 -- Get eventual --db switches
989 Db_Switches
:= Get_Db_Switches
;
993 Args
(1) := new String'("--batch");
994 Args (2) := new String'("-o");
996 -- If no config file was specified, set the auto.cgpr one
998 if Conf_File_Name
'Length = 0 then
999 if Obj_Dir_Exists
then
1000 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
1004 Path_FD : File_Descriptor;
1005 Path_Name : Path_Name_Type;
1008 Prj.Env.Create_Temp_File
1009 (Shared => Project_Tree.Shared,
1011 Path_Name => Path_Name,
1012 File_Use => "configuration file");
1014 if Path_FD /= Invalid_FD then
1016 Temp_Dir : constant String :=
1017 Containing_Directory
1018 (Get_Name_String (Path_Name));
1020 GNAT.OS_Lib.Close (Path_FD);
1022 new String'(Temp_Dir
&
1023 Directory_Separator
&
1025 Delete_File
(Get_Name_String
(Path_Name
));
1029 -- We'll have an error message later on
1031 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
1036 Args (3) := Conf_File_Name;
1039 if Normalized_Hostname = "" then
1042 if Selected_Target'Length = 0 then
1043 if At_Least_One_Compiler_Command then
1045 new String'("--target=all");
1048 new String'("--target=" & Normalized_Hostname);
1053 new String'("--target=" & Selected_Target
.all);
1059 if not Verbose_Mode
then
1060 Arg_Last
:= Arg_Last
+ 1;
1061 Args
(Arg_Last
) := new String'("-q");
1064 if Verbose_Mode then
1065 Write_Str (Gprconfig_Name);
1067 for J in 1 .. Arg_Last loop
1069 Write_Str (Args (J).all);
1072 for J in Config_Switches'Range loop
1074 Write_Str (Config_Switches (J).all);
1077 for J in Db_Switches'Range loop
1079 Write_Str (Db_Switches (J).all);
1084 elsif not Quiet_Output then
1085 -- Display no message if we are creating auto.cgpr, unless in
1088 if Config_File_Name'Length > 0
1089 or else Verbose_Mode
1091 Write_Str ("creating ");
1092 Write_Str (Simple_Name (Args (3).all));
1097 Spawn (Gprconfig_Path.all, Args (1 .. Arg_Last) &
1098 Config_Switches.all & Db_Switches.all,
1101 Free (Config_Switches);
1103 Config_File_Path := Locate_Config_File (Args (3).all);
1105 if Config_File_Path = null then
1106 Raise_Invalid_Config
1107 ("could not create " & Args (3).all);
1110 for F in Args'Range loop
1116 ---------------------
1117 -- Get_Db_Switches --
1118 ---------------------
1120 function Get_Db_Switches return Argument_List_Access is
1121 Result : Argument_List_Access;
1125 (2 * Db_Switch_Args.Last) + Boolean'Pos (not Load_Standard_Base);
1126 Result := new Argument_List (1 .. Nmb_Arg);
1128 if Nmb_Arg /= 0 then
1129 for J in 1 .. Db_Switch_Args.Last loop
1130 Result (2 * J - 1) :=
1131 new String'("--db");
1133 new String'(Get_Name_String (Db_Switch_Args.Table (J)));
1136 if not Load_Standard_Base then
1137 Result (Result'Last) := new String'("--db-");
1142 end Get_Db_Switches
;
1144 -------------------------
1145 -- Get_Config_Switches --
1146 -------------------------
1148 function Get_Config_Switches
return Argument_List_Access
is
1150 package Language_Htable
is new GNAT
.HTable
.Simple_HTable
1151 (Header_Num
=> Prj
.Header_Num
,
1153 No_Element
=> No_Name
,
1157 -- Hash table to keep the languages used in the project tree
1159 IDE
: constant Package_Id
:=
1160 Value_Of
(Name_Ide
, Project
.Decl
.Packages
, Shared
);
1162 procedure Add_Config_Switches_For_Project
1163 (Project
: Project_Id
;
1164 Tree
: Project_Tree_Ref
;
1165 With_State
: in out Integer);
1166 -- Add all --config switches for this project. This is also called
1167 -- for aggregate projects.
1169 -------------------------------------
1170 -- Add_Config_Switches_For_Project --
1171 -------------------------------------
1173 procedure Add_Config_Switches_For_Project
1174 (Project
: Project_Id
;
1175 Tree
: Project_Tree_Ref
;
1176 With_State
: in out Integer)
1178 pragma Unreferenced
(With_State
);
1180 Shared
: constant Shared_Project_Tree_Data_Access
:= Tree
.Shared
;
1182 Variable
: Variable_Value
;
1183 Check_Default
: Boolean;
1185 List
: String_List_Id
;
1186 Elem
: String_Element
;
1189 if Might_Have_Sources
(Project
) then
1191 Value_Of
(Name_Languages
, Project
.Decl
.Attributes
, Shared
);
1193 if Variable
= Nil_Variable_Value
or else Variable
.Default
then
1195 -- Languages is not declared. If it is not an extending
1196 -- project, or if it extends a project with no Languages,
1197 -- check for Default_Language.
1199 Check_Default
:= Project
.Extends
= No_Project
;
1201 if not Check_Default
then
1205 Project
.Extends
.Decl
.Attributes
,
1208 Variable
/= Nil_Variable_Value
1209 and then Variable
.Values
= Nil_String
;
1212 if Check_Default
then
1215 (Name_Default_Language
,
1216 Project
.Decl
.Attributes
,
1219 if Variable
/= Nil_Variable_Value
1220 and then not Variable
.Default
1222 Get_Name_String
(Variable
.Value
);
1223 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1225 Language_Htable
.Set
(Lang
, Lang
);
1227 -- If no default language is declared, default to Ada
1230 Language_Htable
.Set
(Name_Ada
, Name_Ada
);
1234 elsif Variable
.Values
/= Nil_String
then
1236 -- Attribute Languages is declared with a non empty list:
1237 -- put all the languages in Language_HTable.
1239 List
:= Variable
.Values
;
1240 while List
/= Nil_String
loop
1241 Elem
:= Shared
.String_Elements
.Table
(List
);
1243 Get_Name_String
(Elem
.Value
);
1244 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1246 Language_Htable
.Set
(Lang
, Lang
);
1252 end Add_Config_Switches_For_Project
;
1254 procedure For_Every_Imported_Project
is new For_Every_Project_Imported
1255 (State
=> Integer, Action
=> Add_Config_Switches_For_Project
);
1256 -- Document this procedure ???
1262 Result
: Argument_List_Access
;
1263 Variable
: Variable_Value
;
1264 Dummy
: Integer := 0;
1266 -- Start of processing for Get_Config_Switches
1269 For_Every_Imported_Project
1271 Tree
=> Project_Tree
,
1272 With_State
=> Dummy
,
1273 Include_Aggregated
=> True);
1275 Name
:= Language_Htable
.Get_First
;
1277 while Name
/= No_Name
loop
1279 Name
:= Language_Htable
.Get_Next
;
1282 Result
:= new String_List
(1 .. Count
);
1285 Name
:= Language_Htable
.Get_First
;
1286 while Name
/= No_Name
loop
1288 -- Check if IDE'Compiler_Command is declared for the language.
1289 -- If it is, use its value to invoke gprconfig.
1294 Attribute_Or_Array_Name
=> Name_Compiler_Command
,
1297 Force_Lower_Case_Index
=> True);
1300 Config_Command
: constant String :=
1301 "--config=" & Get_Name_String
(Name
);
1303 Runtime_Name
: constant String :=
1304 Runtime_Name_For
(Name
);
1307 if Variable
= Nil_Variable_Value
1308 or else Length_Of_Name
(Variable
.Value
) = 0
1311 new String'(Config_Command & ",," & Runtime_Name);
1314 At_Least_One_Compiler_Command := True;
1317 Compiler_Command : constant String :=
1318 Get_Name_String (Variable.Value);
1321 if Is_Absolute_Path (Compiler_Command) then
1324 (Config_Command
& ",," & Runtime_Name
& "," &
1325 Containing_Directory
(Compiler_Command
) & "," &
1326 Simple_Name
(Compiler_Command
));
1330 (Config_Command & ",," & Runtime_Name & ",," &
1338 Name := Language_Htable.Get_Next;
1342 end Get_Config_Switches;
1344 ------------------------
1345 -- Might_Have_Sources --
1346 ------------------------
1348 function Might_Have_Sources (Project : Project_Id) return Boolean is
1349 Variable : Variable_Value;
1355 Project.Decl.Attributes,
1358 if Variable = Nil_Variable_Value
1359 or else Variable.Default
1360 or else Variable.Values /= Nil_String
1365 Project.Decl.Attributes,
1367 return Variable = Nil_Variable_Value
1368 or else Variable.Default
1369 or else Variable.Values /= Nil_String;
1374 end Might_Have_Sources;
1377 Config_Project_Node : Project_Node_Id := Empty_Node;
1380 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1382 Free (Config_File_Path);
1383 Config := No_Project;
1386 Check_Builder_Switches;
1388 -- Do not attempt to find a configuration project file when
1389 -- Config_File_Name is No_Configuration_File.
1391 if Config_File_Name = No_Configuration_File then
1392 Config_File_Path := null;
1395 if Conf_File_Name'Length > 0 then
1396 Config_File_Path := Locate_Config_File (Conf_File_Name.all);
1398 Config_File_Path := Locate_Config_File (Default_File_Name);
1401 if Config_File_Path = null then
1402 if not Allow_Automatic_Generation
1403 and then Conf_File_Name'Length > 0
1405 Raise_Invalid_Config
1406 ("could not locate main configuration project "
1407 & Conf_File_Name.all);
1412 Automatically_Generated :=
1413 Allow_Automatic_Generation and then Config_File_Path = null;
1415 <<Process_Config_File>>
1417 if Automatically_Generated then
1419 -- This might raise an Invalid_Config exception
1423 -- If the config file is not auto-generated, warn if there is any --RTS
1424 -- switch, but not when the config file is generated in memory.
1426 elsif RTS_Languages.Get_First /= No_Name
1427 and then Opt.Warning_Mode /= Opt.Suppress
1428 and then On_Load_Config = null
1432 "--RTS is taken into account only in auto-configuration");
1435 -- Parse the configuration file
1437 if Verbose_Mode and then Config_File_Path /= null then
1438 Write_Str ("Checking configuration ");
1439 Write_Line (Config_File_Path.all);
1442 if Config_File_Path /= null then
1444 (In_Tree => Project_Node_Tree,
1445 Project => Config_Project_Node,
1446 Project_File_Name => Config_File_Path.all,
1447 Errout_Handling => Prj.Part.Finalize_If_Error,
1448 Packages_To_Check => Packages_To_Check,
1449 Current_Directory => Current_Directory,
1450 Is_Config_File => True,
1453 Config_Project_Node := Empty_Node;
1456 if On_Load_Config /= null then
1458 (Config_File => Config_Project_Node,
1459 Project_Node_Tree => Project_Node_Tree);
1462 if Config_Project_Node /= Empty_Node then
1463 Prj.Proc.Process_Project_Tree_Phase_1
1464 (In_Tree => Project_Tree,
1466 Packages_To_Check => Packages_To_Check,
1468 From_Project_Node => Config_Project_Node,
1469 From_Project_Node_Tree => Project_Node_Tree,
1471 Reset_Tree => False,
1472 On_New_Tree_Loaded => null);
1475 if Config_Project_Node = Empty_Node
1476 or else Config = No_Project
1478 Raise_Invalid_Config
1479 ("processing of configuration project """
1480 & Config_File_Path.all & """ failed");
1483 -- Check that the target of the configuration file is the one the user
1484 -- specified on the command line. We do not need to check that when in
1485 -- auto-conf mode, since the appropriate target was passed to gprconfig.
1487 if not Automatically_Generated
1490 (Config, Autoconf_Specified, Project_Tree, Selected_Target.all)
1492 Automatically_Generated := True;
1493 goto Process_Config_File;
1495 end Get_Or_Create_Configuration_File;
1497 ------------------------
1498 -- Locate_Config_File --
1499 ------------------------
1501 function Locate_Config_File (Name : String) return String_Access is
1502 Prefix_Path : constant String := Executable_Prefix_Path;
1504 if Prefix_Path'Length /= 0 then
1505 return Locate_Regular_File
1507 "." & Path_Separator &
1508 Prefix_Path & "share" & Directory_Separator & "gpr");
1510 return Locate_Regular_File (Name, ".");
1512 end Locate_Config_File;
1514 --------------------
1515 -- Locate_Runtime --
1516 --------------------
1518 procedure Locate_Runtime
1519 (Language : Name_Id;
1520 Env : Prj.Tree.Environment)
1522 function Is_Base_Name (Path : String) return Boolean;
1523 -- Returns True if Path has no directory separator
1529 function Is_Base_Name (Path : String) return Boolean is
1531 for I in Path'Range loop
1532 if Path (I) = Directory_Separator or else Path (I) = '/' then
1539 -- Local declarations
1541 function Find_Rts_In_Path is new Prj.Env.Find_Name_In_Path
1542 (Check_Filename => Is_Directory);
1544 RTS_Name : constant String := Runtime_Name_For (Language);
1546 Full_Path : String_Access;
1548 -- Start of processing for Locate_Runtime
1551 if not Is_Base_Name (RTS_Name) then
1553 Find_Rts_In_Path (Env.Project_Path, RTS_Name);
1555 if Full_Path = null then
1556 Raise_Invalid_Config ("cannot find RTS " & RTS_Name);
1559 Set_Runtime_For (Language, Normalize_Pathname (Full_Path.all));
1564 ------------------------------------
1565 -- Parse_Project_And_Apply_Config --
1566 ------------------------------------
1568 procedure Parse_Project_And_Apply_Config
1569 (Main_Project : out Prj.Project_Id;
1570 User_Project_Node : out Prj.Tree.Project_Node_Id;
1571 Config_File_Name : String := "";
1572 Autoconf_Specified : Boolean;
1573 Project_File_Name : String;
1574 Project_Tree : Prj.Project_Tree_Ref;
1575 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1576 Env : in out Prj.Tree.Environment;
1577 Packages_To_Check : String_List_Access;
1578 Allow_Automatic_Generation : Boolean := True;
1579 Automatically_Generated : out Boolean;
1580 Config_File_Path : out String_Access;
1581 Target_Name : String := "";
1582 Normalized_Hostname : String;
1583 On_Load_Config : Config_File_Hook := null;
1584 Implicit_Project : Boolean := False;
1585 On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
1588 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1590 -- Parse the user project tree
1592 Prj.Initialize (Project_Tree);
1594 Main_Project := No_Project;
1595 Automatically_Generated := False;
1598 (In_Tree => Project_Node_Tree,
1599 Project => User_Project_Node,
1600 Project_File_Name => Project_File_Name,
1601 Errout_Handling => Prj.Part.Finalize_If_Error,
1602 Packages_To_Check => Packages_To_Check,
1603 Current_Directory => Current_Directory,
1604 Is_Config_File => False,
1606 Implicit_Project => Implicit_Project);
1608 if User_Project_Node = Empty_Node then
1609 User_Project_Node := Empty_Node;
1613 Process_Project_And_Apply_Config
1614 (Main_Project => Main_Project,
1615 User_Project_Node => User_Project_Node,
1616 Config_File_Name => Config_File_Name,
1617 Autoconf_Specified => Autoconf_Specified,
1618 Project_Tree => Project_Tree,
1619 Project_Node_Tree => Project_Node_Tree,
1621 Packages_To_Check => Packages_To_Check,
1622 Allow_Automatic_Generation => Allow_Automatic_Generation,
1623 Automatically_Generated => Automatically_Generated,
1624 Config_File_Path => Config_File_Path,
1625 Target_Name => Target_Name,
1626 Normalized_Hostname => Normalized_Hostname,
1627 On_Load_Config => On_Load_Config,
1628 On_New_Tree_Loaded => On_New_Tree_Loaded);
1629 end Parse_Project_And_Apply_Config;
1631 --------------------------------------
1632 -- Process_Project_And_Apply_Config --
1633 --------------------------------------
1635 procedure Process_Project_And_Apply_Config
1636 (Main_Project : out Prj.Project_Id;
1637 User_Project_Node : Prj.Tree.Project_Node_Id;
1638 Config_File_Name : String := "";
1639 Autoconf_Specified : Boolean;
1640 Project_Tree : Prj.Project_Tree_Ref;
1641 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1642 Env : in out Prj.Tree.Environment;
1643 Packages_To_Check : String_List_Access;
1644 Allow_Automatic_Generation : Boolean := True;
1645 Automatically_Generated : out Boolean;
1646 Config_File_Path : out String_Access;
1647 Target_Name : String := "";
1648 Normalized_Hostname : String;
1649 On_Load_Config : Config_File_Hook := null;
1650 Reset_Tree : Boolean := True;
1651 On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
1653 Shared : constant Shared_Project_Tree_Data_Access :=
1654 Project_Tree.Shared;
1655 Main_Config_Project : Project_Id;
1658 Conf_Project : Project_Id := No_Project;
1659 -- The object directory of this project is used to store the config
1660 -- project file in auto-configuration. Set by Check_Project below.
1662 procedure Check_Project (Project : Project_Id);
1663 -- Look for a non aggregate project. If one is found, put its project Id
1670 procedure Check_Project (Project : Project_Id) is
1672 if Project.Qualifier = Aggregate
1674 Project.Qualifier = Aggregate_Library
1677 List : Aggregated_Project_List := Project.Aggregated_Projects;
1680 -- Look for a non aggregate project until one is found
1682 while Conf_Project = No_Project and then List /= null loop
1683 Check_Project (List.Project);
1689 Conf_Project := Project;
1693 -- Start of processing for Process_Project_And_Apply_Config
1696 Main_Project := No_Project;
1697 Automatically_Generated := False;
1699 Process_Project_Tree_Phase_1
1700 (In_Tree => Project_Tree,
1701 Project => Main_Project,
1702 Packages_To_Check => Packages_To_Check,
1704 From_Project_Node => User_Project_Node,
1705 From_Project_Node_Tree => Project_Node_Tree,
1707 Reset_Tree => Reset_Tree,
1708 On_New_Tree_Loaded => On_New_Tree_Loaded);
1711 Main_Project := No_Project;
1715 if Project_Tree.Source_Info_File_Name /= null then
1716 if not Is_Absolute_Path (Project_Tree.Source_Info_File_Name.all) then
1718 Obj_Dir : constant Variable_Value :=
1721 Main_Project.Decl.Attributes,
1725 if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then
1726 Get_Name_String (Main_Project.Directory.Display_Name);
1729 if Is_Absolute_Path (Get_Name_String (Obj_Dir.Value)) then
1730 Get_Name_String (Obj_Dir.Value);
1734 Add_Str_To_Name_Buffer
1735 (Get_Name_String (Main_Project.Directory.Display_Name));
1736 Add_Str_To_Name_Buffer (Get_Name_String (Obj_Dir.Value));
1740 Add_Char_To_Name_Buffer (Directory_Separator);
1741 Add_Str_To_Name_Buffer (Project_Tree.Source_Info_File_Name.all);
1742 Free (Project_Tree.Source_Info_File_Name);
1743 Project_Tree.Source_Info_File_Name :=
1744 new String'(Name_Buffer
(1 .. Name_Len
));
1748 Read_Source_Info_File
(Project_Tree
);
1751 -- Get the first project that is not an aggregate project or an
1752 -- aggregate library project. The object directory of this project will
1753 -- be used to store the config project file in auto-configuration.
1755 Check_Project
(Main_Project
);
1757 -- Fail if there is only aggregate projects and aggregate library
1758 -- projects in the project tree.
1760 if Conf_Project
= No_Project
then
1761 Raise_Invalid_Config
("there are no non-aggregate projects");
1764 -- Find configuration file
1766 Get_Or_Create_Configuration_File
1767 (Config
=> Main_Config_Project
,
1768 Project
=> Main_Project
,
1769 Conf_Project
=> Conf_Project
,
1770 Project_Tree
=> Project_Tree
,
1771 Project_Node_Tree
=> Project_Node_Tree
,
1773 Allow_Automatic_Generation
=> Allow_Automatic_Generation
,
1774 Config_File_Name
=> Config_File_Name
,
1775 Autoconf_Specified
=> Autoconf_Specified
,
1776 Target_Name
=> Target_Name
,
1777 Normalized_Hostname
=> Normalized_Hostname
,
1778 Packages_To_Check
=> Packages_To_Check
,
1779 Config_File_Path
=> Config_File_Path
,
1780 Automatically_Generated
=> Automatically_Generated
,
1781 On_Load_Config
=> On_Load_Config
);
1783 Apply_Config_File
(Main_Config_Project
, Project_Tree
);
1785 -- Finish processing the user's project
1787 Prj
.Proc
.Process_Project_Tree_Phase_2
1788 (In_Tree
=> Project_Tree
,
1789 Project
=> Main_Project
,
1791 From_Project_Node
=> User_Project_Node
,
1792 From_Project_Node_Tree
=> Project_Node_Tree
,
1796 if Project_Tree
.Source_Info_File_Name
/= null
1797 and then not Project_Tree
.Source_Info_File_Exists
1799 Write_Source_Info_File
(Project_Tree
);
1803 Main_Project
:= No_Project
;
1805 end Process_Project_And_Apply_Config
;
1807 --------------------------
1808 -- Raise_Invalid_Config --
1809 --------------------------
1811 procedure Raise_Invalid_Config
(Msg
: String) is
1813 Raise_Exception
(Invalid_Config
'Identity, Msg
);
1814 end Raise_Invalid_Config
;
1816 ----------------------
1817 -- Runtime_Name_For --
1818 ----------------------
1820 function Runtime_Name_For
(Language
: Name_Id
) return String is
1822 if RTS_Languages
.Get
(Language
) /= No_Name
then
1823 return Get_Name_String
(RTS_Languages
.Get
(Language
));
1827 end Runtime_Name_For
;
1829 --------------------------
1830 -- Runtime_Name_Set_For --
1831 --------------------------
1833 function Runtime_Name_Set_For
(Language
: Name_Id
) return Boolean is
1835 return RTS_Languages
.Get
(Language
) /= No_Name
;
1836 end Runtime_Name_Set_For
;
1838 ---------------------
1839 -- Set_Runtime_For --
1840 ---------------------
1842 procedure Set_Runtime_For
(Language
: Name_Id
; RTS_Name
: String) is
1844 Name_Len
:= RTS_Name
'Length;
1845 Name_Buffer
(1 .. Name_Len
) := RTS_Name
;
1846 RTS_Languages
.Set
(Language
, Name_Find
);
1847 end Set_Runtime_For
;