diff options
author | Johannes Kanig <kanig@adacore.com> | 2022-02-24 19:47:47 +0900 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-13 08:04:38 +0000 |
commit | 17a89d82142be1fd9d9a8a584977f41204e13463 (patch) | |
tree | 6b86b5dab9c110d50ad91938feb1cda1c46beff2 /gcc/ada/osint.adb | |
parent | b77029ff250b7a6b0a8f07aa0c4199adca2f4e91 (diff) | |
download | gcc-17a89d82142be1fd9d9a8a584977f41204e13463.zip gcc-17a89d82142be1fd9d9a8a584977f41204e13463.tar.gz gcc-17a89d82142be1fd9d9a8a584977f41204e13463.tar.bz2 |
[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.
Diffstat (limited to 'gcc/ada/osint.adb')
-rw-r--r-- | gcc/ada/osint.adb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index 15f0692..a38ad78 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 |