Skip to content

Commit 1b0ad29

Browse files
committed
Merge branch 'eyraud/48' into 'master'
Set GPR.Opt.Target_Value when target is explicitly set Closes #48 See merge request eng/toolchain/gnatcoll-core!93
2 parents 1251029 + 73a33ea commit 1b0ad29

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

src/projects/gnatcoll-projects.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7939,6 +7939,7 @@ package body GNATCOLL.Projects is
79397939
Free (Self.Forced_Runtime);
79407940
if Target /= "" then
79417941
Self.Forced_Target := new String'(Target);
7942+
GPR.Opt.Target_Value := new String'(Normalize_Target_Name (Target));
79427943
end if;
79437944
if Runtime /= "" then
79447945
Self.Forced_Runtime := new String'(Runtime);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
abstract project Main_Common is
2+
3+
Target := project'Target;
4+
5+
Target_Dir := "error :(";
6+
case Target is
7+
when "x86_64-pc-linux-gnu" =>
8+
Target_Dir := "obj-x86";
9+
when others =>
10+
Target_Dir := "unknown-";
11+
end case;
12+
13+
Build_Dir := "../" & Target_Dir;
14+
15+
end Main_Common;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
with "main_common.gpr";
2+
3+
project Main_x86 is
4+
5+
for Target use "x86_64-pc-linux-gnu";
6+
7+
for Languages use ("Ada");
8+
9+
for Source_Dirs use (".");
10+
11+
for Main use ("main.adb");
12+
13+
for Object_Dir use Main_Common.Build_Dir;
14+
15+
end Main_x86;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
with GNATCOLL.Projects; use GNATCOLL.Projects;
2+
with GNATCOLL.VFS; use GNATCOLL.VFS;
3+
4+
with Test_Assert;
5+
6+
function Test return Integer is
7+
PT : Project_Tree;
8+
Env : Project_Environment_Access;
9+
begin
10+
Initialize (Env);
11+
Env.Set_Target_And_Runtime (Target => "x86_64-pc-linux-gnu");
12+
13+
GNATCOLL.Projects.Load
14+
(PT,
15+
Root_Project_Path => Create ("main_x86.gpr"),
16+
Env => Env);
17+
18+
-- Check that the object directory name is as expected
19+
20+
Test_Assert.Assert
21+
(PT.Root_Project.Object_Dir.Base_Dir_Name = "obj-x86");
22+
23+
PT.Unload;
24+
Free (Env);
25+
return Test_Assert.Report;
26+
end Test;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: Check that the value for the Project attribute is correct
2+
data:
3+
- "main_common.gpr"
4+
- "main_x86.gpr"
5+
control:
6+
- [SKIP, "env.is_cross", "Libutil missing from cross-linux sysroots, see T616-039"]

0 commit comments

Comments
 (0)