Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ NamespaceIndentation: All
PackConstructorInitializers: Never
QualifierAlignment: Left
SpaceBeforeCpp11BracedList: true
SortIncludes: false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/build/
/extension/package.json
.DS_Store
.idea/
.idea/
luamake/
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/actboy168/bee.lua.git
[submodule "3rd/lua/luajit"]
path = 3rd/lua/luajit
url = https://github.com/fesily/luajit2
url = https://github.com/fesily/luajit
[submodule "3rd/json.lua"]
path = 3rd/json.lua
url = https://github.com/actboy168/json.lua
Expand Down
6 changes: 5 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
"trailing-space": "Warning"
}
},
"workspace.checkThirdParty": false
"workspace.checkThirdParty": false,
"type.inferParamType": true,
"workspace.library": [
"${addons}/bee/module/library"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"C_Cpp.autoAddFileAssociations": false,
"terminal.integrated.env.linux": {
"PATH": "${workspaceFolder}/luamake:${env:PATH}"
},
"terminal.integrated.env.windows": {
"PATH": "${workspaceFolder}/luamake:${env:PATH}"
},
"terminal.integrated.env.osx": {
"PATH": "${workspaceFolder}/luamake:${env:PATH}"
}
}
2 changes: 1 addition & 1 deletion 3rd/frida_gum/gumpp
2 changes: 1 addition & 1 deletion 3rd/lua/luajit
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

.PHONY: all download_deps build_luamake init_luamake install

all: download_deps build_luamake
luamake/luamake build --release

build_luamake: init_luamake
@echo "Building luamake..."
git submodule update --init --recursive
cd luamake && compile/build.sh

download_deps: build_luamake
luamake/luamake lua compile/download_deps.lua

init_luamake:
@if [ -d "luamake" ]; then \
if [ -d "luamake/.git" ]; then \
echo "Updating luamake repository..."; \
(cd luamake && git pull && git submodule update --remote); \
else \
echo "Error: 'luamake' exists but is not a Git repository."; \
fi; \
else \
echo "Cloning luamake repository..."; \
git clone --recurse-submodules https://github.com/actboy168/luamake.git; \
fi

install: all
@echo "Installing Lua Debugger..."
luamake/luamake lua compile/install.lua
2 changes: 1 addition & 1 deletion compile/download_deps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local sp = require 'bee.subprocess'

local output_dir = "3rd/frida_gum/"

local version = "16.0.10"
local version = "17.2.6"
local file_fmt = "%s-%s." .. (platform.os == "windows" and "exe" or "tar.xz")
local url_fmt = ("https://github.com/frida/frida/releases/download/%s/frida-gum-devkit-%s")

Expand Down
35 changes: 35 additions & 0 deletions compile/install.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local fs = require 'bee.filesystem'
local home = assert(os.getenv("HOME") or os.getenv("HOMEPATH"), "HOME environment variable is not set")

local vscode_dir = {
".vscode",
".vscode-server",
}

local sourceDir = ...

for i, v in ipairs(vscode_dir) do
local vscode_dir = fs.path(home) / v / "extensions"
if not fs.exists(vscode_dir) or not fs.is_directory(vscode_dir) then
goto continue
end
local extensions_json = vscode_dir / "extensions.json"
if not fs.exists(extensions_json) or not fs.is_regular_file(extensions_json) then
goto continue
end
local fp = io.open(extensions_json:string(), "r")
local content = fp:read("*a")
fp:close()
if not content:find("lua-debug", 1, true) then
goto continue
end
for dir in fs.pairs(vscode_dir) do
if dir:string():find("lua-debug", 1, true) then
local fn = assert(loadfile('compile/copy.lua'))
fn(sourceDir or 'publish', dir:string())
os.exit(0)
end
end
::continue::
end
os.exit(1)
25 changes: 24 additions & 1 deletion compile/luajit/defined.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local lm = require "luamake"
local fs = require 'bee.filesystem'

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

local _M = {
arch = arch,
LUAJIT_ENABLE_LUA52COMPAT = LUAJIT_ENABLE_LUA52COMPAT,
LUAJIT_NUMMODE = LUAJIT_NUMMODE,
luajitDir = luajitDir
luajitDir = luajitDir,
is_old_version_luajit = is_old_version_luajit
}

if not is_old_version_luajit then
local sp = require 'bee.subprocess'
local sys = require 'bee.sys'
sp.spawn({
sys.exe_path(),
"lua",
'compile/luajit/relver.lua',
luajitDir.."/..",
luajitDir.."/luajit_relver.txt"
}):wait()
sp.spawn({
sys.exe_path(),
"lua",
luajitDir.."/host/genversion.lua",
luajitDir.."/luajit_rolling.h",
luajitDir.."/luajit_relver.txt",
luajitDir.."/luajit.h"
}):wait()
end

return _M
64 changes: 36 additions & 28 deletions compile/luajit/make.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local lm = require "luamake"
local fs = require 'bee.filesystem'

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

Expand All @@ -9,6 +10,7 @@ local arch = defined.arch
local LUAJIT_ENABLE_LUA52COMPAT = defined.LUAJIT_ENABLE_LUA52COMPAT
local LUAJIT_NUMMODE = defined.LUAJIT_NUMMODE
local luajitDir = defined.luajitDir
local is_old_version_luajit = defined.is_old_version_luajit

local LJLIB_C = {
luajitDir .. "/lib_base.c ",
Expand Down Expand Up @@ -98,35 +100,39 @@ lm:build "lj_vm.obj" {
outputs = lm.bindir .. "/lj_vm.obj",
}

local lj_str_hash_flags = {
"-fno-stack-protector",
U_FORTIFY_SOURCE,
"-fPIC",
}
local has_str_hash = fs.exists(luajitDir.. '/lj_str_hash.c')
if has_str_hash then
local lj_str_hash_flags = {
"-fno-stack-protector",
U_FORTIFY_SOURCE,
"-fPIC",
}

if arch == "x64" then
table.insert(lj_str_hash_flags, "-msse4.2")
end
if arch == "x64" then
table.insert(lj_str_hash_flags, "-msse4.2")
end

lm:source_set("lj_str_hash.c") {
rootdir = luajitDir,
sources = { "lj_str_hash.c" },
includes = { '.' },
defines = {
LUAJIT_UNWIND_EXTERNAL,
_FILE_OFFSET_BITS,
_LARGEFILE_SOURCE,
LUA_MULTILIB,
LUAJIT_ENABLE_LUA52COMPAT,
LUAJIT_NUMMODE,
},
linux = {
lm:source_set("lj_str_hash.c") {
rootdir = luajitDir,
sources = { "lj_str_hash.c" },
includes = { '.' },
defines = {
"_GNU_SOURCE",
}
},
flags = lj_str_hash_flags
}
LUAJIT_UNWIND_EXTERNAL,
_FILE_OFFSET_BITS,
_LARGEFILE_SOURCE,
LUA_MULTILIB,
LUAJIT_ENABLE_LUA52COMPAT,
LUAJIT_NUMMODE,
},
linux = {
defines = {
"_GNU_SOURCE",
}
},
flags = lj_str_hash_flags
}
end


lm:executable("luajit/lua") {
rootdir = luajitDir,
Expand All @@ -139,12 +145,14 @@ lm:executable("luajit/lua") {
"lj_libdef.h",
"lj_recdef.h",
},
deps = "lj_str_hash.c",
deps = {
has_str_hash and "lj_str_hash.c",
},
sources = {
"luajit.c",
"lj_*.c",
"lib_*.c",
"!lj_str_hash.c",
has_str_hash and "!lj_str_hash.c",
lm.bindir .. "/lj_vm.obj",
},
includes = {
Expand Down
2 changes: 1 addition & 1 deletion compile/luajit/make_buildtools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ lm:executable("buildvm") {
".",
"../../../../" .. lm.bindir
}
}
}
8 changes: 5 additions & 3 deletions compile/luajit/make_windows.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local lm = require "luamake"

local luaver = "luajit"
local luajitDir = '3rd/lua/'..luaver
local luajitDir = '3rd/lua/' .. luaver
local luajitSrcDir = luajitDir .. '/src'
local bindir = "publish/runtime/"..lm.runtime_platform
local is_old_version_luajit = require "compile.luajit.defined".is_old_version_luajit

lm:exe "minilua" {
rootdir = luajitDir,
Expand Down Expand Up @@ -170,7 +172,7 @@ lm:shared_library "luajit/luajit" {
},
sources = {
"!src/luajit.c",
"!src/lj_init.c",
is_old_version_luajit and "!src/lj_init.c",
"src/lj_*.c",
"src/lib_*.c",
},
Expand All @@ -189,7 +191,7 @@ lm:exe "luajit/lua" {
},
sources = {
"src/luajit.c",
"src/lj_init.c",
is_old_version_luajit and "src/lj_init.c",
},
includes = {
".",
Expand Down
30 changes: 30 additions & 0 deletions compile/luajit/relver.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local fs = require 'bee.filesystem'
local subprocess = require 'bee.subprocess'
local platform = require 'bee.platform'

local luajitDir = arg[1]
local output = arg[2]
---@type bee.subprocess.spawn.options
local args = fs.exists(luajitDir.."/.git") and {
"git",
"show",
"-s",
"--format=%ct"
} or {
platform.os ~= "windows" and "cat" or "type",
luajitDir.."/.relver"
}
args.cwd = luajitDir
args.stdout = true
args.stderr = true
args.searchPath = true

local proc, err = subprocess.spawn(args)
if not proc then
print(err)
os.exit(1)
end

proc:wait()

io.open(output, 'w+'):write(proc.stdout:read('a'))
14 changes: 14 additions & 0 deletions compile/windows/init_luamake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if exist luamake\.git (

pushd luamake

git pull
git submodule update --remote

popd

) else (

git clone https://github.com/actboy168/luamake.git --recurse-submodules

)
2 changes: 1 addition & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
| supportsDataBreakpoints | 🟨 |
| supportsReadMemoryRequest | 🟩 |
| supportsWriteMemoryRequest | 🟩 |
| supportsDisassembleRequest | 🟨 |
| supportsDisassembleRequest | 🟩 |
| supportsCancelRequest | 🟨 |
| supportsBreakpointLocationsRequest | 🟨 |
| supportsClipboardContext | 🟩 |
Expand Down
Loading
Loading