Skip to content

Host Get Extension and Meson#77

Merged
abique merged 4 commits intofree-audio:nextfrom
mfisher31:meson-and-host-ext
Mar 25, 2025
Merged

Host Get Extension and Meson#77
abique merged 4 commits intofree-audio:nextfrom
mfisher31:meson-and-host-ext

Conversation

@mfisher31
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread include/clap/helpers/host.hh Outdated
virtual void requestCallback() noexcept = 0;

virtual bool enableDraftExtensions() const noexcept { return false; }
virtual const void* getExtension (std::string_view extensionId) const noexcept { return nullptr; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
virtual const void* getExtension (std::string_view extensionId) const noexcept { return nullptr; }
virtual const void *extension(const char *id) const noexcept { return nullptr; }
  • rename for consistency with clap::helpers::Plugin::extension
  • just pass on the const char * -> let it up to the implementation to use std::string_view
  • format: void *extension( instead of void* extension ( seems more consistent with the rest to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rename for consistency with clap::helpers::Plugin::extension

Plugin uses clapExtension and extension, but Host uses clapGetExtension so the corresponding method would be getExtension. However, the parameter type and name should be changed to const char *extension_id to match Host::clapGetExtension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I change it back... probably should have looked here first. :)

Copy link
Copy Markdown
Contributor

@Trinitou Trinitou Feb 14, 2025

Choose a reason for hiding this comment

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

Yeah, I actually think messmerd is more right than me :D
So maybe it would be ok for you to change the name back to getExtension...?

Comment thread meson.build Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would be OK for me to add this. What do you think, @abique ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My comment in discord was: if we add it we should add a ci test since it needs to work and most of us don’t use it ever.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I turned on ci here and it failed alas

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just for cmakr not even for meson

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've never used meson.
I'm not going to maintain it myself.
So as long as it is maintained by someone I don't mind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and made another branch ...

https://github.com/mfisher31/clap-helpers/tree/host-ext-access

... that has cherry-pick'd the extension access changes only.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My two cents is that a meson.build addition was a workaround anyway. If there was a cmake option, or something, to stop the download of clap without erroring then the cmake could be used directly as a cmake-subproject. (assuming the dev also handles the clap dependency on their own).

but the cmake already does that. The download is wrapped in if (NOT TARGET clap)

if (NOT TARGET clap)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, my guess is that TARGET clap does not get registered when runs the checks and what not.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does that mean?

when ci runs target clap is false so it downloads

you can see in the pr I pushed that the next main thing also gets fixed - if I merge that and you rebase your code should work. Just waiting for @abique to review

my comment was addressing yours about meson needing an if (which my pr also addresses)

I guess “what is the problem which requires a meson build file here and nowhere else”

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry I only really use cmake in passing. I just meant from my own perspective: If I used meson to subproject(...) in clap, then TARGET clap still returns false (not regisered in cmake). I'll do the rebase, kill the meson.build???, and also change back to getExtension() as @messmerd suggested?. Sorry this one went kind of haywire :)

@baconpaul
Copy link
Copy Markdown
Collaborator

I've started addressing the identified cmake problems #78

  • adds a control for MAIN/NEXT and PR against main pull main etc
  • Adds an option to not FATAL_ERROR if you don't have a clap target and dont have downloads on. Editorially wishes you luck in a warning.

@mfisher31 mfisher31 changed the base branch from main to next March 7, 2025 14:26
@mfisher31 mfisher31 force-pushed the meson-and-host-ext branch from 386ee7c to 15a450c Compare March 7, 2025 14:31
Comment thread include/clap/helpers/host.hxx Outdated
}
return nullptr;

return self.getExtension(extension_id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would need to be called first and if that returns a valid ext pointer then return it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hm, in clap::helpers::Plugin::clapExtension self.extension isn't called first. Should that be changed as well then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh yeah, didn't think about that. Doing so enables client code to override the default impl. I'll get it done.

Copy link
Copy Markdown
Contributor Author

@mfisher31 mfisher31 Mar 25, 2025

Choose a reason for hiding this comment

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

Ok. I did a few things:

  • Squash all previous commits.
  • Rebase on next & force push
  • check overriden extension(...) and getExtension(...) before built-in implementations
  • remove the meson.build
  • remove #include <string_view> from host.hh

Turns out next works perfectly fine when using the cmake options: something like this:
https://github.com/kushview/element/blob/4d3d97114680a3312f1eddcf39b68e0ddcbdf845/meson/deps/meson.build#L5

# ...
cmake = import ('cmake')
clap_proj = cmake.subproject ('clap')
clap_helpers_opts = cmake.subproject_options()
clap_helpers_opts.add_cmake_defines ({
    'CLAP_HELPERS_DOWNLOAD_DEPENDENCIES': false,
    'CLAP_HELPERS_NO_CLAP_IS_FATAL': false })
clap_helpers_proj = cmake.subproject ('clap-helpers', options: clap_helpers_opts)
clap_dep = [ clap_proj.dependency('clap'), 
             clap_helpers_proj.dependency ('clap-helpers') ]
# ...

@mfisher31
Copy link
Copy Markdown
Contributor Author

Sorry for the delay on this. I just pushed the change to revert to getExtension(). I rebased on next, and am still in need of my meson.build. The situation for me is the same as before: if I use clap helpers from meson as a cmake subproject it either 1) blows up when downloading clap, or 2) can't find clap even though it too is part of the build as a cmake subproject.

All of the above is being worked out here:
https://github.com/kushview/element/blob/7eb89631aaa3ac43295239932ce7145e7c44923e/meson/deps/meson.build#L5

* Ignore generated files when used as a meson subproject
@mfisher31 mfisher31 force-pushed the meson-and-host-ext branch from a8b6a9d to f8c8a51 Compare March 25, 2025 02:00
@mfisher31 mfisher31 requested a review from Trinitou March 25, 2025 02:51
@mfisher31 mfisher31 marked this pull request as ready for review March 25, 2025 02:51
@abique abique self-assigned this Mar 25, 2025
@abique
Copy link
Copy Markdown
Contributor

abique commented Mar 25, 2025

Maybe split the assignment from the if and it'll compile :)
Appart from that, LGTM.

@mfisher31
Copy link
Copy Markdown
Contributor Author

mfisher31 commented Mar 25, 2025

Maybe split the assignment from the if and it'll compile :)

Whoops. probably should have checked one of the plugin (not host), projects I have on the side. 😎

@mfisher31 mfisher31 requested a review from abique March 25, 2025 10:38
@abique abique merged commit c75ab5f into free-audio:next Mar 25, 2025
14 checks passed
@abique
Copy link
Copy Markdown
Contributor

abique commented Mar 25, 2025

Thanks 👍

@mfisher31 mfisher31 deleted the meson-and-host-ext branch March 25, 2025 11:14
@@ -163,7 +165,7 @@ namespace clap { namespace helpers {
// put draft ext here
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Am I reading this wrong or is it a pretty big change?

if I request host.get extension I no longer get the extension which routes to my internal virtual method for one of the mapped extensions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It allows the host to shortcut the clap helper for a specific extension.
I think it makes sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I merged this too quickly, do you see a big issue with this change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could have two methods to make it clearer if that you're concern:

  • getExtension() which would be the fallback if the clap-helper didn't provide it
  • shortcutExtension() which would let the subclass provide the extension to use before the helper layer.

Would that make sense?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It allows the host to shortcut the clap helper for a specific extension. I think it makes sense.

but what if that extension is CLAP_EXT_GUI was my thinking. Then you get nullptr if you call get extension.

I definitely mix-and-match hostProxy.paramFoo and p = hostProxy.getExtension(PARAMS); p->foo(hostProxy->_host) in my code and expect both to kinda give the same function point.

The perhaps yeah 'underlyingExtension' or 'shortcutExtension' makes sense but I think this change will break some of my code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't touch the PluginProxy or HostProxy.
It is only for the Plugin and Host.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you saying that you are using plugin-proxy to talk to your own plugin instance within itself?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ahhh did i misread?

i definitely use raw extensions from the host and the host proxy interchangeably.

let me check if i do the same with plugins. i think that's less likely.

abique pushed a commit that referenced this pull request Nov 28, 2025
* * Add host getExtension() handler
* Ignore generated files when used as a meson subproject

* host/plugin: check overriden extension access before built-ins

* host.hh: remove string_view include; not used.

* plugin: call extension on the 'self' object
abique pushed a commit that referenced this pull request Nov 28, 2025
* * Add host getExtension() handler
* Ignore generated files when used as a meson subproject

* host/plugin: check overriden extension access before built-ins

* host.hh: remove string_view include; not used.

* plugin: call extension on the 'self' object
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.

5 participants