-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
Simplifying adding runenvs in virtual environment #5580
Comments
试下这个 patch, #5582 脚本,table 描述域设置都可以 includes("@builtin/xrepo")
xrepo_addenvs(function (package)
package:addenv("FOO", "FOO")
end)
xrepo_addenvs({BAR = "BAR"}) |
另外加了一个可以快速设置单个 envs 的 xrepo_addenv("ZOO", "ZOO") |
In addition, one can quickly set up a single envs xrepo_addenv("ZOO", "ZOO") |
这块好像还没解决 |
This seems to have not been resolved yet |
再试试 |
try again |
这里实现还是有问题,当加的变量比较复杂(比如路径)
会报错
去重的时候简单拼接还是不行,会有非法字符,包括xrepo_addenvs使用的table也不行,含有":"字符。理想方式是使用hash,但description scope用不了hash.md5 |
There are still problems with the implementation here, when the variables added are more complex (such as paths)
Will report an error
When removing duplicates, simple splicing still doesn't work. There will be illegal characters, including the table used by xrepo_addenvs, which contains the ":" character. The ideal way is to use hash, but description scope cannot use hash.md5 |
Is your feature request related to a problem? Please describe.
目前在虚拟环境中加环境变量是比较麻烦的:必须先定义一个package,再在on_load里加环境变量,还要加上on_fetch让xmake不报错:
这种写法繁琐、非常容易出错。然而加环境变量的需求在多语言项目中普遍存在,例如C++/Python混合项目里,编译出的.pyd要在python里测试,就要把python module加入环境变量PYTHONPATH才行
Describe the solution you'd like
目前定义一个
add_runenvs()
函数就行:测试:
可以正确生成结果。要加入xmake内置函数的话,加一些处理应该就行:
这样多次调用add_runenvs也没有问题了。剩下两个问题:
TESTFILE = io.readfile("testfile")
,就只能手写繁琐的package定义了。Describe alternatives you've considered
仍保留package定义的部分给用户,但传入一个on_load函数:
这样可以解决上面的问题1,只是需要多写一点代码。并且这种形式不仅限于加环境变量,也可以用来做别的事情。(这里去重的话只能用load函数的地址了;我不太清楚怎么做)
Additional context
No response
The text was updated successfully, but these errors were encountered: