Conversation
waruqi
commented
Apr 1, 2026
- Before adding new features and new modules, please go to issues to submit the relevant feature description first.
- Write good commit messages and use the same coding conventions as the rest of the project.
- Please commit code to dev branch and we will merge into master branch in feature
- Ensure your edited codes with four spaces instead of TAB.
- 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
- 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
- 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
- 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。
There was a problem hiding this comment.
Code Review
This pull request refactors the package installation logic to support local project package directories more consistently. It updates package.installdir to handle a localdir option and ensures that local packages pass their installation path to child processes via the XMAKE_PKG_INSTALLDIR environment variable. Review feedback highlighted a critical shadowing issue in xmake/modules/package/tools/xmake.lua where the imported package module conflicts with a function parameter, potentially causing runtime failures. Additionally, a placeholder issue reference in the comments needs to be corrected.
| import("core.base.global") | ||
| import("core.tool.toolchain") | ||
| import("core.project.project") | ||
| import("core.package.package") |
There was a problem hiding this comment.
| -- @see https://github.com/xmake-io/xmake/discussions/7441 | ||
| if package:is_local() then | ||
| envs = table.clone(envs) | ||
| envs.XMAKE_PKG_INSTALLDIR = package.installdir({localdir = true}) |
There was a problem hiding this comment.
Because the package parameter shadows the package module, this line is currently calling the installdir method on the package instance instead of the module function. Furthermore, it uses . instead of :, which would cause a crash as self would be the options table. Use the aliased module name to call the correct function.
envs.XMAKE_PKG_INSTALLDIR = core_package.installdir({localdir = true})
| -- if the package is installed locally, pass the local packages directory | ||
| -- to the child xmake process so it can find already-installed deps | ||
| -- without re-installing them to the global directory | ||
| -- @see https://github.com/xmake-io/xmake/discussions/7441 |