Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meson #1868

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add meson #1868

wants to merge 2 commits into from

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Aug 30, 2021

Signed-off-by: Rosen Penev rosenp@gmail.com

Gonna just post this here. I've tried to make it as similar as the CMakeLists.txt file.

Benefit is smaller size when built with minsize. It also works with coverity's build tool. The CMake one does not for some reason.

Some bugs are fixed compared to the cmake one: libatomic does not get linked unconditionally, the exiv2 auto_ptr hack is "fixed". The actual define needs to match the libc++, not the compiler.

FILE_OFFSET_BITS are also set to 64. Not configurable. ccache is default unless CC/CXX is overridden.

Various hacks still need to be fixed. Notably the git and compile info stuff.

@whyman
Copy link
Member

whyman commented Aug 30, 2021

I would rather have fixes for the CMake.

@neheb neheb force-pushed the meson branch 3 times, most recently from a000d3c to 5970ffd Compare September 2, 2021 04:02
@neheb
Copy link
Contributor Author

neheb commented Sep 2, 2021

Added fixes from Debian 10. Turns out, even clang 7 can compile Gerbera.

@KarlStraussberger
Copy link
Member

Please, add a section to doc/compile to explain usage.

@neheb
Copy link
Contributor Author

neheb commented Sep 6, 2021

Added doc section. Also updated to install files in /usr/share as well.

What's left with the meson build is:

testing support
proper support of compile info. It's currently hardcoded.

The big change is that it's actually usable now. GNOME Builder runs it just fine. Profiling also works.

edit: forgot to mention. I've only done testing on various Linux distros. No testing has been done on macOS or any BSD. MinGW was tested briefly but doesn't compile for unrelated reasons (bad std::fs usage, POSIX APIs, etc...)

Copy link

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, nice to see you considering meson. Some suggestions for potential optimizations:

meson.build Outdated

iconv_dep = cpp.find_library('iconv', required : false)
if not iconv_dep.found()
if cpp.has_function('iconv')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In meson 0.60, you will be able to do dependency('iconv') as I've added a custom lookup in mesonbuild/meson#9205 which will first check if iconv_open is available in libc without any dependencies, and then look for cpp.find_library('iconv').

Unfortunately that does require a version so new it is not even released right now. But it will eventually let you simplify these 8 lines down to 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep this in mind.

meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
@neheb
Copy link
Contributor Author

neheb commented Sep 13, 2021

I think I addressed most stuff.

Some stuff I kept as booleans. Specifically the stuff that needs two or more dependencies.

@neheb
Copy link
Contributor Author

neheb commented Sep 13, 2021

Also note this project uses cxxopts as a single header library. Would it make sense to use https://github.com/mesonbuild/wrapdb/blob/master/subprojects/cxxopts.wrap ?

@eli-schwartz
Copy link

It would, but on the other hand I don't know if you can actually remove the cmake vendored copy just yet...

Either way, meson would be able to take advantage of encapsulation, accountability, and clean upgradeability of the .wrap file interface.

@neheb
Copy link
Contributor Author

neheb commented Sep 13, 2021

https://github.com/gerbera/gerbera/tree/master/scripts contains a bunch of scripts to install newer versions of packages. I assume these "wraps" build and statically link these libraries? If so, that would be a great alternative.

@eli-schwartz
Copy link

eli-schwartz commented Sep 13, 2021

Indeed they do, with -Default_library=static or per-wrap -D<wrapname>:default_library=static meson enforces that those wraps are linked statically.

And they don't even need root in order to do it :p they are just downloaded and checksummed and private copies built. Automatically as part of searching for dependencies, if system copies are not found or if --wrap-mode=forcefallback forces wraps to be preferred.
(Those scripts do not do checksumming, BTW.)

@neheb
Copy link
Contributor Author

neheb commented Sep 13, 2021

I'll test later on Debian 10. fmtlib and spdlog are the issues there.

edit: first problem I see is the massive amount of -Wpsabi warnings on 32-bit ARM :).

@neheb
Copy link
Contributor Author

neheb commented Sep 13, 2021

Hmm doesn't seem to work with meson 0.49.1 (version that comes with Debian 10)

@eli-schwartz
Copy link

For versions of meson earlier than 0.55, automatic wrap fallback via the [provide] section was not yet implemented and that section of the .wrap file will be ignored.

If you need to support versions older than that, the dependency() function takes a kwarg fallback: [ 'subproject_name', 'foo_dep' ] which will fallback to configuring the subproject and looking for the variable foo_dep as the right-hand side of the mapping in the newer style [provide] section.

meson.build Outdated Show resolved Hide resolved
@neheb neheb force-pushed the meson branch 2 times, most recently from 24648dd to 55facea Compare September 14, 2021 03:52
@neheb
Copy link
Contributor Author

neheb commented Sep 14, 2021

Added compile_info. Not totally happy with how it turned out...

@neheb neheb force-pushed the meson branch 2 times, most recently from ef2de62 to 58d4a67 Compare September 14, 2021 04:04
meson.build Outdated
uuid_dep,
]

compile_info = [ '-DCOMPILE_INFO="' +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks painful and complicated indeed. But this seems to be an array with one element, and later inserted as '-DCOMPILE_INFO='.join(compile_info)

I think maybe you meant to not include all those + ' ' +. Just have:


  'WITH_MAGIC=' + magic_dep.found().to_string().to_upper(),
  'WITH_MYSQL=' + mysql_dep.found().to_string().to_upper(),
  'WITH_CURL=' + curl_dep.found().to_string().to_upper(),

etc.

maybe...

foreach info: [
    ['MAGIC', magic_dep],
    ['MYSQL', mysql_dep],
    ...
    ]
    found = info[1].found().to_string().to_upper()
    compile_info += 'WITH_@0@=@1@'.format(info[0], found)
endforeach

I'm very curious why the current cmake build includes COMPILE_INFO about whether or not the tests were enabled. :/ Likewise about whether the systemd unit was installed...

Given most of these are nearly identical to existing libgerbera_args += '-DHAVE_*' it feels like this should be handled in the .cpp source code using preprocessor macros to extend a string. But clearly that is not the current state of the cmake...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the first version. I got output like -DCOMPILE_INFO="-DXXX=TRUE-DYY=FALSE-DZZZ=TRUE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no

-DCOMPILE_INFO=\"WITH_MAGIC=TRUE-DCOMPILE_INFO=WITH_MYSQL=TRUE-DCOMPILE_INFO=WITH_CURL=TRUE-DCOMPILE_INFO=WITH_INOTIFY=TRUE-DCOMPILE_INFO=WITH_JS=TRUE-DCOMPILE_INFO=WITH_TAGLIB=TRUE-DCOMPILE_INFO=WITH_AVCODEC=TRUE-DCOMPILE_INFO=WITH_FFMPEGTHUMBNAILER=TRUE-DCOMPILE_INFO=WITH_EXIF=TRUE-DCOMPILE_I    NFO=WITH_EXIV2=TRUE-DCOMPILE_INFO=WITH_SYSTEMD=TRUE-DCOMPILE_INFO=WITH_LASTFM=TRUE-DCOMPILE_INFO=WITH_DEBUG=TRUE-DCOMPILE_INFO=WITH_TESTS=FALSE\"'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, '-DCOMPILE_INFO='.join(compile_info) will get you:

  • just compile_info, if there is only one element
  • otherwise: compile_info[0] + '-DCOMPILE_INFO=' + compile_info[1] + '-DCOMPILE_INFO=' + compile_info[2] .........

But you have a second copy of -DCOMPILE_INFO= at the beginning of your compile_info string building. So you might as well do compile_info = '-DCOMPILE_INFO=' + ........ followed by add_project_arguments(compile_info, language: 'cpp')

Or, you could do:

add_project_arguments('-DCOMPILE_INFO=' + ' '.join(compile_info), language : 'cpp')

Because the .join() should apply to the single-space separator token.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this:

--- a/meson.build
+++ b/meson.build
@@ -203,24 +203,31 @@ libgerbera_deps = [
   uuid_dep,
 ]

-compile_info = [ '-DCOMPILE_INFO="' +
-  'WITH_MAGIC=' + magic_dep.found().to_string().to_upper() + ' ' +
-  'WITH_MYSQL=' + mysql_dep.found().to_string().to_upper() + ' ' +
-  'WITH_CURL=' + curl_dep.found().to_string().to_upper() + ' ' +
-  'WITH_INOTIFY=' + get_option('inotify').to_string().to_upper() + ' ' +
-  'WITH_JS=' + duktape_dep.found().to_string().to_upper() + ' ' +
-  'WITH_TAGLIB=' + taglib_dep.found().to_string().to_upper() + ' ' +
-  'WITH_AVCODEC=' + avcodec_dep.found().to_string().to_upper() + ' ' +
-  'WITH_FFMPEGTHUMBNAILER=' + ffmpegthumbnailer_dep.found().to_string().to_upper() + ' ' +
-  'WITH_EXIF=' + exif_dep.found().to_string().to_upper() +  ' ' +
-  'WITH_EXIV2=' + exiv2_dep.found().to_string().to_upper() + ' ' +
-  'WITH_SYSTEMD=' + get_option('systemd').to_string().to_upper() + ' ' +
-  'WITH_LASTFM=' + lastfm_dep.found().to_string().to_upper() + ' ' +
-  'WITH_DEBUG=' + get_option('debug').to_string().to_upper() + ' ' +
-  'WITH_TESTS=' + get_option('tests').to_string().to_upper() + '"'
-]
-
-add_project_arguments('-DCOMPILE_INFO='.join(compile_info), language : 'cpp')
+compile_info = '-DCOMPILE_INFO="'
+foreach info: [
+  ['WITH_MAGIC', magic_dep.found()],
+  ['WITH_MYSQL', mysql_dep.found()],
+  ['WITH_CURL', curl_dep.found()],
+  ['WITH_INOTIFY', get_option('inotify')],
+  ['WITH_JS', duktape_dep.found()],
+  ['WITH_TAGLIB', taglib_dep.found()],
+  ['WITH_AVCODEC', avcodec_dep.found()],
+  ['WITH_FFMPEGTHUMBNAILER', ffmpegthumbnailer_dep.found()],
+  ['WITH_EXIF', exif_dep.found()],
+  ['WITH_EXIV2', exiv2_dep.found()],
+  ['WITH_SYSTEMD', get_option('systemd')],
+  ['WITH_LASTFM', lastfm_dep.found()],
+  ['WITH_DEBUG', get_option('debug')],
+  ['WITH_TESTS', get_option('tests')],
+  ]
+
+  found = info[1].to_string().to_upper()
+  compile_info += 'WITH_@0@=@1@ '.format(info[0], found)
+endforeach
+
+compile_info += '"'
+
+add_project_arguments(compile_info, language : 'cpp')

 # mangix hacks
 add_project_arguments('-DGIT_COMMIT_HASH=""', language : 'cpp')

works. Except the last entry ends in a space.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile_info should be declared as a [] and += adds new array elements.

Or, you could do:

add_project_arguments('-DCOMPILE_INFO=' + ' '.join(compile_info), language : 'cpp')

@neheb neheb force-pushed the meson branch 2 times, most recently from 262571e to e1ed30e Compare October 6, 2021 04:29
@neheb neheb force-pushed the meson branch 2 times, most recently from bccf895 to c978b99 Compare November 19, 2021 04:10
@neheb neheb force-pushed the meson branch 2 times, most recently from 07bc610 to 00c7fd5 Compare May 25, 2022 00:31
@neheb neheb force-pushed the meson branch 11 times, most recently from 332d0c4 to 2e8f4d5 Compare June 16, 2022 20:23
@neheb neheb force-pushed the meson branch 2 times, most recently from 8e02c8d to 3d9521f Compare June 25, 2022 05:55
@neheb neheb force-pushed the meson branch 7 times, most recently from 16d72c6 to fcb8073 Compare January 26, 2024 01:37
Modern build system. Has the concept of wraps, which simplify
dependencies when they are missing from the OS.

Also has a clang-format ninja target, which can remove the separate CI
for it.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
@neheb neheb force-pushed the meson branch 2 times, most recently from ef7f2b8 to fbba2fb Compare January 26, 2024 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants