Skip to content

Commit

Permalink
Merge branch 'eyraud/48' into 'master'
Browse files Browse the repository at this point in the history
Set GPR.Opt.Target_Value when target is explicitly set

Closes #48

See merge request eng/toolchain/gnatcoll-core!93
  • Loading branch information
Jugst3r committed Apr 8, 2024
2 parents 1251029 + 73a33ea commit 1b0ad29
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/projects/gnatcoll-projects.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7939,6 +7939,7 @@ package body GNATCOLL.Projects is
Free (Self.Forced_Runtime);
if Target /= "" then
Self.Forced_Target := new String'(Target);
GPR.Opt.Target_Value := new String'(Normalize_Target_Name (Target));
end if;
if Runtime /= "" then
Self.Forced_Runtime := new String'(Runtime);
Expand Down
15 changes: 15 additions & 0 deletions testsuite/tests/projects/project_attribute/main_common.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
abstract project Main_Common is

Target := project'Target;

Target_Dir := "error :(";
case Target is
when "x86_64-pc-linux-gnu" =>
Target_Dir := "obj-x86";
when others =>
Target_Dir := "unknown-";
end case;

Build_Dir := "../" & Target_Dir;

end Main_Common;
15 changes: 15 additions & 0 deletions testsuite/tests/projects/project_attribute/main_x86.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
with "main_common.gpr";

project Main_x86 is

for Target use "x86_64-pc-linux-gnu";

for Languages use ("Ada");

for Source_Dirs use (".");

for Main use ("main.adb");

for Object_Dir use Main_Common.Build_Dir;

end Main_x86;
26 changes: 26 additions & 0 deletions testsuite/tests/projects/project_attribute/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
with GNATCOLL.Projects; use GNATCOLL.Projects;
with GNATCOLL.VFS; use GNATCOLL.VFS;

with Test_Assert;

function Test return Integer is
PT : Project_Tree;
Env : Project_Environment_Access;
begin
Initialize (Env);
Env.Set_Target_And_Runtime (Target => "x86_64-pc-linux-gnu");

GNATCOLL.Projects.Load
(PT,
Root_Project_Path => Create ("main_x86.gpr"),
Env => Env);

-- Check that the object directory name is as expected

Test_Assert.Assert
(PT.Root_Project.Object_Dir.Base_Dir_Name = "obj-x86");

PT.Unload;
Free (Env);
return Test_Assert.Report;
end Test;
6 changes: 6 additions & 0 deletions testsuite/tests/projects/project_attribute/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Check that the value for the Project attribute is correct
data:
- "main_common.gpr"
- "main_x86.gpr"
control:
- [SKIP, "env.is_cross", "Libutil missing from cross-linux sysroots, see T616-039"]

0 comments on commit 1b0ad29

Please sign in to comment.