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 Nov 14, 2021
1 parent c0a4bda commit 5d510ec
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 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", "windows");

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

Adaflags := External_As_List ("ADAFLAGS", " ");
Ldflags := 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,35 @@ library project Langkit_Support is

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

So_Ext := "";
case OS is
when "windows" => So_Ext := "dll";
when "osx" => So_Ext := "dylib";
when "unix" => So_Ext := "so";
end case;

case Library_Kind_Param is
when "relocatable" =>
for Library_version use "lib" & project'Library_Name & "." & So_Ext
& "." & Soversion;
for Leading_Library_Options use Ldflags;
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 & Adaflags;
end Compiler;

end Langkit_Support;

0 comments on commit 5d510ec

Please sign in to comment.