@@ -113,6 +113,12 @@ package body TGen.Libgen is
113113 -- Include all the types in Source in the correct package key in Dest. All
114114 -- anonymous types are ignored.
115115
116+ function Lang_Version_To_Attr
117+ (Version : Ada_Language_Version) return String;
118+ -- Return the corresponding string to be added to the
119+ -- Compiler.Default_Switches attribute. This will return the empty string
120+ -- if Version is Unspecified.
121+
116122 -- --------------------
117123 -- Replace_Standard --
118124 -- --------------------
@@ -922,11 +928,19 @@ package body TGen.Libgen is
922928 Put_Line (Prj_File, " package Compiler is" );
923929 Put_Line (Prj_File, " case Build_Mode is" );
924930 Put_Line (Prj_File, " when "" dev"" =>" );
925- Put_Line (Prj_File, " for Default_Switches ("" Ada"" ) use"
926- & " ("" -g"" , "" -gnatg"" , "" -gnatyN"" , "" -gnatws"" );" );
931+ Put (Prj_File, " for Default_Switches ("" Ada"" ) use"
932+ & " ("" -g"" , "" -gnatg"" , "" -gnatyN"" , "" -gnatws"" " );
933+ if Ctx.Lang_Version /= Unspecified then
934+ Put (Prj_File, " , " & Lang_Version_To_Attr (Ctx.Lang_Version));
935+ end if ;
936+ Put_Line (Prj_File, " );" );
927937 Put_Line (Prj_File, " when "" prod"" =>" );
928938 Put_Line (Prj_File, " for Default_Switches ("" Ada"" ) use"
929- & " ("" -gnatg"" , "" -gnatyN"" , "" -gnatws"" );" );
939+ & " ("" -gnatg"" , "" -gnatyN"" , "" -gnatws"" " );
940+ if Ctx.Lang_Version /= Unspecified then
941+ Put (Prj_File, " , " & Lang_Version_To_Attr (Ctx.Lang_Version));
942+ end if ;
943+ Put_Line (Prj_File, " );" );
930944 Put_Line (Prj_File, " end case;" );
931945 Put_Line (Prj_File, " end Compiler;" );
932946 New_Line (Prj_File);
@@ -1320,6 +1334,11 @@ package body TGen.Libgen is
13201334 Put_Line (Prj_File, " project TGen_Generation_Harness is" );
13211335 Put_Line (Prj_File, " for Main use ("" generation_main.adb"" );" );
13221336 Put_Line (Prj_File, " for Object_Dir use "" obj"" ;" );
1337+ Put_Line (Prj_File, " package Compiler is" );
1338+ Put (Prj_File, " for Default_Switches ("" Ada"" ) use (" );
1339+ Put (Prj_File, Lang_Version_To_Attr (Ctx.Lang_Version) & " );" );
1340+ Ada.Text_IO.Put_Line (Prj_File, " end Compiler;" );
1341+
13231342 Put_Line (Prj_File, " end TGen_Generation_Harness;" );
13241343 Close (Prj_File);
13251344
@@ -1371,4 +1390,25 @@ package body TGen.Libgen is
13711390 TGen.Marshalling.Set_Array_Size_Limit (Limit);
13721391 end Set_Array_Size_Limit ;
13731392
1393+ -- ----------------------------
1394+ -- Set_Minimum_Lang_Version --
1395+ -- ----------------------------
1396+
1397+ procedure Set_Minimum_Lang_Version
1398+ (Ctx : in out Libgen_Context; Version : Ada_Language_Version) is
1399+ begin
1400+ Ctx.Lang_Version := Version;
1401+ end Set_Minimum_Lang_Version ;
1402+
1403+ -- ------------------------
1404+ -- Lang_Version_To_Attr --
1405+ -- ------------------------
1406+
1407+ function Lang_Version_To_Attr
1408+ (Version : Ada_Language_Version) return String is
1409+ (case Version is
1410+ when Unspecified => " " ,
1411+ when Ada_12 => " "" -gnat2012"" " ,
1412+ when Ada_22 => " "" -gnat2022"" " );
1413+
13741414end TGen.Libgen ;
0 commit comments