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

cppzmq: new wrap #545

Merged
merged 1 commit into from
Aug 24, 2022
Merged

cppzmq: new wrap #545

merged 1 commit into from
Aug 24, 2022

Conversation

stephanlachnit
Copy link
Contributor

This currently still requires libzmq, which I will add as wrap hopefully soon.

@stephanlachnit stephanlachnit force-pushed the p-add-cppzmq branch 2 times, most recently from cc021f9 to 4ce9029 Compare July 29, 2022 19:26
@stephanlachnit
Copy link
Contributor Author

@eli-schwartz @jpakkane can we merge this already? I've made some progress on libzmq (https://github.com/stephanlachnit/libzmq/tree/p-meson), but it selecting the correct option will take some more time. Doesn't block cppzmq though as it works fine with system libzmq.

@eli-schwartz
Copy link
Member

eli-schwartz commented Aug 10, 2022

Sorry, I forgot to look at it because I assumed that you were going to be updating the PR to also wrap zeromq.

I think you should install zeromq for macOS via brew_packages. Additionally, how about building and running the tests/ directory? Maybe examples as well?

@stephanlachnit
Copy link
Contributor Author

I think you should install zeromq for macOS via brew_packages.

Good point

Additionally, how about building and running the tests/ directory?

Build the tests, could also add the examples. Looks like the CI doesn't take catch2 from wrapdb, how do I do this?

Is there some kind of preferred way to enable testing in meson? I think when using cppzmq in a subproject, the tests and examples should not be build by default.

@eli-schwartz
Copy link
Member

Just add a meson_options.txt with a tests feature option, and use that as the required kwarg for catch2. If it is required, then it will be picked up via wraps, wrap fallbacks don't automatically get used for optional dependencies.

(There's a kwarg to allow fallback anyway.)

@stephanlachnit
Copy link
Contributor Author

Ah right, I see. But then the feature would have to be enabled by default for this to work, right?

A bit offtopic, but maybe meson should add a builtin tests bool? That could be disabled for subprojects by default, but e.g. here in the CI enabled via cli.

@neheb
Copy link
Collaborator

neheb commented Aug 11, 2022

That wouldn't make much sense. Note that you still have to run ninja tests or meson tests to get them to run. A simple compile does that but does not run or install them.

@stephanlachnit
Copy link
Contributor Author

That wouldn't make much sense.

I disagree, tests should only be compiled if wished by the user (developer vs user). Sure, enabling them by default is a good default, but having a default way to not compile tests is something useful. It might not make a difference here, but if you have a giant testsuite containing maybe hundreds of files, it can take quite a while to compile.
Lots of CMake projects have it, and even some meson projects (e.g. https://github.com/libratbag/piper/blob/7f9834cc5901f790a596bae61e3eb81e63d7c2bd/meson_options.txt#L1-L4).

Note that you still have to run ninja tests or meson tests to get them to run. A simple compile does that but does not run or install them.

Sure, but I have my own tests defined, I don't care about tests from the subproject - possible test failures have nothing to do with my project.

@eli-schwartz
Copy link
Member

I disagree, tests should only be compiled if wished by the user (developer vs user). Sure, enabling them by default is a good default, but having a default way to not compile tests is something useful.

Actually, this shouldn't be an option, and enabling to compile them by default is a pointless waste.

It's just a bug in Meson that currently, build_by_default: false is ignored for testsuite executables.

What should happen is you mark every test executable to not build by default, but it's fine to unconditionally define their rules. Running ninja test should build the testsuite executables, but ninja all shouldn't build them.

This works fine in most cases, though if the tests require additional dependencies then it's probably desirable to have an option for that.

@stephanlachnit
Copy link
Contributor Author

stephanlachnit commented Aug 12, 2022

What should happen is you mark every test executable to not build by default, but it's fine to unconditionally define their rules. Running ninja test should build the testsuite executables, but ninja all shouldn't build them.

Ah thanks! This seems like a good idea - but there is still the subproject problem. But this should be fixable with an option for meson test, i.e. meson test --with-subprojects (where the default is to not run tests of subprojects on meson test).

@eli-schwartz
Copy link
Member

meson test --suite mainprojectname

@stephanlachnit
Copy link
Contributor Author

meson test --suite mainprojectname

Thanks!

@stephanlachnit stephanlachnit force-pushed the p-add-cppzmq branch 3 times, most recently from dc152c6 to 6e933f4 Compare August 12, 2022 12:03
@stephanlachnit
Copy link
Contributor Author

Added tests and examples with build_by_default: false, so from my side good to merge now.

Just add a meson_options.txt with a tests feature option, and use that as the required kwarg for catch2. If it is required, then it will be picked up via wraps, wrap fallbacks don't automatically get used for optional dependencies.

Did that, it still is not picked up by the CI when left on auto.

Copy link
Member

@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.

The ci_config.json can pass -Dcppzmq:catch2=required as build_options for this wrap. This will guarantee fallback happens.

It's also possible to use dependency(..., allow_fallback: true) but that bumps the minimum version of Meson from 0.47.0 to 0.56.0

subprojects/packagefiles/cppzmq/meson.build Outdated Show resolved Hide resolved
subprojects/packagefiles/cppzmq/meson.build Show resolved Hide resolved
subprojects/packagefiles/cppzmq/meson.build Show resolved Hide resolved
@stephanlachnit stephanlachnit force-pushed the p-add-cppzmq branch 3 times, most recently from 537a78e to ce5347e Compare August 15, 2022 11:33
Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>
@stephanlachnit
Copy link
Contributor Author

The ci_config.json can pass -Dcppzmq:catch2=required as build_options for this wrap. This will guarantee fallback happens.

cppzmq:catch2=enabled but thanks, done.

@stephanlachnit
Copy link
Contributor Author

@eli-schwartz any more objections or can this be merged?

@jpakkane jpakkane merged commit 1378afe into mesonbuild:master Aug 24, 2022
@stephanlachnit stephanlachnit deleted the p-add-cppzmq branch August 25, 2022 12:01
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.

None yet

4 participants