public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-401] [Ada] Take into account GNSA_ROOT env var for prefix
@ 2022-05-13  8:08 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-13  8:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:17a89d82142be1fd9d9a8a584977f41204e13463

commit r13-401-g17a89d82142be1fd9d9a8a584977f41204e13463
Author: Johannes Kanig <kanig@adacore.com>
Date:   Thu Feb 24 19:47:47 2022 +0900

    [Ada] Take into account GNSA_ROOT env var for prefix
    
    The GNSA_ROOT environment variable can be used to indicate to the
    compiler how to find the runtime directory.
    
    gcc/ada/
    
            * osint.ads, osint.adb (Relocate_Path): If the GNSA_ROOT
            environment variable is set, we use that as the prefix, instead
            of computing the prefix from the executable location.

Diff:
---
 gcc/ada/osint.adb | 20 +++++++++++++++++++-
 gcc/ada/osint.ads |  7 +++++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index 15f0692ab05..a38ad7874e3 100644
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -2758,7 +2758,25 @@ package body Osint is
 
    begin
       if Std_Prefix = null then
-         Std_Prefix := Executable_Prefix;
+         Std_Prefix := String_Ptr (Getenv ("GNSA_ROOT"));
+
+         if Std_Prefix.all = "" then
+            Std_Prefix := Executable_Prefix;
+
+         elsif not Is_Directory_Separator (Std_Prefix (Std_Prefix'Last)) then
+
+            --  The remainder of this function assumes that Std_Prefix
+            --  terminates with a dir separator, so we force this here.
+
+            declare
+               Old_Prefix : String_Ptr := Std_Prefix;
+            begin
+               Std_Prefix := new String (1 .. Old_Prefix'Length + 1);
+               Std_Prefix (1 .. Old_Prefix'Length) := Old_Prefix.all;
+               Std_Prefix (Old_Prefix'Length + 1) := Directory_Separator;
+               Free (Old_Prefix);
+            end;
+         end if;
 
          if Std_Prefix.all /= "" then
 
diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads
index a4a863e1155..328619c103d 100644
--- a/gcc/ada/osint.ads
+++ b/gcc/ada/osint.ads
@@ -237,8 +237,11 @@ package Osint is
    --  replace the Prefix substring with the root installation directory.
    --  By default, try to compute the root installation directory by looking
    --  at the executable name as it was typed on the command line and, if
-   --  needed, use the PATH environment variable. If the above computation
-   --  fails, return Path. This function assumes Prefix'First = Path'First.
+   --  needed, use the PATH environment variable. If the GNSA_ROOT environment
+   --  variable is set, then the content of this variable is used as the root
+   --  installation directory.
+   --  If the above computation fails, return Path. This function assumes
+   --  Prefix'First = Path'First.
 
    function Shared_Lib (Name : String) return String;
    --  Returns the runtime shared library in the form -l<name>-<version> where


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-13  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  8:08 [gcc r13-401] [Ada] Take into account GNSA_ROOT env var for prefix Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).