-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
xrepo install指定--includes时找不到文件 #6048
Comments
Title: xrepo install cannot find the file when specifying --includes |
includes(path.join(os.scriptdir(), "source.lua")) |
这不行,XMAKE_RCFILES里的脚本执行 warning: includes("C:\Users\2283\AppData\Local\Temp\.xmake\250109\xrepo\working\source.lua") cannot find any files! 事实上 |
那目前没办法, 如果要 includes 多个。直接 |
--includes传递相对路径会直接找不到脚本,因为XMAKE_RCFILES传进去后,会进入一共临时目录,然后工作目录就变了,这里是不是可以改成,自动在XMAKE_RCFILES中传递脚本的绝对路径 |
--includes will not find the script if you pass the relative path, because after XMAKE_RCFILES is passed in, it will enter a temporary directory, and then the working directory will change. Can it be changed here to automatically pass the absolute path of the script in XMAKE_RCFILES? |
改了 #6066 |
现在可以传相对路径了。不过如果传的脚本里需要用到modules,那import的时候也会报错,这怎么处理? |
目前没办法,xrepo install --includes 原本仅仅就是为了支持传递 简单的单一 xmake.lua 脚本配置,不是用来搞复杂脚本的。 你全部整一个 xmake.lua ,import 不要用自定义的脚本 |
1. 支持通过XMAKE_RCFILES环境变量传递,可以填入--includes选项中 2. 通过读取XMAKE_RCFILES环境变量来查找脚本目录,要求XMAKE_RCFILES环境变量中只有一个名为toolchain.lua的文件 3. 参见xmake-io/xmake#6048
Relative paths can now be passed. However, if modules need to be used in the passed script, an error will be reported when importing. How to deal with this? |
There is currently no way. xrepo install --includes was originally just to support the delivery of a simple single xmake.lua script configuration, not for complex scripts. All you need is xmake.lua. Do not use custom scripts for import. |
Xmake 版本
xmake v2.9.7+HEAD.2bb99e0c3
操作系统版本和架构
Windows 11 24H2
描述问题
首先,在
source.lua
中定义一些表供后续使用:然后在
toolchain.lua
中定义一些工具链:此时通过
xmake.lua
包含toolchain.lua
加载工具链定义:运行
xmake show -l toolchains
可以正常得到工具链:但如果运行命令
xrepo install --toolchain=myclang --includes="toolchain.lua" benchmark
,这时toolchain.lua
并没有被加载,因为xrepo
在一个临时目录下执行xmake
,而它会基于临时目录寻找toolchain.lua
。将toolchain.lua
改用绝对路径则会得到如下结果:因为通过
XMAKE_RCFILES
加载的脚本没有用includes
函数的逻辑,此时不是基于toolchain.lua
所在目录,而是基于临时目录查找source.lua
。如果将includes("source.lua")
也改为使用绝对路径则能正常工作,但这会导致脚本发布困难。期待的结果
XMAKE_RCFILES
中的脚本使用includes
逻辑,将工作目录切换到脚本所在目录后再执行脚本内容import
函数的rootdir
参数,传递{rootdir="."}
以强制基于当前文件所在路径搜索脚本工程配置
test.zip
附加信息和错误日志
在
toolchain.lua
的最后添加print("Hello")
语句后得到得到如下日志:includes("source.lua")
改为绝对路径后不会报工具链找不到的错误The text was updated successfully, but these errors were encountered: