Closed zhouqingyi123 closed 2 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: xmake.lua script, the specific writing configuration does not take effect.
path.join(os.scriptdir(), "xxx")
,或者 os.projectdir()
, core.project.config
/config.buildir() 拼下@waruqi 感谢回复,第1个问题明白了,这种时候就只能用os.host()来获取当前主机的平台。但是第二个问题还是存在,麻烦看看我改的是否正确呢?通过打印这个绝对路径,我确认路径是没错的。
不要用 $(buildir)
@waruqi 好的,改成用模块提供的函数来获取build路径进行设置确实没有问题了。这里再请教一下,这是什么原因呢?脚本域里使用$(buildir)得到的字符串通过print打印出来看也是正确的,感觉也能解析到这个内置变量,但就如上一个回复的图中那样,用它拼接而成的绝对路径就有问题。
Bot detected the issue body's language is not English, translate it automatically.
@waruqi Thanks for the reply. I understand the first question. In this case, you can only use os.host() to get the platform of the current host. But the second problem still exists. Could you please check if I changed it correctly? By printing this absolute path, I confirmed that the path is correct.
Bot detected the issue body's language is not English, translate it automatically.
Don’t use
$(buildir)
内置变量主要是给描述域的,脚本域上百个模块,上千上万个 api ,不可能每个接口,都给支持处理一遍
Bot detected the issue body's language is not English, translate it automatically.
@waruqi Okay, changing to using the function provided by the module to obtain the build path for setting is indeed problematic. Let me ask you again, what is the reason for this? The string obtained by using $(builder) in the script field is correct when printed through print. It seems that this built-in variable can also be parsed, but as in the picture in the previous reply, the absolute path spliced with it is question.
Bot detected the issue body's language is not English, translate it automatically.
Built-in variables are mainly used in the description domain. There are hundreds of modules and thousands of APIs in the script domain. It is impossible to support and process every interface.
@waruqi 好的,感谢解惑
Bot detected the issue body's language is not English, translate it automatically.
@waruqi Okay, thanks for clarifying
Xmake 版本
2.9.4
操作系统版本和架构
Windows 11 x64
描述问题
问题1:如下图所示,在is_plat("windows")的条件块中,通过set_config("vs", “2017”)设置vs的版本时不生效(我的电脑同时安装了2017和2022),还是使用的2022进行编译,但是写在条件块外面,是可以生效的(如上面注释部分)。
问题2:如下图所示,当我通过在on_load脚本域中写target:add("includedirs", xxx, {interface = true})来设置头文件目录时,依赖它的子target无法搜索到这个头文件目录,看上去add并没生效。但是我在描述域写add_inculdedirs时是可以生效的。
下面的demo1中包含了这两个问题。
demo1.zip
期待的结果
希望上图的两个场景,每个场景对应的出问题的写法能正常生效,当然,如果是因为用法不对导致的,请教一下正确的用法。
工程配置
附加信息和错误日志
提交的demo1应该可以复现