-
Notifications
You must be signed in to change notification settings - Fork 213
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
base: master
Are you sure you want to change the base?
add meson #1868
Conversation
I would rather have fixes for the CMake. |
a000d3c
to
5970ffd
Compare
Added fixes from Debian 10. Turns out, even clang 7 can compile Gerbera. |
Please, add a section to |
Added doc section. Also updated to install files in /usr/share as well. What's left with the meson build is: testing support 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...) |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I think I addressed most stuff. Some stuff I kept as booleans. Specifically the stuff that needs two or more dependencies. |
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 ? |
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. |
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. |
Indeed they do, with 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 |
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 :). |
Hmm doesn't seem to work with meson 0.49.1 (version that comes with Debian 10) |
For versions of meson earlier than 0.55, automatic wrap fallback via the If you need to support versions older than that, the dependency() function takes a kwarg |
24648dd
to
55facea
Compare
Added compile_info. Not totally happy with how it turned out... |
ef2de62
to
58d4a67
Compare
meson.build
Outdated
uuid_dep, | ||
] | ||
|
||
compile_info = [ '-DCOMPILE_INFO="' + |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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\"'
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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')
262571e
to
e1ed30e
Compare
bccf895
to
c978b99
Compare
07bc610
to
00c7fd5
Compare
332d0c4
to
2e8f4d5
Compare
8e02c8d
to
3d9521f
Compare
16d72c6
to
fcb8073
Compare
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>
ef7f2b8
to
fbba2fb
Compare
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.