Skip to content

Commit da4f9e1

Browse files
committed
Merge branch 'master' of github.com:EmmyLua/EmmyLuaDebugger
2 parents 62eeed1 + 62b5f36 commit da4f9e1

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7777
steps:
7878
- name: Download
79-
uses: actions/download-artifact@v3
79+
uses: actions/download-artifact@v4.1.7
8080
- name: Display structure of downloaded files
8181
run: ls -R
8282
- name: zip win32-x64
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
[TOC]
2+
3+
# 如何利用超强[EmmyLuaDebugger](https://github.com/EmmyLua/EmmyLuaDebugger)实现全平台调试[Lua](https://www.lua.org/)代码?
4+
5+
这里给出UE4.26+lua大致的一种解决方案,具体有类似需要再实操一下。
6+
7+
## 流程
8+
9+
1.你需要能够完成emmy_core的创建注入_G环境中。
10+
11+
2.启动调试器服务器:`emmy_core.tcpListen('localhost', 9966)`
12+
13+
3.IDE连接调试器:配置Tcp(IDE connect debugger),点击开始调试。
14+
15+
## 细节
16+
17+
### Q:重点是怎么注入emmy_core?
18+
19+
A1:对于Windows平台下的工程,直接使用现有的插件内置的emmy_core.dll
20+
21+
然后执行这段代码完成注入:(具体代码看调试器生成代码)
22+
23+
```lua
24+
package.cpath = package.cpath .. ';C:/Users/XXX/AppData/Roaming/JetBrains/IntelliJIdea2023.2/plugins/EmmyLua/debugger/emmy/windows/x64/?.dll'
25+
local dbg = require('emmy_core')
26+
dbg.tcpListen('localhost', 9966)
27+
```
28+
29+
A2:对于Windows平台打包的程序该如何注入emmy_core.dll呢?
30+
31+
这里以UnrealEngine为例,只需要把emmyluadebugger编译到插件,然后直接做一层绑定给lua调用即可。
32+
33+
A3:那么Windows平台都能编译emmy_core了,其他平台理论上也可以。(EmmyLuaDebugger依赖了一个重型C库:[libuv](https://github.com/libuv/libuv)。需要针对不同平台编译好这个库。)
34+
35+
注意事项:
36+
37+
0.这里需要结合自己工程内用到的lua源码参与编译,自己配置依赖,笔者用的[slua_unreal](https://github.com/Tencent/sluaunreal)+lua修改版,配置了slua_unreal依赖
38+
39+
1.需要改一下源代码每个文件加上编译宏ENABLE_EMMY_LUA_DEBUGGER,避免Shipping下参与编译
40+
41+
2.需要改一下源代码每个文件加上命名空间,例如我加了namespace Emmy
42+
43+
UnrealEngine Build脚本大概是这样:(自己配置一下路径就好了)
44+
45+
```c#
46+
if (Target.Configuration != UnrealTargetConfiguration.Shipping &&
47+
(Target.Platform == UnrealTargetPlatform.Win64 ||
48+
Target.Platform == UnrealTargetPlatform.Android ||
49+
Target.Platform == UnrealTargetPlatform.IOS ||
50+
Target.Platform == UnrealTargetPlatform.Mac))
51+
{
52+
PrivateIncludePaths.AddRange(
53+
new string[]
54+
{
55+
Path.Combine(ModuleDirectory, "emmylua"),
56+
Path.Combine(ModuleDirectory, "emmylua/emmy_core"),
57+
Path.Combine(ModuleDirectory, "emmylua/emmy_core/src"),
58+
Path.Combine(ModuleDirectory, "emmylua/emmy_debugger"),
59+
Path.Combine(ModuleDirectory, "emmylua/emmy_debugger/include"),
60+
Path.Combine(ModuleDirectory, "emmylua/emmy_debugger/src"),
61+
Path.Combine(ModuleDirectory, "emmylua/third_party"),
62+
Path.Combine(ModuleDirectory, "emmylua/third_party/nlohmann"),
63+
Path.Combine(ModuleDirectory, "emmylua/third_party/nlohmann/include"),
64+
Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460"),
65+
Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460/include"),
66+
});
67+
bUseUnity = false;
68+
PublicDefinitions.Add("ENABLE_EMMY_LUA_DEBUGGER");
69+
PublicDefinitions.Add("EMMY_LUA_54");
70+
PublicDefinitions.Add("EMMY_USE_LUA_SOURCE");
71+
72+
if (Target.Platform == UnrealTargetPlatform.Win64)
73+
{
74+
PublicAdditionalLibraries.Add("Userenv.lib");
75+
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460/lib/x64/libuv.lib"));
76+
PublicDefinitions.Add("EMMY_CORE_VERSION=\"Win64 DEV\"");
77+
}
78+
else if(Target.Platform == UnrealTargetPlatform.IOS)
79+
{
80+
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460/lib/ios/libuv.a"));
81+
PublicDefinitions.Add("EMMY_CORE_VERSION=\"IOS DEV\"");
82+
}else if (Target.Platform == UnrealTargetPlatform.Android)
83+
{
84+
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460/lib/android/arm64/libuv.a"));
85+
PublicDefinitions.Add("EMMY_CORE_VERSION=\"Android DEV\"");
86+
}else if (Target.Platform == UnrealTargetPlatform.Mac)
87+
{
88+
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "emmylua/third_party/libuv1460/lib/mac/libuv.a"));
89+
PublicDefinitions.Add("EMMY_CORE_VERSION=\"Mac DEV\"");
90+
}
91+
}
92+
```
93+
94+
### Q:怎么多平台编译好这个libuv库呢?
95+
96+
A1:android libuv编译参考:[交叉编译 Android 的 libuv](https://fh0.github.io/%E7%BC%96%E8%AF%91/2019/12/16/android-libuv.html)
97+
98+
> 需要自己调整libuv版本到1.46,以及ndk级别到r21b(这个看具体项目,UE4.26用r21b)
99+
100+
A2:mac编译参考libuv官方编译脚本直接编译就好了:[libuv](https://github.com/libuv/libuv)
101+
102+
A3:ios平台的参考这个:[makios](https://gist.github.com/litesync/d7c484ccfd9552d88249ade4ebc69bba)
103+
104+
Q:IDEA怎么连接到Android平台下我程序内的debugger呢?
105+
106+
A:1.插入数据线;2.启动程序;3.程序完成debugger启动;4.adb端口映射:`adb forward tcp:9966 tcp:9966`;5.IDE点击调试。
107+
108+
Q:IDEA怎么连接ios平台下我程序内的debugger呢?
109+
110+
todo: ...

0 commit comments

Comments
 (0)