alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

Enhancement proposal for crate.gpr and crate_config.gpr. #1183

Open Blady-Com opened 2 years ago

Blady-Com commented 2 years ago

The extension of a shared lib, which is depending of the OS, can be easily computed in crate_config.gpr:

   So_Ext := "";
   case Alire_Host_OS is
      when "linux" =>
         So_Ext := ".so";
      when "macos" =>
         So_Ext := ".dylib";
      when "windows" =>
         So_Ext := ".dll";
      when others =>
         So_Ext := ".so";
   end case;

Thus Library_Version can be computed in crate.gpr: for Library_Version use "lib" & Project'Library_Name & Crate_Config.So_Ext & "." & Crate_Config.Crate_Version;

Fabien-Chouteau commented 2 years ago

Isn't gprbuild already doing the right thing for the file extension?

For the version number, I think this is only done on "UNIX" systems. And with sym-links.

mosteo commented 2 years ago

In my system, there's a symlink from the major number to the precise versioned library:

libX11.so.6 -> libX11.so.6.4.0

Why this isn't done for static libs too I don't know.

Blady-Com commented 2 years ago

I saw this practice of AdaCore for instance in gnatcoll_sqlite.gpr:

for Library_Version use
            "lib" & project'Library_Name & Gnatcoll.So_Ext & "." & Version;
simonjwright commented 2 years ago

In my system, there's a symlink from the major number to the precise versioned library:

libX11.so.6 -> libX11.so.6.4.0

Why this isn't done for static libs too I don't know.

It’s a runtime thing, I think. You link against libX11.so, which is a symlink to libX11.so.6, which is a symlink to libX11.so.6.4.0, so if at runtime (on another machine, maybe) that final symlink is to libX11.so.6.3.0 the executable can still run.

Blady-Com commented 2 years ago

Why this isn't done for static libs too I don't know.

Static libs are directly linked in the executable. Version can't be anymore change at runtime as Simon explain for dynamic libs. So no need for a version number (when you built the executable you should know which version you linked with :-).

mosteo commented 2 years ago

Static libs are directly linked in the executable. Version can't be anymore change at runtime as Simon explain for dynamic libs. So no need for a version number (when you built the executable you should know which version you linked with :-).

Yes, but this precludes having two static versions available simultaneously for development. I guess those systems deem one the "current" system-wide.

simonjwright commented 2 years ago

@Fabien-Chouteau:

Isn't gprbuild already doing the right thing for the file extension?

Yes.

simonjwright commented 2 years ago

@mosteo :

Yes, but this precludes having two static versions available simultaneously for development. I guess those systems deem one the "current" system-wide.

I think if you wanted two different relocatable library versions during development you’d keep them in separate directories. Same for static libraries.