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 -----------------------
72 (Config_File
: Prj
.Project_Id
;
73 Autoconf_Specified
: Boolean;
74 Project_Tree
: Prj
.Project_Tree_Ref
;
75 Target
: String := "") return Boolean;
76 -- Check that the config file's target matches Target.
77 -- Target should be set to the empty string when the user did not specify
78 -- a target. If the target in the configuration file is invalid, this
79 -- function will raise Invalid_Config with an appropriate message.
80 -- Autoconf_Specified should be set to True if the user has used
83 function Locate_Config_File
(Name
: String) return String_Access
;
84 -- Search for Name in the config files directory. Return full path if
85 -- found, or null otherwise.
87 procedure Raise_Invalid_Config
(Msg
: String);
88 pragma No_Return
(Raise_Invalid_Config
);
89 -- Raises exception Invalid_Config with given message
91 procedure Apply_Config_File
92 (Config_File
: Prj
.Project_Id
;
93 Project_Tree
: Prj
.Project_Tree_Ref
);
94 -- Apply the configuration file settings to all the projects in the
95 -- project tree. The Project_Tree must have been parsed first, and
96 -- processed through the first phase so that all its projects are known.
98 -- Currently, this will add new attributes and packages in the various
99 -- projects, so that when the second phase of the processing is performed
100 -- these attributes are automatically taken into account.
102 ------------------------------------
103 -- Add_Default_GNAT_Naming_Scheme --
104 ------------------------------------
106 procedure Add_Default_GNAT_Naming_Scheme
107 (Config_File
: in out Project_Node_Id
;
108 Project_Tree
: Project_Node_Tree_Ref
)
110 procedure Create_Attribute
113 Index
: String := "";
114 Pkg
: Project_Node_Id
:= Empty_Node
);
116 ----------------------
117 -- Create_Attribute --
118 ----------------------
120 procedure Create_Attribute
123 Index
: String := "";
124 Pkg
: Project_Node_Id
:= Empty_Node
)
126 Attr
: Project_Node_Id
;
127 pragma Unreferenced
(Attr
);
129 Expr
: Name_Id
:= No_Name
;
130 Val
: Name_Id
:= No_Name
;
131 Parent
: Project_Node_Id
:= Config_File
;
135 Name_Len
:= Index
'Length;
136 Name_Buffer
(1 .. Name_Len
) := Index
;
140 if Pkg
/= Empty_Node
then
144 Name_Len
:= Value
'Length;
145 Name_Buffer
(1 .. Name_Len
) := Value
;
148 Attr
:= Create_Attribute
149 (Tree
=> Project_Tree
,
150 Prj_Or_Pkg
=> Parent
,
154 Value
=> Create_Literal_String
(Expr
, Project_Tree
));
155 end Create_Attribute
;
160 Naming
: Project_Node_Id
;
161 Compiler
: Project_Node_Id
;
163 -- Start of processing for Add_Default_GNAT_Naming_Scheme
166 if Config_File
= Empty_Node
then
168 -- Create a dummy config file is none was found
170 Name_Len
:= Auto_Cgpr
'Length;
171 Name_Buffer
(1 .. Name_Len
) := Auto_Cgpr
;
174 -- An invalid project name to avoid conflicts with user-created ones
177 Name_Buffer
(1 .. Name_Len
) := "_auto";
181 (In_Tree
=> Project_Tree
,
183 Full_Path
=> Path_Name_Type
(Name
),
184 Is_Config_File
=> True);
186 -- Setup library support
188 case MLib
.Tgt
.Support_For_Libraries
is
193 Create_Attribute
(Name_Library_Support
, "static_only");
196 Create_Attribute
(Name_Library_Support
, "full");
199 if MLib
.Tgt
.Standalone_Library_Auto_Init_Is_Supported
then
200 Create_Attribute
(Name_Library_Auto_Init_Supported
, "true");
202 Create_Attribute
(Name_Library_Auto_Init_Supported
, "false");
205 -- Declare an empty target
207 Create_Attribute
(Name_Target
, "");
209 -- Setup Ada support (Ada is the default language here, since this
210 -- is only called when no config file existed initially, ie for
213 Create_Attribute
(Name_Default_Language
, "ada");
215 Compiler
:= Create_Package
(Project_Tree
, Config_File
, "compiler");
217 (Name_Driver
, "gcc", "ada", Pkg
=> Compiler
);
219 (Name_Language_Kind
, "unit_based", "ada", Pkg
=> Compiler
);
221 (Name_Dependency_Kind
, "ALI_File", "ada", Pkg
=> Compiler
);
223 Naming
:= Create_Package
(Project_Tree
, Config_File
, "naming");
224 Create_Attribute
(Name_Spec_Suffix
, ".ads", "ada", Pkg
=> Naming
);
225 Create_Attribute
(Name_Separate_Suffix
, ".adb", "ada", Pkg
=> Naming
);
226 Create_Attribute
(Name_Body_Suffix
, ".adb", "ada", Pkg
=> Naming
);
227 Create_Attribute
(Name_Dot_Replacement
, "-", Pkg
=> Naming
);
228 Create_Attribute
(Name_Casing
, "lowercase", Pkg
=> Naming
);
230 if Current_Verbosity
= High
then
231 Write_Line
("Automatically generated (in-memory) config file");
233 (Project
=> Config_File
,
234 In_Tree
=> Project_Tree
,
235 Backward_Compatibility
=> False);
238 end Add_Default_GNAT_Naming_Scheme
;
240 -----------------------
241 -- Apply_Config_File --
242 -----------------------
244 procedure Apply_Config_File
245 (Config_File
: Prj
.Project_Id
;
246 Project_Tree
: Prj
.Project_Tree_Ref
)
248 procedure Add_Attributes
249 (Project_Tree
: Project_Tree_Ref
;
250 Conf_Decl
: Declarations
;
251 User_Decl
: in out Declarations
);
252 -- Process the attributes in the config declarations. For
253 -- single string values, if the attribute is not declared in
254 -- the user declarations, declare it with the value in the
255 -- config declarations. For string list values, prepend the
256 -- value in the user declarations with the value in the config
263 procedure Add_Attributes
264 (Project_Tree
: Project_Tree_Ref
;
265 Conf_Decl
: Declarations
;
266 User_Decl
: in out Declarations
)
268 Shared
: constant Shared_Project_Tree_Data_Access
:=
270 Conf_Attr_Id
: Variable_Id
;
271 Conf_Attr
: Variable
;
272 Conf_Array_Id
: Array_Id
;
273 Conf_Array
: Array_Data
;
274 Conf_Array_Elem_Id
: Array_Element_Id
;
275 Conf_Array_Elem
: Array_Element
;
276 Conf_List
: String_List_Id
;
277 Conf_List_Elem
: String_Element
;
279 User_Attr_Id
: Variable_Id
;
280 User_Attr
: Variable
;
281 User_Array_Id
: Array_Id
;
282 User_Array
: Array_Data
;
283 User_Array_Elem_Id
: Array_Element_Id
;
284 User_Array_Elem
: Array_Element
;
287 Conf_Attr_Id
:= Conf_Decl
.Attributes
;
288 User_Attr_Id
:= User_Decl
.Attributes
;
290 while Conf_Attr_Id
/= No_Variable
loop
291 Conf_Attr
:= Shared
.Variable_Elements
.Table
(Conf_Attr_Id
);
292 User_Attr
:= Shared
.Variable_Elements
.Table
(User_Attr_Id
);
294 if not Conf_Attr
.Value
.Default
then
295 if User_Attr
.Value
.Default
then
297 -- No attribute declared in user project file: just copy
298 -- the value of the configuration attribute.
300 User_Attr
.Value
:= Conf_Attr
.Value
;
301 Shared
.Variable_Elements
.Table
(User_Attr_Id
) := User_Attr
;
303 elsif User_Attr
.Value
.Kind
= List
304 and then Conf_Attr
.Value
.Values
/= Nil_String
306 -- List attribute declared in both the user project and the
307 -- configuration project: prepend the user list with the
308 -- configuration list.
311 User_List
: constant String_List_Id
:=
312 User_Attr
.Value
.Values
;
313 Conf_List
: String_List_Id
:= Conf_Attr
.Value
.Values
;
314 Conf_Elem
: String_Element
;
315 New_List
: String_List_Id
;
316 New_Elem
: String_Element
;
321 String_Element_Table
.Increment_Last
322 (Shared
.String_Elements
);
324 String_Element_Table
.Last
(Shared
.String_Elements
);
326 -- Value of attribute is new list
328 User_Attr
.Value
.Values
:= New_List
;
329 Shared
.Variable_Elements
.Table
(User_Attr_Id
) :=
333 -- Get each element of configuration list
335 Conf_Elem
:= Shared
.String_Elements
.Table
(Conf_List
);
336 New_Elem
:= Conf_Elem
;
337 Conf_List
:= Conf_Elem
.Next
;
339 if Conf_List
= Nil_String
then
341 -- If it is the last element in the list, connect
342 -- to first element of user list, and we are done.
344 New_Elem
.Next
:= User_List
;
345 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
349 -- If it is not the last element in the list, add
352 String_Element_Table
.Increment_Last
353 (Shared
.String_Elements
);
354 New_Elem
.Next
:= String_Element_Table
.Last
355 (Shared
.String_Elements
);
356 Shared
.String_Elements
.Table
(New_List
) := New_Elem
;
357 New_List
:= New_Elem
.Next
;
364 Conf_Attr_Id
:= Conf_Attr
.Next
;
365 User_Attr_Id
:= User_Attr
.Next
;
368 Conf_Array_Id
:= Conf_Decl
.Arrays
;
369 while Conf_Array_Id
/= No_Array
loop
370 Conf_Array
:= Shared
.Arrays
.Table
(Conf_Array_Id
);
372 User_Array_Id
:= User_Decl
.Arrays
;
373 while User_Array_Id
/= No_Array
loop
374 User_Array
:= Shared
.Arrays
.Table
(User_Array_Id
);
375 exit when User_Array
.Name
= Conf_Array
.Name
;
376 User_Array_Id
:= User_Array
.Next
;
379 -- If this associative array does not exist in the user project
380 -- file, do a shallow copy of the full associative array.
382 if User_Array_Id
= No_Array
then
383 Array_Table
.Increment_Last
(Shared
.Arrays
);
384 User_Array
:= Conf_Array
;
385 User_Array
.Next
:= User_Decl
.Arrays
;
386 User_Decl
.Arrays
:= Array_Table
.Last
(Shared
.Arrays
);
387 Shared
.Arrays
.Table
(User_Decl
.Arrays
) := User_Array
;
389 -- Otherwise, check each array element
392 Conf_Array_Elem_Id
:= Conf_Array
.Value
;
393 while Conf_Array_Elem_Id
/= No_Array_Element
loop
395 Shared
.Array_Elements
.Table
(Conf_Array_Elem_Id
);
397 User_Array_Elem_Id
:= User_Array
.Value
;
398 while User_Array_Elem_Id
/= No_Array_Element
loop
400 Shared
.Array_Elements
.Table
(User_Array_Elem_Id
);
401 exit when User_Array_Elem
.Index
= Conf_Array_Elem
.Index
;
402 User_Array_Elem_Id
:= User_Array_Elem
.Next
;
405 -- If the array element doesn't exist in the user array,
406 -- insert a shallow copy of the conf array element in the
409 if User_Array_Elem_Id
= No_Array_Element
then
410 Array_Element_Table
.Increment_Last
411 (Shared
.Array_Elements
);
412 User_Array_Elem
:= Conf_Array_Elem
;
413 User_Array_Elem
.Next
:= User_Array
.Value
;
415 Array_Element_Table
.Last
(Shared
.Array_Elements
);
416 Shared
.Array_Elements
.Table
(User_Array
.Value
) :=
418 Shared
.Arrays
.Table
(User_Array_Id
) := User_Array
;
420 -- Otherwise, if the value is a string list, prepend the
421 -- conf array element value to the array element.
423 elsif Conf_Array_Elem
.Value
.Kind
= List
then
424 Conf_List
:= Conf_Array_Elem
.Value
.Values
;
426 if Conf_List
/= Nil_String
then
428 Link
: constant String_List_Id
:=
429 User_Array_Elem
.Value
.Values
;
430 Previous
: String_List_Id
:= Nil_String
;
431 Next
: String_List_Id
;
436 Shared
.String_Elements
.Table
(Conf_List
);
437 String_Element_Table
.Increment_Last
438 (Shared
.String_Elements
);
440 String_Element_Table
.Last
441 (Shared
.String_Elements
);
442 Shared
.String_Elements
.Table
(Next
) :=
445 if Previous
= Nil_String
then
446 User_Array_Elem
.Value
.Values
:= Next
;
447 Shared
.Array_Elements
.Table
448 (User_Array_Elem_Id
) := User_Array_Elem
;
451 Shared
.String_Elements
.Table
452 (Previous
).Next
:= Next
;
457 Conf_List
:= Conf_List_Elem
.Next
;
459 if Conf_List
= Nil_String
then
460 Shared
.String_Elements
.Table
461 (Previous
).Next
:= Link
;
469 Conf_Array_Elem_Id
:= Conf_Array_Elem
.Next
;
473 Conf_Array_Id
:= Conf_Array
.Next
;
477 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
479 Conf_Decl
: constant Declarations
:= Config_File
.Decl
;
480 Conf_Pack_Id
: Package_Id
;
481 Conf_Pack
: Package_Element
;
483 User_Decl
: Declarations
;
484 User_Pack_Id
: Package_Id
;
485 User_Pack
: Package_Element
;
489 Debug_Output
("Applying config file to a project tree");
491 Proj
:= Project_Tree
.Projects
;
492 while Proj
/= null loop
493 if Proj
.Project
/= Config_File
then
494 User_Decl
:= Proj
.Project
.Decl
;
496 (Project_Tree
=> Project_Tree
,
497 Conf_Decl
=> Conf_Decl
,
498 User_Decl
=> User_Decl
);
500 Conf_Pack_Id
:= Conf_Decl
.Packages
;
501 while Conf_Pack_Id
/= No_Package
loop
502 Conf_Pack
:= Shared
.Packages
.Table
(Conf_Pack_Id
);
504 User_Pack_Id
:= User_Decl
.Packages
;
505 while User_Pack_Id
/= No_Package
loop
506 User_Pack
:= Shared
.Packages
.Table
(User_Pack_Id
);
507 exit when User_Pack
.Name
= Conf_Pack
.Name
;
508 User_Pack_Id
:= User_Pack
.Next
;
511 if User_Pack_Id
= No_Package
then
512 Package_Table
.Increment_Last
(Shared
.Packages
);
513 User_Pack
:= Conf_Pack
;
514 User_Pack
.Next
:= User_Decl
.Packages
;
515 User_Decl
.Packages
:= Package_Table
.Last
(Shared
.Packages
);
516 Shared
.Packages
.Table
(User_Decl
.Packages
) := User_Pack
;
520 (Project_Tree
=> Project_Tree
,
521 Conf_Decl
=> Conf_Pack
.Decl
,
522 User_Decl
=> Shared
.Packages
.Table
523 (User_Pack_Id
).Decl
);
526 Conf_Pack_Id
:= Conf_Pack
.Next
;
529 Proj
.Project
.Decl
:= User_Decl
;
531 -- For aggregate projects, we need to apply the config to all
532 -- their aggregated trees as well.
534 if Proj
.Project
.Qualifier
in Aggregate_Project
then
536 List
: Aggregated_Project_List
;
538 List
:= Proj
.Project
.Aggregated_Projects
;
539 while List
/= null loop
541 ("Recursively apply config to aggregated tree",
544 (Config_File
, Project_Tree
=> List
.Tree
);
553 end Apply_Config_File
;
559 function Check_Target
560 (Config_File
: Project_Id
;
561 Autoconf_Specified
: Boolean;
562 Project_Tree
: Prj
.Project_Tree_Ref
;
563 Target
: String := "") return Boolean
565 Shared
: constant Shared_Project_Tree_Data_Access
:=
567 Variable
: constant Variable_Value
:=
569 (Name_Target
, Config_File
.Decl
.Attributes
, Shared
);
570 Tgt_Name
: Name_Id
:= No_Name
;
574 if Variable
/= Nil_Variable_Value
and then not Variable
.Default
then
575 Tgt_Name
:= Variable
.Value
;
582 and then (Length_Of_Name
(Tgt_Name
) = 0
583 or else Target
= Get_Name_String
(Tgt_Name
)));
586 if Autoconf_Specified
then
588 Write_Line
("inconsistent targets, performing autoconf");
594 if Tgt_Name
/= No_Name
then
596 ("invalid target name """
597 & Get_Name_String
(Tgt_Name
) & """ in configuration");
600 ("no target specified in configuration file");
608 --------------------------------------
609 -- Get_Or_Create_Configuration_File --
610 --------------------------------------
612 procedure Get_Or_Create_Configuration_File
613 (Project
: Project_Id
;
614 Conf_Project
: Project_Id
;
615 Project_Tree
: Project_Tree_Ref
;
616 Project_Node_Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
617 Env
: in out Prj
.Tree
.Environment
;
618 Allow_Automatic_Generation
: Boolean;
619 Config_File_Name
: String := "";
620 Autoconf_Specified
: Boolean;
621 Target_Name
: String := "";
622 Normalized_Hostname
: String;
623 Packages_To_Check
: String_List_Access
:= null;
624 Config
: out Prj
.Project_Id
;
625 Config_File_Path
: out String_Access
;
626 Automatically_Generated
: out Boolean;
627 On_Load_Config
: Config_File_Hook
:= null)
629 Shared
: constant Shared_Project_Tree_Data_Access
:= Project_Tree
.Shared
;
631 At_Least_One_Compiler_Command
: Boolean := False;
632 -- Set to True if at least one attribute Ide'Compiler_Command is
633 -- specified for one language of the system.
635 Conf_File_Name
: String_Access
:= new String'(Config_File_Name);
636 -- The configuration project file name. May be modified if there are
637 -- switches --config= in the Builder package of the main project.
639 Selected_Target : String_Access := new String'(Target_Name
);
641 function Default_File_Name
return String;
642 -- Return the name of the default config file that should be tested
644 procedure Do_Autoconf
;
645 -- Generate a new config file through gprconfig. In case of error, this
646 -- raises the Invalid_Config exception with an appropriate message
648 procedure Check_Builder_Switches
;
649 -- Check for switches --config and --RTS in package Builder
651 procedure Get_Project_Target
;
652 -- If Target_Name is empty, get the specified target in the project
655 function Get_Config_Switches
return Argument_List_Access
;
656 -- Return the --config switches to use for gprconfig
658 function Get_Db_Switches
return Argument_List_Access
;
659 -- Return the --db switches to use for gprconfig
661 function Might_Have_Sources
(Project
: Project_Id
) return Boolean;
662 -- True if the specified project might have sources (ie the user has not
663 -- explicitly specified it. We haven't checked the file system, nor do
664 -- we need to at this stage.
666 ----------------------------
667 -- Check_Builder_Switches --
668 ----------------------------
670 procedure Check_Builder_Switches
is
671 Get_RTS_Switches
: constant Boolean :=
672 RTS_Languages
.Get_First
= No_Name
;
673 -- If no switch --RTS have been specified on the command line, look
674 -- for --RTS switches in the Builder switches.
676 Builder
: constant Package_Id
:=
677 Value_Of
(Name_Builder
, Project
.Decl
.Packages
, Shared
);
679 Switch_Array_Id
: Array_Element_Id
;
680 -- The Switches to be checked
682 procedure Check_Switches
;
683 -- Check the switches in Switch_Array_Id
689 procedure Check_Switches
is
690 Switch_Array
: Array_Element
;
691 Switch_List
: String_List_Id
:= Nil_String
;
692 Switch
: String_Element
;
694 Lang_Last
: Positive;
697 while Switch_Array_Id
/= No_Array_Element
loop
699 Shared
.Array_Elements
.Table
(Switch_Array_Id
);
701 Switch_List
:= Switch_Array
.Value
.Values
;
702 List_Loop
: while Switch_List
/= Nil_String
loop
703 Switch
:= Shared
.String_Elements
.Table
(Switch_List
);
705 if Switch
.Value
/= No_Name
then
706 Get_Name_String
(Switch
.Value
);
708 if Conf_File_Name
'Length = 0
709 and then Name_Len
> 9
710 and then Name_Buffer
(1 .. 9) = "--config="
713 new String'(Name_Buffer (10 .. Name_Len));
715 elsif Get_RTS_Switches
716 and then Name_Len >= 7
717 and then Name_Buffer (1 .. 5) = "--RTS"
719 if Name_Buffer (6) = '=' then
720 if not Runtime_Name_Set_For (Name_Ada) then
723 Name_Buffer (7 .. Name_Len));
724 Locate_Runtime (Name_Ada, Project_Tree);
728 and then Name_Buffer (6) = ':'
729 and then Name_Buffer (7) /= '='
732 while Lang_Last < Name_Len
733 and then Name_Buffer (Lang_Last + 1) /= '='
735 Lang_Last := Lang_Last + 1;
738 if Name_Buffer (Lang_Last + 1) = '=' then
740 RTS : constant String :=
741 Name_Buffer (Lang_Last + 2 .. Name_Len);
743 Name_Buffer (1 .. Lang_Last - 6) :=
744 Name_Buffer (7 .. Lang_Last);
745 Name_Len := Lang_Last - 6;
746 To_Lower (Name_Buffer (1 .. Name_Len));
749 if not Runtime_Name_Set_For (Lang) then
750 Set_Runtime_For (Lang, RTS);
751 Locate_Runtime (Lang, Project_Tree);
759 Switch_List := Switch.Next;
762 Switch_Array_Id := Switch_Array.Next;
766 -- Start of processing for Check_Builder_Switches
769 if Builder /= No_Package then
772 (Name => Name_Switches,
773 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
779 (Name => Name_Default_Switches,
780 In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
784 end Check_Builder_Switches;
786 ------------------------
787 -- Get_Project_Target --
788 ------------------------
790 procedure Get_Project_Target is
792 if Selected_Target'Length = 0 then
794 -- Check if attribute Target is specified in the main
795 -- project, or in a project it extends. If it is, use this
796 -- target to invoke gprconfig.
799 Variable : Variable_Value;
801 Tgt_Name : Name_Id := No_Name;
806 while Proj /= No_Project loop
808 Value_Of (Name_Target, Proj.Decl.Attributes, Shared);
810 if Variable /= Nil_Variable_Value
811 and then not Variable.Default
812 and then Variable.Value /= No_Name
814 Tgt_Name := Variable.Value;
818 Proj := Proj.Extends;
819 end loop Project_Loop;
821 if Tgt_Name /= No_Name then
822 Selected_Target := new String'(Get_Name_String
(Tgt_Name
));
826 end Get_Project_Target
;
828 -----------------------
829 -- Default_File_Name --
830 -----------------------
832 function Default_File_Name
return String is
833 Ada_RTS
: constant String := Runtime_Name_For
(Name_Ada
);
837 if Selected_Target
'Length /= 0 then
838 if Ada_RTS
/= "" then
840 Selected_Target
.all & '-' &
841 Ada_RTS
& Config_Project_File_Extension
;
844 Selected_Target
.all & Config_Project_File_Extension
;
847 elsif Ada_RTS
/= "" then
848 return Ada_RTS
& Config_Project_File_Extension
;
851 Tmp
:= Getenv
(Config_Project_Env_Var
);
854 T
: constant String := Tmp
.all;
860 return Default_Config_Name
;
866 end Default_File_Name
;
872 procedure Do_Autoconf
is
873 Obj_Dir
: constant Variable_Value
:=
876 Conf_Project
.Decl
.Attributes
,
879 Gprconfig_Path
: String_Access
;
883 Gprconfig_Path
:= Locate_Exec_On_Path
(Gprconfig_Name
);
885 if Gprconfig_Path
= null then
887 ("could not locate gprconfig for auto-configuration");
890 -- First, find the object directory of the Conf_Project
892 if Obj_Dir
= Nil_Variable_Value
or else Obj_Dir
.Default
then
893 Get_Name_String
(Conf_Project
.Directory
.Display_Name
);
896 if Is_Absolute_Path
(Get_Name_String
(Obj_Dir
.Value
)) then
897 Get_Name_String
(Obj_Dir
.Value
);
901 Add_Str_To_Name_Buffer
902 (Get_Name_String
(Conf_Project
.Directory
.Display_Name
));
903 Add_Str_To_Name_Buffer
(Get_Name_String
(Obj_Dir
.Value
));
907 if Subdirs
/= null then
908 Add_Char_To_Name_Buffer
(Directory_Separator
);
909 Add_Str_To_Name_Buffer
(Subdirs
.all);
912 for J
in 1 .. Name_Len
loop
913 if Name_Buffer
(J
) = '/' then
914 Name_Buffer
(J
) := Directory_Separator
;
918 -- Make sure that Obj_Dir ends with a directory separator
920 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
921 Name_Len
:= Name_Len
+ 1;
922 Name_Buffer
(Name_Len
) := Directory_Separator
;
926 Obj_Dir
: constant String := Name_Buffer
(1 .. Name_Len
);
927 Config_Switches
: Argument_List_Access
;
928 Db_Switches
: Argument_List_Access
;
929 Args
: Argument_List
(1 .. 5);
931 Obj_Dir_Exists
: Boolean := True;
934 -- Check if the object directory exists. If Setup_Projects is True
935 -- (-p) and directory does not exist, attempt to create it.
936 -- Otherwise, if directory does not exist, fail without calling
939 if not Is_Directory
(Obj_Dir
)
940 and then (Setup_Projects
or else Subdirs
/= null)
943 Create_Path
(Obj_Dir
);
945 if not Quiet_Output
then
946 Write_Str
("object directory """);
948 Write_Line
(""" created");
954 ("could not create object directory " & Obj_Dir
);
958 if not Is_Directory
(Obj_Dir
) then
959 case Env
.Flags
.Require_Obj_Dirs
is
962 ("object directory " & Obj_Dir
& " does not exist");
967 "?object directory " & Obj_Dir
& " does not exist");
968 Obj_Dir_Exists
:= False;
975 -- Get the config switches. This should be done only now, as some
976 -- runtimes may have been found if the Builder switches.
978 Config_Switches
:= Get_Config_Switches
;
980 -- Get eventual --db switches
982 Db_Switches
:= Get_Db_Switches
;
986 Args
(1) := new String'("--batch");
987 Args (2) := new String'("-o");
989 -- If no config file was specified, set the auto.cgpr one
991 if Conf_File_Name
'Length = 0 then
992 if Obj_Dir_Exists
then
993 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
997 Path_FD : File_Descriptor;
998 Path_Name : Path_Name_Type;
1001 Prj.Env.Create_Temp_File
1002 (Shared => Project_Tree.Shared,
1004 Path_Name => Path_Name,
1005 File_Use => "configuration file");
1007 if Path_FD /= Invalid_FD then
1009 Temp_Dir : constant String :=
1010 Containing_Directory
1011 (Get_Name_String (Path_Name));
1013 GNAT.OS_Lib.Close (Path_FD);
1015 new String'(Temp_Dir
&
1016 Directory_Separator
&
1018 Delete_File
(Get_Name_String
(Path_Name
));
1022 -- We'll have an error message later on
1024 Args
(3) := new String'(Obj_Dir & Auto_Cgpr);
1029 Args (3) := Conf_File_Name;
1032 if Normalized_Hostname = "" then
1035 if Selected_Target'Length = 0 then
1036 if At_Least_One_Compiler_Command then
1038 new String'("--target=all");
1041 new String'("--target=" & Normalized_Hostname);
1046 new String'("--target=" & Selected_Target
.all);
1052 if not Verbose_Mode
then
1053 Arg_Last
:= Arg_Last
+ 1;
1054 Args
(Arg_Last
) := new String'("-q");
1057 if Verbose_Mode then
1058 Write_Str (Gprconfig_Name);
1060 for J in 1 .. Arg_Last loop
1062 Write_Str (Args (J).all);
1065 for J in Config_Switches'Range loop
1067 Write_Str (Config_Switches (J).all);
1070 for J in Db_Switches'Range loop
1072 Write_Str (Db_Switches (J).all);
1077 elsif not Quiet_Output then
1078 -- Display no message if we are creating auto.cgpr, unless in
1081 if Config_File_Name'Length > 0
1082 or else Verbose_Mode
1084 Write_Str ("creating ");
1085 Write_Str (Simple_Name (Args (3).all));
1090 Spawn (Gprconfig_Path.all, Args (1 .. Arg_Last) &
1091 Config_Switches.all & Db_Switches.all,
1094 Free (Config_Switches);
1096 Config_File_Path := Locate_Config_File (Args (3).all);
1098 if Config_File_Path = null then
1099 Raise_Invalid_Config
1100 ("could not create " & Args (3).all);
1103 for F in Args'Range loop
1109 ---------------------
1110 -- Get_Db_Switches --
1111 ---------------------
1113 function Get_Db_Switches return Argument_List_Access is
1114 Result : Argument_List_Access;
1118 (2 * Db_Switch_Args.Last) + Boolean'Pos (not Load_Standard_Base);
1119 Result := new Argument_List (1 .. Nmb_Arg);
1121 if Nmb_Arg /= 0 then
1122 for J in 1 .. Db_Switch_Args.Last loop
1123 Result (2 * J - 1) :=
1124 new String'("--db");
1126 new String'(Get_Name_String (Db_Switch_Args.Table (J)));
1129 if not Load_Standard_Base then
1130 Result (Result'Last) := new String'("--db-");
1135 end Get_Db_Switches
;
1137 -------------------------
1138 -- Get_Config_Switches --
1139 -------------------------
1141 function Get_Config_Switches
return Argument_List_Access
is
1143 package Language_Htable
is new GNAT
.HTable
.Simple_HTable
1144 (Header_Num
=> Prj
.Header_Num
,
1146 No_Element
=> No_Name
,
1150 -- Hash table to keep the languages used in the project tree
1152 IDE
: constant Package_Id
:=
1153 Value_Of
(Name_Ide
, Project
.Decl
.Packages
, Shared
);
1155 procedure Add_Config_Switches_For_Project
1156 (Project
: Project_Id
;
1157 Tree
: Project_Tree_Ref
;
1158 With_State
: in out Integer);
1159 -- Add all --config switches for this project. This is also called
1160 -- for aggregate projects.
1162 -------------------------------------
1163 -- Add_Config_Switches_For_Project --
1164 -------------------------------------
1166 procedure Add_Config_Switches_For_Project
1167 (Project
: Project_Id
;
1168 Tree
: Project_Tree_Ref
;
1169 With_State
: in out Integer)
1171 pragma Unreferenced
(With_State
);
1173 Shared
: constant Shared_Project_Tree_Data_Access
:= Tree
.Shared
;
1175 Variable
: Variable_Value
;
1176 Check_Default
: Boolean;
1178 List
: String_List_Id
;
1179 Elem
: String_Element
;
1182 if Might_Have_Sources
(Project
) then
1184 Value_Of
(Name_Languages
, Project
.Decl
.Attributes
, Shared
);
1186 if Variable
= Nil_Variable_Value
or else Variable
.Default
then
1188 -- Languages is not declared. If it is not an extending
1189 -- project, or if it extends a project with no Languages,
1190 -- check for Default_Language.
1192 Check_Default
:= Project
.Extends
= No_Project
;
1194 if not Check_Default
then
1198 Project
.Extends
.Decl
.Attributes
,
1201 Variable
/= Nil_Variable_Value
1202 and then Variable
.Values
= Nil_String
;
1205 if Check_Default
then
1208 (Name_Default_Language
,
1209 Project
.Decl
.Attributes
,
1212 if Variable
/= Nil_Variable_Value
1213 and then not Variable
.Default
1215 Get_Name_String
(Variable
.Value
);
1216 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1218 Language_Htable
.Set
(Lang
, Lang
);
1220 -- If no default language is declared, default to Ada
1223 Language_Htable
.Set
(Name_Ada
, Name_Ada
);
1227 elsif Variable
.Values
/= Nil_String
then
1229 -- Attribute Languages is declared with a non empty list:
1230 -- put all the languages in Language_HTable.
1232 List
:= Variable
.Values
;
1233 while List
/= Nil_String
loop
1234 Elem
:= Shared
.String_Elements
.Table
(List
);
1236 Get_Name_String
(Elem
.Value
);
1237 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1239 Language_Htable
.Set
(Lang
, Lang
);
1245 end Add_Config_Switches_For_Project
;
1247 procedure For_Every_Imported_Project
is new For_Every_Project_Imported
1248 (State
=> Integer, Action
=> Add_Config_Switches_For_Project
);
1249 -- Document this procedure ???
1255 Result
: Argument_List_Access
;
1256 Variable
: Variable_Value
;
1257 Dummy
: Integer := 0;
1259 -- Start of processing for Get_Config_Switches
1262 For_Every_Imported_Project
1264 Tree
=> Project_Tree
,
1265 With_State
=> Dummy
,
1266 Include_Aggregated
=> True);
1268 Name
:= Language_Htable
.Get_First
;
1270 while Name
/= No_Name
loop
1272 Name
:= Language_Htable
.Get_Next
;
1275 Result
:= new String_List
(1 .. Count
);
1278 Name
:= Language_Htable
.Get_First
;
1279 while Name
/= No_Name
loop
1281 -- Check if IDE'Compiler_Command is declared for the language.
1282 -- If it is, use its value to invoke gprconfig.
1287 Attribute_Or_Array_Name
=> Name_Compiler_Command
,
1290 Force_Lower_Case_Index
=> True);
1293 Config_Command
: constant String :=
1294 "--config=" & Get_Name_String
(Name
);
1296 Runtime_Name
: constant String :=
1297 Runtime_Name_For
(Name
);
1300 if Variable
= Nil_Variable_Value
1301 or else Length_Of_Name
(Variable
.Value
) = 0
1304 new String'(Config_Command & ",," & Runtime_Name);
1307 At_Least_One_Compiler_Command := True;
1310 Compiler_Command : constant String :=
1311 Get_Name_String (Variable.Value);
1314 if Is_Absolute_Path (Compiler_Command) then
1317 (Config_Command
& ",," & Runtime_Name
& "," &
1318 Containing_Directory
(Compiler_Command
) & "," &
1319 Simple_Name
(Compiler_Command
));
1323 (Config_Command & ",," & Runtime_Name & ",," &
1331 Name := Language_Htable.Get_Next;
1335 end Get_Config_Switches;
1337 ------------------------
1338 -- Might_Have_Sources --
1339 ------------------------
1341 function Might_Have_Sources (Project : Project_Id) return Boolean is
1342 Variable : Variable_Value;
1348 Project.Decl.Attributes,
1351 if Variable = Nil_Variable_Value
1352 or else Variable.Default
1353 or else Variable.Values /= Nil_String
1358 Project.Decl.Attributes,
1360 return Variable = Nil_Variable_Value
1361 or else Variable.Default
1362 or else Variable.Values /= Nil_String;
1367 end Might_Have_Sources;
1370 Config_Project_Node : Project_Node_Id := Empty_Node;
1373 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1375 Free (Config_File_Path);
1376 Config := No_Project;
1379 Check_Builder_Switches;
1381 -- Do not attempt to find a configuration project file when
1382 -- Config_File_Name is No_Configuration_File.
1384 if Config_File_Name = No_Configuration_File then
1385 Config_File_Path := null;
1388 if Conf_File_Name'Length > 0 then
1389 Config_File_Path := Locate_Config_File (Conf_File_Name.all);
1391 Config_File_Path := Locate_Config_File (Default_File_Name);
1394 if Config_File_Path = null then
1395 if not Allow_Automatic_Generation
1396 and then Conf_File_Name'Length > 0
1398 Raise_Invalid_Config
1399 ("could not locate main configuration project "
1400 & Conf_File_Name.all);
1405 Automatically_Generated :=
1406 Allow_Automatic_Generation and then Config_File_Path = null;
1408 <<Process_Config_File>>
1410 if Automatically_Generated then
1411 if Hostparm.OpenVMS then
1413 -- There is no gprconfig on VMS
1415 Raise_Invalid_Config
1416 ("could not locate any configuration project file");
1419 -- This might raise an Invalid_Config exception
1424 -- If the config file is not auto-generated, warn if there is any --RTS
1425 -- switch, but not when the config file is generated in memory.
1427 elsif RTS_Languages.Get_First /= No_Name
1428 and then Opt.Warning_Mode /= Opt.Suppress
1429 and then On_Load_Config = null
1433 "--RTS is taken into account only in auto-configuration");
1436 -- Parse the configuration file
1438 if Verbose_Mode and then Config_File_Path /= null then
1439 Write_Str ("Checking configuration ");
1440 Write_Line (Config_File_Path.all);
1443 if Config_File_Path /= null then
1445 (In_Tree => Project_Node_Tree,
1446 Project => Config_Project_Node,
1447 Project_File_Name => Config_File_Path.all,
1448 Errout_Handling => Prj.Part.Finalize_If_Error,
1449 Packages_To_Check => Packages_To_Check,
1450 Current_Directory => Current_Directory,
1451 Is_Config_File => True,
1454 Config_Project_Node := Empty_Node;
1457 if On_Load_Config /= null then
1459 (Config_File => Config_Project_Node,
1460 Project_Node_Tree => Project_Node_Tree);
1463 if Config_Project_Node /= Empty_Node then
1464 Prj.Proc.Process_Project_Tree_Phase_1
1465 (In_Tree => Project_Tree,
1467 Packages_To_Check => Packages_To_Check,
1469 From_Project_Node => Config_Project_Node,
1470 From_Project_Node_Tree => Project_Node_Tree,
1472 Reset_Tree => False,
1473 On_New_Tree_Loaded => null);
1476 if Config_Project_Node = Empty_Node
1477 or else Config = No_Project
1479 Raise_Invalid_Config
1480 ("processing of configuration project """
1481 & Config_File_Path.all & """ failed");
1484 -- Check that the target of the configuration file is the one the user
1485 -- specified on the command line. We do not need to check that when in
1486 -- auto-conf mode, since the appropriate target was passed to gprconfig.
1488 if not Automatically_Generated
1491 (Config, Autoconf_Specified, Project_Tree, Selected_Target.all)
1493 Automatically_Generated := True;
1494 goto Process_Config_File;
1496 end Get_Or_Create_Configuration_File;
1498 ------------------------
1499 -- Locate_Config_File --
1500 ------------------------
1502 function Locate_Config_File (Name : String) return String_Access is
1503 Prefix_Path : constant String := Executable_Prefix_Path;
1505 if Prefix_Path'Length /= 0 then
1506 return Locate_Regular_File
1508 "." & Path_Separator &
1509 Prefix_Path & "share" & Directory_Separator & "gpr");
1511 return Locate_Regular_File (Name, ".");
1513 end Locate_Config_File;
1515 --------------------
1516 -- Locate_Runtime --
1517 --------------------
1519 procedure Locate_Runtime
1520 (Language : Name_Id;
1521 Project_Tree : Prj.Project_Tree_Ref)
1523 function Is_Base_Name (Path : String) return Boolean;
1524 -- Returns True if Path has no directory separator
1530 function Is_Base_Name (Path : String) return Boolean is
1532 for I in Path'Range loop
1533 if Path (I) = Directory_Separator or else Path (I) = '/' then
1540 -- Local declarations
1542 function Find_Rts_In_Path is new Prj.Env.Find_Name_In_Path
1543 (Check_Filename => Is_Directory);
1545 RTS_Name : constant String := Runtime_Name_For (Language);
1547 Full_Path : String_Access;
1549 -- Start of processing for Locate_Runtime
1552 if not Is_Base_Name (RTS_Name) then
1554 Find_Rts_In_Path (Root_Environment.Project_Path, RTS_Name);
1556 if Full_Path = null then
1557 Fail_Program (Project_Tree, "cannot find RTS " & RTS_Name);
1560 Set_Runtime_For (Language, Normalize_Pathname (Full_Path.all));
1565 ------------------------------------
1566 -- Parse_Project_And_Apply_Config --
1567 ------------------------------------
1569 procedure Parse_Project_And_Apply_Config
1570 (Main_Project : out Prj.Project_Id;
1571 User_Project_Node : out Prj.Tree.Project_Node_Id;
1572 Config_File_Name : String := "";
1573 Autoconf_Specified : Boolean;
1574 Project_File_Name : String;
1575 Project_Tree : Prj.Project_Tree_Ref;
1576 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1577 Env : in out Prj.Tree.Environment;
1578 Packages_To_Check : String_List_Access;
1579 Allow_Automatic_Generation : Boolean := True;
1580 Automatically_Generated : out Boolean;
1581 Config_File_Path : out String_Access;
1582 Target_Name : String := "";
1583 Normalized_Hostname : String;
1584 On_Load_Config : Config_File_Hook := null;
1585 Implicit_Project : Boolean := False;
1586 On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
1589 pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
1591 -- Parse the user project tree
1593 Prj.Initialize (Project_Tree);
1595 Main_Project := No_Project;
1596 Automatically_Generated := False;
1599 (In_Tree => Project_Node_Tree,
1600 Project => User_Project_Node,
1601 Project_File_Name => Project_File_Name,
1602 Errout_Handling => Prj.Part.Finalize_If_Error,
1603 Packages_To_Check => Packages_To_Check,
1604 Current_Directory => Current_Directory,
1605 Is_Config_File => False,
1607 Implicit_Project => Implicit_Project);
1609 if User_Project_Node = Empty_Node then
1610 User_Project_Node := Empty_Node;
1614 Process_Project_And_Apply_Config
1615 (Main_Project => Main_Project,
1616 User_Project_Node => User_Project_Node,
1617 Config_File_Name => Config_File_Name,
1618 Autoconf_Specified => Autoconf_Specified,
1619 Project_Tree => Project_Tree,
1620 Project_Node_Tree => Project_Node_Tree,
1622 Packages_To_Check => Packages_To_Check,
1623 Allow_Automatic_Generation => Allow_Automatic_Generation,
1624 Automatically_Generated => Automatically_Generated,
1625 Config_File_Path => Config_File_Path,
1626 Target_Name => Target_Name,
1627 Normalized_Hostname => Normalized_Hostname,
1628 On_Load_Config => On_Load_Config,
1629 On_New_Tree_Loaded => On_New_Tree_Loaded);
1630 end Parse_Project_And_Apply_Config;
1632 --------------------------------------
1633 -- Process_Project_And_Apply_Config --
1634 --------------------------------------
1636 procedure Process_Project_And_Apply_Config
1637 (Main_Project : out Prj.Project_Id;
1638 User_Project_Node : Prj.Tree.Project_Node_Id;
1639 Config_File_Name : String := "";
1640 Autoconf_Specified : Boolean;
1641 Project_Tree : Prj.Project_Tree_Ref;
1642 Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
1643 Env : in out Prj.Tree.Environment;
1644 Packages_To_Check : String_List_Access;
1645 Allow_Automatic_Generation : Boolean := True;
1646 Automatically_Generated : out Boolean;
1647 Config_File_Path : out String_Access;
1648 Target_Name : String := "";
1649 Normalized_Hostname : String;
1650 On_Load_Config : Config_File_Hook := null;
1651 Reset_Tree : Boolean := True;
1652 On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
1654 Shared : constant Shared_Project_Tree_Data_Access :=
1655 Project_Tree.Shared;
1656 Main_Config_Project : Project_Id;
1659 Conf_Project : Project_Id := No_Project;
1660 -- The object directory of this project is used to store the config
1661 -- project file in auto-configuration. Set by Check_Project below.
1663 procedure Check_Project (Project : Project_Id);
1664 -- Look for a non aggregate project. If one is found, put its project Id
1671 procedure Check_Project (Project : Project_Id) is
1673 if Project.Qualifier = Aggregate
1675 Project.Qualifier = Aggregate_Library
1678 List : Aggregated_Project_List := Project.Aggregated_Projects;
1681 -- Look for a non aggregate project until one is found
1683 while Conf_Project = No_Project and then List /= null loop
1684 Check_Project (List.Project);
1690 Conf_Project := Project;
1694 -- Start of processing for Process_Project_And_Apply_Config
1697 Main_Project := No_Project;
1698 Automatically_Generated := False;
1700 Process_Project_Tree_Phase_1
1701 (In_Tree => Project_Tree,
1702 Project => Main_Project,
1703 Packages_To_Check => Packages_To_Check,
1705 From_Project_Node => User_Project_Node,
1706 From_Project_Node_Tree => Project_Node_Tree,
1708 Reset_Tree => Reset_Tree,
1709 On_New_Tree_Loaded => On_New_Tree_Loaded);
1712 Main_Project := No_Project;
1716 if Project_Tree.Source_Info_File_Name /= null then
1717 if not Is_Absolute_Path (Project_Tree.Source_Info_File_Name.all) then
1719 Obj_Dir : constant Variable_Value :=
1722 Main_Project.Decl.Attributes,
1726 if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then
1727 Get_Name_String (Main_Project.Directory.Display_Name);
1730 if Is_Absolute_Path (Get_Name_String (Obj_Dir.Value)) then
1731 Get_Name_String (Obj_Dir.Value);
1735 Add_Str_To_Name_Buffer
1736 (Get_Name_String (Main_Project.Directory.Display_Name));
1737 Add_Str_To_Name_Buffer (Get_Name_String (Obj_Dir.Value));
1741 Add_Char_To_Name_Buffer (Directory_Separator);
1742 Add_Str_To_Name_Buffer (Project_Tree.Source_Info_File_Name.all);
1743 Free (Project_Tree.Source_Info_File_Name);
1744 Project_Tree.Source_Info_File_Name :=
1745 new String'(Name_Buffer
(1 .. Name_Len
));
1749 Read_Source_Info_File
(Project_Tree
);
1752 -- Get the first project that is not an aggregate project or an
1753 -- aggregate library project. The object directory of this project will
1754 -- be used to store the config project file in auto-configuration.
1756 Check_Project
(Main_Project
);
1758 -- Fail if there is only aggregate projects and aggregate library
1759 -- projects in the project tree.
1761 if Conf_Project
= No_Project
then
1762 Raise_Invalid_Config
("there are no non-aggregate projects");
1765 -- Find configuration file
1767 Get_Or_Create_Configuration_File
1768 (Config
=> Main_Config_Project
,
1769 Project
=> Main_Project
,
1770 Conf_Project
=> Conf_Project
,
1771 Project_Tree
=> Project_Tree
,
1772 Project_Node_Tree
=> Project_Node_Tree
,
1774 Allow_Automatic_Generation
=> Allow_Automatic_Generation
,
1775 Config_File_Name
=> Config_File_Name
,
1776 Autoconf_Specified
=> Autoconf_Specified
,
1777 Target_Name
=> Target_Name
,
1778 Normalized_Hostname
=> Normalized_Hostname
,
1779 Packages_To_Check
=> Packages_To_Check
,
1780 Config_File_Path
=> Config_File_Path
,
1781 Automatically_Generated
=> Automatically_Generated
,
1782 On_Load_Config
=> On_Load_Config
);
1784 Apply_Config_File
(Main_Config_Project
, Project_Tree
);
1786 -- Finish processing the user's project
1788 Prj
.Proc
.Process_Project_Tree_Phase_2
1789 (In_Tree
=> Project_Tree
,
1790 Project
=> Main_Project
,
1792 From_Project_Node
=> User_Project_Node
,
1793 From_Project_Node_Tree
=> Project_Node_Tree
,
1797 if Project_Tree
.Source_Info_File_Name
/= null
1798 and then not Project_Tree
.Source_Info_File_Exists
1800 Write_Source_Info_File
(Project_Tree
);
1804 Main_Project
:= No_Project
;
1806 end Process_Project_And_Apply_Config
;
1808 --------------------------
1809 -- Raise_Invalid_Config --
1810 --------------------------
1812 procedure Raise_Invalid_Config
(Msg
: String) is
1814 Raise_Exception
(Invalid_Config
'Identity, Msg
);
1815 end Raise_Invalid_Config
;
1817 ----------------------
1818 -- Runtime_Name_For --
1819 ----------------------
1821 function Runtime_Name_For
(Language
: Name_Id
) return String is
1823 if RTS_Languages
.Get
(Language
) /= No_Name
then
1824 return Get_Name_String
(RTS_Languages
.Get
(Language
));
1828 end Runtime_Name_For
;
1830 --------------------------
1831 -- Runtime_Name_Set_For --
1832 --------------------------
1834 function Runtime_Name_Set_For
(Language
: Name_Id
) return Boolean is
1836 return RTS_Languages
.Get
(Language
) /= No_Name
;
1837 end Runtime_Name_Set_For
;
1839 ---------------------
1840 -- Set_Runtime_For --
1841 ---------------------
1843 procedure Set_Runtime_For
(Language
: Name_Id
; RTS_Name
: String) is
1845 Name_Len
:= RTS_Name
'Length;
1846 Name_Buffer
(1 .. Name_Len
) := RTS_Name
;
1847 RTS_Languages
.Set
(Language
, Name_Find
);
1848 end Set_Runtime_For
;