summaryrefslogtreecommitdiff
path: root/gcc/ada/prj-util.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-29 12:37:05 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-29 12:37:05 +0000
commit12cb78d1cca1387a092ec0bd49c250340bff4afc (patch)
tree1eab97da96906e0a2786d51d9f25f20de02befcf /gcc/ada/prj-util.adb
parent31879e18aea3222fe3e56f2c0319c9f230645ff3 (diff)
downloadgcc-12cb78d1cca1387a092ec0bd49c250340bff4afc.tar.gz
2012-08-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 190745 using svnmerge, notably C++ conversion. [gcc/] 2012-08-29 Basile Starynkevitch <basile@starynkevitch.net> {{merging with trunk, converted to C++}} * melt-runtime.h (MELT_FLEXIBLE_DIM): Set when C++. * melt-runtime.c (melt_tempdir_path): Don't use choose_tmpdir from libiberty. (meltgc_start_module_by_index): Use address-of & on VEC_index. (melt_really_initialize): When printing builtin settings, handle GCC 4.8 as with implicit ENABLE_BUILD_WITH_CXX. (meltgc_out_edge): Provide additional flag TDF_DETAILS for dump_edge_info. (melt_val2passflag): Handle PROP_referenced_vars only when defined. * melt-module.mk: Use GCCMELT_COMPILER instead of GCCMELT_CC. * melt-build-script.tpl: Transmit GCCMELT_COMPILER on every make using melt-module.mk and improve the error message. * melt-build-script.sh: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@190778 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/prj-util.adb')
-rw-r--r--gcc/ada/prj-util.adb148
1 files changed, 147 insertions, 1 deletions
diff --git a/gcc/ada/prj-util.adb b/gcc/ada/prj-util.adb
index 9454f9ff418..1ad1aff58a7 100644
--- a/gcc/ada/prj-util.adb
+++ b/gcc/ada/prj-util.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2011, Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -23,11 +23,14 @@
-- --
------------------------------------------------------------------------------
+with Ada.Containers.Indefinite_Ordered_Sets;
+with Ada.Directories;
with Ada.Unchecked_Deallocation;
with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.Regexp; use GNAT.Regexp;
+with ALI; use ALI;
with Osint; use Osint;
with Output; use Output;
with Opt;
@@ -390,6 +393,149 @@ package body Prj.Util is
return Add_Suffix (Name_Find);
end Executable_Of;
+ ---------------------------
+ -- For_Interface_Sources --
+ ---------------------------
+
+ procedure For_Interface_Sources
+ (Tree : Project_Tree_Ref;
+ Project : Project_Id)
+ is
+ use Ada;
+ use type Ada.Containers.Count_Type;
+
+ package Dep_Names is new Containers.Indefinite_Ordered_Sets (String);
+
+ function Load_ALI (Filename : String) return ALI_Id;
+ -- Load an ALI file and return its id
+
+ --------------
+ -- Load_ALI --
+ --------------
+
+ function Load_ALI (Filename : String) return ALI_Id is
+ Result : ALI_Id := No_ALI_Id;
+ Text : Text_Buffer_Ptr;
+ Lib_File : File_Name_Type;
+
+ begin
+ if Directories.Exists (Filename) then
+ Name_Len := 0;
+ Add_Str_To_Name_Buffer (Filename);
+ Lib_File := Name_Find;
+ Text := Osint.Read_Library_Info (Lib_File);
+ Result :=
+ ALI.Scan_ALI
+ (Lib_File,
+ Text,
+ Ignore_ED => False,
+ Err => True,
+ Read_Lines => "UD");
+ Free (Text);
+ end if;
+
+ return Result;
+ end Load_ALI;
+
+ -- Local declarations
+
+ Iter : Source_Iterator := For_Each_Source (Tree, Project);
+ Sid : Source_Id;
+ ALI : ALI_Id;
+
+ First_Unit : Unit_Id;
+ Second_Unit : Unit_Id;
+ Body_Needed : Boolean;
+ Deps : Dep_Names.Set;
+
+ -- Start of processing for For_Interface_Sources
+
+ begin
+ -- First look at each spec, check if the body is needed
+
+ loop
+ Sid := Element (Iter);
+ exit when Sid = No_Source;
+
+ -- Skip sources that are removed/excluded and sources not part of
+ -- the interface for standalone libraries.
+
+ if Sid.Kind = Spec
+ and then not Sid.Locally_Removed
+ and then (Project.Standalone_Library = No
+ or else Sid.Declared_In_Interfaces)
+ then
+ Action (Sid);
+
+ -- Check ALI for dependencies on body and sep
+
+ ALI :=
+ Load_ALI
+ (Get_Name_String (Get_Object_Directory (Sid.Project, True))
+ & Get_Name_String (Sid.Dep_Name));
+
+ if ALI /= No_ALI_Id then
+ First_Unit := ALIs.Table (ALI).First_Unit;
+ Second_Unit := No_Unit_Id;
+ Body_Needed := True;
+
+ -- If there is both a spec and a body, check if both needed
+
+ if Units.Table (First_Unit).Utype = Is_Body then
+ Second_Unit := ALIs.Table (ALI).Last_Unit;
+
+ -- If the body is not needed, then reset First_Unit
+
+ if not Units.Table (Second_Unit).Body_Needed_For_SAL then
+ Body_Needed := False;
+ end if;
+
+ elsif Units.Table (First_Unit).Utype = Is_Spec_Only then
+ Body_Needed := False;
+ end if;
+
+ -- Handle all the separates, if any
+
+ if Body_Needed then
+ if Other_Part (Sid) /= null then
+ Deps.Include (Get_Name_String (Other_Part (Sid).File));
+ end if;
+
+ for Dep in ALIs.Table (ALI).First_Sdep ..
+ ALIs.Table (ALI).Last_Sdep
+ loop
+ if Sdep.Table (Dep).Subunit_Name /= No_Name then
+ Deps.Include
+ (Get_Name_String (Sdep.Table (Dep).Sfile));
+ end if;
+ end loop;
+ end if;
+ end if;
+ end if;
+
+ Next (Iter);
+ end loop;
+
+ -- Now handle the bodies and separates if needed
+
+ if Deps.Length /= 0 then
+ Iter := For_Each_Source (Tree, Project);
+
+ loop
+ Sid := Element (Iter);
+ exit when Sid = No_Source;
+
+ if Sid.Kind /= Spec
+ and then Deps.Contains (Get_Name_String (Sid.File))
+ then
+ Action (Sid);
+ end if;
+
+ Next (Iter);
+ end loop;
+ end if;
+ end For_Interface_Sources;
+
--------------
-- Get_Line --
--------------