Skip to content

Commit

Permalink
support: allow override of ADAFLAGS, LDFLAGS, library soversion
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon committed Nov 23, 2021
1 parent c0a4bda commit 5a8f16a
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions support/langkit_support.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ library project Langkit_Support is
Library_Kind_Param : Library_Kind_Type := external
("LIBRARY_TYPE", external ("LANGKIT_SUPPORT_LIBRARY_TYPE", "static"));

type OS_Kind is ("", "windows", "unix", "osx");
OS : OS_Kind := External ("LANGKIT_SUPPORT_OS", "");

SO_Version := External ("LANGKIT_SUPPORT_SOVERSION", "1");

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 @@ -70,20 +78,40 @@ library project Langkit_Support is

for Library_Dir use "lib/" & Library_Kind_Param & "/" & Build_Mode;

case Library_Kind_Param is
when "relocatable" =>
case OS is
when "windows" =>
for Library_Version use "lib" & project'Library_Name
& ".dll." & SO_Version;
when "osx" =>
for Library_Version use "lib" & project'Library_Name
& ".dylib." & SO_Version;
when "unix" =>
for Library_Version use "lib" & project'Library_Name
& ".so." & SO_Version;
when "" =>
null;
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
Mode_Args := ();
case Build_Mode is
when "dev" =>
for Default_Switches ("Ada") use
Common_Ada_Cargs & ("-g", "-O0", "-gnatwe", "-gnata");

Mode_Args := ("-g", "-O0", "-gnatwe", "-gnata");
when "prod" =>
-- Debug information is useful even with optimization for
-- profiling, for instance.
for Default_Switches ("Ada") use
Common_Ada_Cargs & ("-g", "-Ofast");
Mode_Args := ("-g", "-Ofast");
end case;
for Default_Switches ("Ada") use Common_Ada_Cargs & Mode_Args
& Ada_Flags;
end Compiler;

end Langkit_Support;

0 comments on commit 5a8f16a

Please sign in to comment.