-
Notifications
You must be signed in to change notification settings - Fork 128
build: Add zsh completion generation and installation to CMake #199
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
base: 29.x-knots
Are you sure you want to change the base?
build: Add zsh completion generation and installation to CMake #199
Conversation
- Add tool_cli_completion.py test script supporting both bash and zsh completions - Add --bash-completion and --zsh-completion parameters for bitcoin-cli - Include zsh-specific completion header and footer templates - Make completion file comparison optional in tests - Refactor completion test for better efficiency and maintainability
This commit integrates zsh completion script generation and installation into the CMake build system: - Add INSTALL_ZSH_COMPLETION option to CMakeLists.txt (defaults to ON) - Extend InstallBinaryComponent.cmake to support HAS_ZSH_COMPLETION parameter - Add custom CMake target to generate bitcoin-cli.zsh using tool_cli_completion.py - Install zsh completion to ${CMAKE_INSTALL_DATADIR}/zsh/site-functions/_bitcoin-cli - Ensure zsh directory is created before generation - Use correct config.ini path from build directory - Set proper working directory and paths for the generation script The zsh completion file is automatically generated during build when INSTALL_ZSH_COMPLETION=ON and installed to the appropriate system or user directory based on CMAKE_INSTALL_PREFIX. Note: This requires the tool_cli_completion.py script from the add-zsh-completion-generation branch to function properly.
@luke-jr @Retropex
|
I think so. Maybe not if the target is Windows?
Probably should treat the prefix as if it is a system-wide installation.
Maybe in a subsequent PR? But need to be careful not to break if zsh isn't installed.
Cross-compile support :| |
Replace the simple option for INSTALL_ZSH_COMPLETION with cmake_dependent_option that automatically disables zsh completion when targeting Windows (WIN32=true). This prevents build errors on Windows where zsh is not available, while maintaining the feature for Unix-like systems. The change is safe for cross-compilation as the WIN32 variable correctly reflects the target platform, not the host platform.
AFAIK zsh can be used on Windows, and building the completion file doesn't require zsh itself - so I would only change the default for Windows, not make the option entirely unavailable. (It might even make sense to include it with the Windows ZIP/installer) |
Change the zsh completion installation option to use conditional defaults rather than completely disabling it on Windows. This allows Windows users to explicitly enable zsh completion if needed (e.g., for WSL environments) while defaulting to OFF for Windows and ON for Unix-like systems. This provides better flexibility for users with non-standard setups while maintaining sensible platform-specific defaults.
This PR integrates zsh completion script generation and installation into the CMake build system, providing automated shell completion for bitcoin-cli commands on both macOS and Linux.
Changes
- Added INSTALL_ZSH_COMPLETION CMake option (defaults to ON when BUILD_CLI is enabled)
- Automatically generates contrib/completions/zsh/bitcoin-cli.zsh during build
- Installs completion file to system zsh completions directory (compatible with both macOS and Linux paths)
- Fixed build issues in CI environments by properly configuring paths and dependencies
Features
Testing
The completion generation is tested as part of the functional test suite via tool_cli_completion.py, which validates the zsh completion script.
Testing Zsh Completion Installation
Prerequisites
Building with Zsh Completion
1. Configure with Zsh Completion Enabled (Default)