2.99 meson: app/meson.build builds static library libapp but doesn't use it properly
In app/meson.build:
libapp_sources = [
'app.c',
'errors.c',
'gimp-debug.c',
'gimp-log.c',
'gimp-update.c',
'gimp-version.c',
'language.c',
'sanity.c',
'signals.c',
'tests.c',
'unique.c',
gitversion_h,
gimpdbusservice_gen,
]
libapp = static_library('app',
libapp_sources,
include_directories: [ rootInclude, rootAppInclude, configInclude, ],
c_args: [ '-DG_LOG_DOMAIN="Gimp"', '-DGIMP_APP_GLUE_COMPILATION', ],
dependencies: [
gegl, gdk_pixbuf, gtk3,
],
)
That creates a list of source file names, then compiles a static library target named "libapp" from that list. In meson, a static library defaults to not installed.
Later:
gimpconsole_exe = executable('gimp-console-'+gimp_app_version,
'main.c',
libapp_sources,
console_rc_file,
c_args: [
... omitted
gimpmain_exe = executable('gimp-'+gimp_app_version,
'main.c',
libapp_sources,
gui_rc_file,
c_args: [
... omitted
Instead, in two places, it should be:
gimpmain_exe = executable('gimp-'+gimp_app_version,
'main.c',
libapp, <<<<<<<<<<
Then the gimpmain_exe target has as input the static library instead of the sources for the static library. Then the sources are not compiled again, and the linker makes an executable a tiny bit smaller (since linking from object files is not as optimized as linking from a static library?)
"libapp_sources" doesn't really need to be defined because the list should only be used once to build the static library libapp.
There is a comment in the AM makefile that libapp static library is built so that it can be linked into test programs. That comment should be in the meson.build.
There might be other places where libapp is put in a list, where it doesn't need to be.
I could be wrong, I am not that familiar with Gimp build. There could be an order problem that I don't know about. I did try it, it still builds, the binary is 7k smaller, and it still seems to work.