Netatalk / netatalk

Netatalk is a Free and Open Source AFP fileserver. A *NIX or BSD system running Netatalk is capable of serving many Macintosh clients simultaneously as an AppleShare file server.
https://netatalk.io
GNU General Public License v2.0
327 stars 84 forks source link

Allow exclusion of static libraries during build #1305

Closed knight-of-ni closed 1 month ago

knight-of-ni commented 1 month ago

Is your feature request related to a problem? Please describe. Fedora packaging guideline dictate we exclude all static libraries from rpm packages. When all else fails, I must find and delete all .a files after they are built.

Describe the solution you'd like Add a meson build flag to avoid building any static libraries

Describe alternatives you've considered Meson has a _defaultlibrary flag, but that only works if the library function is used in meson.build.

Additional context For libatalk this should be a simple change from _bothlibraries -> library here: https://github.com/Netatalk/netatalk/blob/main/libatalk/meson.build#L29

For the uams libraries, something different would be needed: https://github.com/Netatalk/netatalk/blob/main/etc/uams/meson.build

Static libraries are built with _staticlibrary while the dynamic libraries are built separately, using _sharedmodule. I'm not sure why it was done separately that way. Rather than rewrite that, perhaps you could add a conditional statement to exclude the static_library blocks when default_library is set to shared.

NOTE: I'm sure you know where and what changes need to be made. I am citing references primarily for my own understanding.

rdmark commented 1 month ago

Thanks for the notes, this is helpful for contextualizing your thought process. I'm not entirely sure why @dgsga defined the libatalk/UAM libraries in this way, but I'm sure it was as part of an attempt to emulate the behavior of Autotools. A conditional statement sounds like the safest thing to do for the stable 3.2 branch, but for the main dev branch I will try to refactor the whole thing and then run some tests on all the supported platforms.

rdmark commented 1 month ago

Interestingly, the shared_module() build target is deprecated for non-Android platforms so in the long run we have to refactor the UAM build script anyways.

https://mesonbuild.com/Reference-manual_functions.html#shared_module

rdmark commented 1 month ago

@knight-of-ni I have two different solutions lined up, the workaround for 3.2 and the refactoring for main.

3.2: https://github.com/Netatalk/netatalk/pull/1321 main: https://github.com/Netatalk/netatalk/pull/1320

After attempting both, I feel inclined to favor the latter. It's less code and less complexity with the same outcome across all supported OSes. What do you think?

knight-of-ni commented 1 month ago

Yeah, #1320 looks much cleaner to me. All the CI workflows completed, so we can be reasonably certain we didn't break someone else's environment by attempting to fix mine (i.e. the BSD workflows in particular).

I'll test this one sometime today... I'm remote, trying to upgrade the fedora vm on this laptop to f40 through a jetpack. lol

rdmark commented 1 month ago

Cheers, I've gone ahead and aligned the PRs for the stable branches with this solution.

What I found out through this work is that every single OS that we support and test on default to shared libraries solely (when using Meson.) So we are currently not building static libraries at all in the CI workflow. But I have been testing the building of static libraries locally. I don't know what the actual usecase for static libraries would be for Netatalk specifically?

rdmark commented 1 month ago

@knight-of-ni I merged the PR for the main branch, but am holding off on updating the stable branches until you've confirmed that this solution works for your needs.

knight-of-ni commented 1 month ago

I am in transit today. If I don't get to this tonight, then I'll test it tomorrow.

rdmark commented 1 month ago

That works, cheers.

I'm planning to cut a 3.2.5 release the coming weekend, which I'm hoping will be a good one for Fedora packaging. :)

knight-of-ni commented 1 month ago

Yes, this appears to work. No .a static libraries were built when I set -Ddefault_library=shared.

rdmark commented 1 month ago

Excellent, thank you for testing. I have merged the stable branch PRs now.