i18nsite opened a new pull request, #3254:
URL: https://github.com/apache/kvrocks/pull/3254

   ## Description / 描述
   
   This PR adds support for building Kvrocks with pre-built dependencies, which 
is particularly useful for build systems like Nix where:
   - Dependencies are pre-compiled in isolated environments
   - Source directories are read-only (stored in `/nix/store`)
   - Build reproducibility is critical
   
   本 PR 添加了使用预编译依赖构建 Kvrocks 的支持,这对于像 Nix 这样的构建系统特别有用:
   - 依赖在隔离环境中预编译
   - 源码目录是只读的(存储在 `/nix/store` 中)
   - 构建可重现性至关重要
   
   ## Changes / 改动
   
   Modified 5 CMake files to make custom build targets optional:
   - `cmake/jemalloc.cmake`
   - `cmake/lua.cmake`
   - `cmake/luajit.cmake`
   - `cmake/lz4.cmake`
   - `cmake/zstd.cmake`
   
   修改了 5 个 CMake 文件,使自定义构建目标变为可选:
   - `cmake/jemalloc.cmake`
   - `cmake/lua.cmake`
   - `cmake/luajit.cmake`
   - `cmake/lz4.cmake`
   - `cmake/zstd.cmake`
   
   **Before / 之前:**
   ```cmake
   add_custom_target(make_xxx COMMAND ${MAKE_COMMAND} ...
     WORKING_DIRECTORY ...
     BYPRODUCTS ...
   )
   ```
   
   **After / 之后:**
   ```cmake
   # Using pre-built xxx from Nix
   add_custom_target(make_xxx)
   ```
   
   ## How It Works / 工作原理
   
   1. The custom targets are still created to maintain CMake dependency 
relationships
   2. But they don't execute any build commands (no COMMAND specified)
   3. Build systems can place pre-built libraries in expected locations before 
the build phase
   4. CMake will use these pre-existing libraries instead of building them
   
   1. 自定义目标仍然会被创建以维持 CMake 依赖关系
   2. 但它们不执行任何构建命令(未指定 COMMAND)
   3. 构建系统可以在构建阶段之前将预编译的库放置在预期位置
   4. CMake 将使用这些预先存在的库而不是构建它们
   
   ## Benefits / 优势
   
   - ✅ **Minimal change**: Only ~13 lines removed, ~5 lines added
   - ✅ **No impact on normal builds**: Regular builds continue to work as before
   - ✅ **Enables Nix support**: Makes it possible to package Kvrocks for NixOS
   - ✅ **Faster builds**: When dependencies are pre-built and cached
   - ✅ **Better reproducibility**: Pre-built dependencies ensure consistent 
builds
   
   - ✅ **最小化改动**:仅删除约 13 行,添加约 5 行
   - ✅ **不影响正常构建**:常规构建继续像以前一样工作
   - ✅ **启用 Nix 支持**:使得为 NixOS 打包 Kvrocks 成为可能
   - ✅ **更快的构建**:当依赖被预编译和缓存时
   - ✅ **更好的可重现性**:预编译的依赖确保一致的构建
   
   ## Testing / 测试
   
   Tested successfully with Nix build system on macOS (Apple Silicon):
   - All dependencies (jemalloc, lua, luajit, lz4, zstd) pre-built successfully
   - Kvrocks builds and runs correctly
   - Binary size: ~20MB
   - Version check: `kvrocks --version` returns `kvrocks version 2.13.0`
   
   在 macOS (Apple Silicon) 上使用 Nix 构建系统测试成功:
   - 所有依赖(jemalloc、lua、luajit、lz4、zstd)预编译成功
   - Kvrocks 构建并正确运行
   - 二进制大小:约 20MB
   - 版本检查:`kvrocks --version` 返回 `kvrocks version 2.13.0`
   
   ## Related Issues / 相关问题
   
   This change addresses the challenges of building Kvrocks in environments 
with:
   - Read-only source directories
   - Pre-built dependency requirements
   - Sandboxed build environments
   
   这个改动解决了在以下环境中构建 Kvrocks 的挑战:
   - 只读源码目录
   - 预编译依赖要求
   - 沙盒构建环境
   
   ## Checklist / 检查清单
   
   - [x] Code follows the project's coding style
   - [x] Changes are minimal and focused
   - [x] No breaking changes to existing builds
   - [x] Tested on macOS with Nix
   - [x] Commit message follows conventional commits format
   
   - [x] 代码遵循项目的编码风格
   - [x] 改动最小且集中
   - [x] 对现有构建无破坏性改动
   - [x] 在 macOS 上使用 Nix 测试
   - [x] 提交信息遵循约定式提交格式
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to