Skip to content

Commit c802868

Browse files
committed
Add support for disassembly and support debug debugger
- Add support for disassembly - Support debug debugger - Support auto download luamake - Update luajit build script
1 parent 2bae990 commit c802868

35 files changed

+880
-67
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ NamespaceIndentation: All
1515
PackConstructorInitializers: Never
1616
QualifierAlignment: Left
1717
SpaceBeforeCpp11BracedList: true
18+
SortIncludes: false

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
/build/
66
/extension/package.json
77
.DS_Store
8-
.idea/
8+
.idea/
9+
luamake/

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
url = https://github.com/actboy168/bee.lua.git
44
[submodule "3rd/lua/luajit"]
55
path = 3rd/lua/luajit
6-
url = https://github.com/fesily/luajit2
6+
url = https://github.com/fesily/luajit
77
[submodule "3rd/json.lua"]
88
path = 3rd/json.lua
99
url = https://github.com/actboy168/json.lua

.luarc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@
3737
"trailing-space": "Warning"
3838
}
3939
},
40-
"workspace.checkThirdParty": false
40+
"workspace.checkThirdParty": false,
41+
"type.inferParamType": true,
42+
"workspace.library": [
43+
"${addons}/bee/module/library"
44+
]
4145
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
{
22
"C_Cpp.autoAddFileAssociations": false,
3+
"terminal.integrated.env.linux": {
4+
"PATH": "${workspaceFolder}/luamake:${env:PATH}",
5+
},
6+
"terminal.integrated.env.windows": {
7+
"PATH": "${workspaceFolder}/luamake:${env:PATH}",
8+
},
9+
"terminal.integrated.env.osx": {
10+
"PATH": "${workspaceFolder}/luamake:${env:PATH}",
11+
}
312
}

3rd/lua/luajit

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
.PHONY: all download_deps build_luamake init_luamake
3+
4+
all: download_deps build_luamake
5+
luamake/luamake build --release
6+
7+
build_luamake: init_luamake
8+
@echo "Building luamake..."
9+
git submodule update --init --recursive
10+
cd luamake && compile/build.sh
11+
12+
download_deps: build_luamake
13+
luamake/luamake lua compile/download_deps.lua
14+
15+
init_luamake:
16+
@if [ -d "luamake" ]; then \
17+
if [ -d "luamake/.git" ]; then \
18+
echo "Updating luamake repository..."; \
19+
(cd luamake && git pull && git submodule update --remote); \
20+
else \
21+
echo "Error: 'luamake' exists but is not a Git repository."; \
22+
fi; \
23+
else \
24+
echo "Cloning luamake repository..."; \
25+
git clone --recurse-submodules https://github.com/actboy168/luamake.git; \
26+
fi

compile/luajit/defined.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local lm = require "luamake"
2+
local fs = require 'bee.filesystem'
23

34
local arch = lm.runtime_platform:sub(lm.runtime_platform:find("-") + 1)
45
if arch == "ia32" then
@@ -9,12 +10,35 @@ local luaver = "luajit"
910
local LUAJIT_ENABLE_LUA52COMPAT = "LUAJIT_ENABLE_LUA52COMPAT"
1011
local LUAJIT_NUMMODE = "LUAJIT_NUMMODE=2"
1112
local luajitDir = '3rd/lua/' .. luaver .. "/src"
13+
local is_old_version_luajit = fs.exists(fs.path(luajitDir) / 'lj_init.c')
1214

1315
local _M = {
1416
arch = arch,
1517
LUAJIT_ENABLE_LUA52COMPAT = LUAJIT_ENABLE_LUA52COMPAT,
1618
LUAJIT_NUMMODE = LUAJIT_NUMMODE,
17-
luajitDir = luajitDir
19+
luajitDir = luajitDir,
20+
is_old_version_luajit = is_old_version_luajit
1821
}
1922

23+
if not is_old_version_luajit then
24+
local sp = require 'bee.subprocess'
25+
local fs = require 'bee.filesystem'
26+
local sys = require 'bee.sys'
27+
sp.spawn({
28+
sys.exe_path(),
29+
"lua",
30+
'compile/luajit/relver.lua',
31+
luajitDir.."/..",
32+
luajitDir.."/luajit_relver.txt"
33+
}):wait()
34+
sp.spawn({
35+
sys.exe_path(),
36+
"lua",
37+
luajitDir.."/host/genversion.lua",
38+
luajitDir.."/luajit_rolling.h",
39+
luajitDir.."/luajit_relver.txt",
40+
luajitDir.."/luajit.h"
41+
}):wait()
42+
end
43+
2044
return _M

compile/luajit/make.lua

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local lm = require "luamake"
2+
local fs = require 'bee.filesystem'
23

34
local bindir = "publish/runtime/" .. lm.runtime_platform
45

@@ -9,6 +10,7 @@ local arch = defined.arch
910
local LUAJIT_ENABLE_LUA52COMPAT = defined.LUAJIT_ENABLE_LUA52COMPAT
1011
local LUAJIT_NUMMODE = defined.LUAJIT_NUMMODE
1112
local luajitDir = defined.luajitDir
13+
local is_old_version_luajit = defined.is_old_version_luajit
1214

1315
local LJLIB_C = {
1416
luajitDir .. "/lib_base.c ",
@@ -98,35 +100,39 @@ lm:build "lj_vm.obj" {
98100
outputs = lm.bindir .. "/lj_vm.obj",
99101
}
100102

101-
local lj_str_hash_flags = {
102-
"-fno-stack-protector",
103-
U_FORTIFY_SOURCE,
104-
"-fPIC",
105-
}
103+
local has_str_hash = fs.exists(luajitDir.. '/lj_str_hash.c')
104+
if has_str_hash then
105+
local lj_str_hash_flags = {
106+
"-fno-stack-protector",
107+
U_FORTIFY_SOURCE,
108+
"-fPIC",
109+
}
106110

107-
if arch == "x64" then
108-
table.insert(lj_str_hash_flags, "-msse4.2")
109-
end
111+
if arch == "x64" then
112+
table.insert(lj_str_hash_flags, "-msse4.2")
113+
end
110114

111-
lm:source_set("lj_str_hash.c") {
112-
rootdir = luajitDir,
113-
sources = { "lj_str_hash.c" },
114-
includes = { '.' },
115-
defines = {
116-
LUAJIT_UNWIND_EXTERNAL,
117-
_FILE_OFFSET_BITS,
118-
_LARGEFILE_SOURCE,
119-
LUA_MULTILIB,
120-
LUAJIT_ENABLE_LUA52COMPAT,
121-
LUAJIT_NUMMODE,
122-
},
123-
linux = {
115+
lm:source_set("lj_str_hash.c") {
116+
rootdir = luajitDir,
117+
sources = { "lj_str_hash.c" },
118+
includes = { '.' },
124119
defines = {
125-
"_GNU_SOURCE",
126-
}
127-
},
128-
flags = lj_str_hash_flags
129-
}
120+
LUAJIT_UNWIND_EXTERNAL,
121+
_FILE_OFFSET_BITS,
122+
_LARGEFILE_SOURCE,
123+
LUA_MULTILIB,
124+
LUAJIT_ENABLE_LUA52COMPAT,
125+
LUAJIT_NUMMODE,
126+
},
127+
linux = {
128+
defines = {
129+
"_GNU_SOURCE",
130+
}
131+
},
132+
flags = lj_str_hash_flags
133+
}
134+
end
135+
130136

131137
lm:executable("luajit/lua") {
132138
rootdir = luajitDir,
@@ -139,12 +145,14 @@ lm:executable("luajit/lua") {
139145
"lj_libdef.h",
140146
"lj_recdef.h",
141147
},
142-
deps = "lj_str_hash.c",
148+
deps = {
149+
has_str_hash and "lj_str_hash.c",
150+
},
143151
sources = {
144152
"luajit.c",
145153
"lj_*.c",
146154
"lib_*.c",
147-
"!lj_str_hash.c",
155+
has_str_hash and "!lj_str_hash.c",
148156
lm.bindir .. "/lj_vm.obj",
149157
},
150158
includes = {

compile/luajit/make_buildtools.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ lm:executable("buildvm") {
6767
".",
6868
"../../../../" .. lm.bindir
6969
}
70-
}
70+
}

0 commit comments

Comments
 (0)