Skip to content

feat(#461): Optional CLI plugin loader via dlopen#502

Merged
justinjoy merged 4 commits intomainfrom
feat/461-cli-plugin-loader
Apr 14, 2026
Merged

feat(#461): Optional CLI plugin loader via dlopen#502
justinjoy merged 4 commits intomainfrom
feat/461-cli-plugin-loader

Conversation

@justinjoy
Copy link
Copy Markdown
Collaborator

Summary

  • Add io_plugin_dlopen meson option (default disabled) for optional CLI plugin loading
  • Define WL_IO_PLUGIN_EXPORT macro and wl_io_plugin_entry_fn typedef in io_adapter.h (Path B contract from feat: Option C user-defined I/O adapters (static + Android + optional CLI dlopen) #446)
  • Implement wirelog/cli/plugin_loader.c with dlopen + dlsym("wl_io_plugin_entry") + ABI version check + fail-fast bulk registration
  • Wire repeatable --load-adapter=PATH CLI argument in main.c, gated behind WL_HAVE_PLUGIN_LOADER
  • Conditional libdl linking, excluded from Windows builds
  • Mock adapter shared libraries + 5 test cases (valid load, unload cleanup, ABI mismatch, missing file, NULL path)

Test plan

  • Build with -Dio_plugin_dlopen=enabled: compiles and links
  • Plugin loader test: 5/5 PASS (load, unload, ABI mismatch, missing file, NULL)
  • CLI --load-adapter with valid plugin: loads successfully
  • CLI --load-adapter with missing file: clear error message
  • Full test suite: 135/135 PASS, no regressions
  • Uncrustify formatting applied via pre-commit hook

Closes #461

…types

Add io_plugin_dlopen combo option (default disabled) to meson_options.txt.
Define WL_IO_PLUGIN_EXPORT visibility macro and wl_io_plugin_entry_fn
typedef in io_adapter.h for the Path B plugin contract (#446 section 7).
Add plugin_loader.c/.h implementing dlopen + dlsym("wl_io_plugin_entry")
+ ABI version validation + bulk adapter registration with fail-fast
semantics. Tracks loaded plugins for clean dlclose at shutdown.
Single-threaded CLI-only module, not thread-safe by design.
Add repeatable --load-adapter=PATH argument to CLI main.c, gated behind
WL_HAVE_PLUGIN_LOADER define. Update meson.build to conditionally link
libdl and include plugin_loader.c when io_plugin_dlopen=enabled.
Excluded from Windows builds.
Add test_plugin_loader.c exercising: valid load + register + find,
unload cleanup, ABI mismatch rejection, missing file error, NULL path
error. Build mock_plugin_adapter.so (valid) and mock_plugin_adapter_bad_abi.so
(always returns NULL) as test-only shared libraries. Tests gated behind
io_plugin_dlopen=enabled.
@justinjoy justinjoy merged commit 3b83a05 into main Apr 14, 2026
7 checks passed
@justinjoy justinjoy deleted the feat/461-cli-plugin-loader branch April 14, 2026 09:38
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.

Optional CLI plugin loader (gated, Path B)

1 participant