如何在多个 project 中复用函数 #4779
Unanswered
Dont-laugh
asked this question in
Q&A
Replies: 2 comments
-
描述域和脚本域是隔离的,不要混用。。脚本域里面 走 import 导入模块使用,用户自定义模块也可以 import 复用,add_moduledirs 配置模块目录,具体看下文档 |
Beta Was this translation helpful? Give feedback.
0 replies
-
自动义脚本写好后用 import。
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我在一个 Solution 中有多个 Projects,每个 Project 都对应一个 xmake.lua 配置,目录大致如下:
在根目录下的 xmake.lua 中一个个 includes 其他 project 目录,由于每个 project 都有一些自己的资源,我需要在 on_build 的时候把资源拷贝到执行目录,它们完全用同一个函数来执行拷贝逻辑。
我尝试过在根目录的 xmake.lua 中定义这个拷贝函数,子 xmake 中会找不到这个函数。但神奇的是,我在根 xmake 中定义的变量却可以在子 xmake 中找到,在 on_build 中要用到这个变量也只需要在 target 范围外用一个 local 变量存一下就行,函数就算存下来任然是 nil。
所以,想要在多个 xmake.lua 中复用某个函数的话,我应该怎么做?
Beta Was this translation helpful? Give feedback.
All reactions