Skip to content

Commit

Permalink
support: allow override of ADAFLAGS, LDFLAGS, library Shared Object v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
asarhaddon committed Mar 13, 2024
1 parent 7bbd9f3 commit 2753602
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions langkit/support/langkit_support.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ library project Langkit_Support is
Library_Standalone : Library_Standalone_Type := external
("LANGKIT_SUPPORT_STANDALONE", external ("STANDALONE", "standard"));

SO_Name := External ("LANGKIT_SUPPORT_SONAME", "");
Ada_Flags := External_As_List ("ADAFLAGS", " ");
Ld_Flags := External_As_List ("LDFLAGS", " ");

for Languages use ("Ada");
for Source_Dirs use (".");
for Object_Dir use "obj/" & Build_Mode;
Expand Down Expand Up @@ -82,25 +86,39 @@ library project Langkit_Support is
for Library_Kind use Library_Kind_Param;
for Library_Dir use "lib/" & Library_Kind_Param & "/" & Build_Mode;

case Library_Kind_Param is
when "relocatable" =>
case SO_Name is
when "" =>
null;
when others =>
for Library_Version use SO_Name;
end case;
for Leading_Library_Options use Ld_Flags;
when "static" | "static-pic" =>
null;
end case;

Common_Ada_Cargs := ("-gnatwa", "-gnatyg", "-fPIC");

package Compiler is
case Build_Mode is
when "dev" =>
for Default_Switches ("Ada") use
Common_Ada_Cargs & ("-g", "-O0", "-gnatwe", "-gnata");
Common_Ada_Cargs & ("-g", "-O0", "-gnatwe", "-gnata")
& Ada_Flags;

when "prod" =>
-- Debug information is useful even with optimization for
-- profiling, for instance.
for Default_Switches ("Ada") use
Common_Ada_Cargs & ("-g", "-Ofast");
Common_Ada_Cargs & ("-g", "-Ofast") & Ada_Flags;

when "prof" =>
-- Ensure that we have a relatively fast build but with all
-- possible stack info & debug info, for profiling.
for Default_Switches ("Ada") use
("-Og", "-ggdb", "-g3", "-fno-omit-frame-pointer");
("-Og", "-ggdb", "-g3", "-fno-omit-frame-pointer") & Adaflags;
end case;
end Compiler;

Expand Down

0 comments on commit 2753602

Please sign in to comment.