Skip to content

Commit

Permalink
实现luadbg-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Nov 9, 2023
1 parent 99ce2c1 commit 75da893
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 34 deletions.
1 change: 1 addition & 0 deletions compile/common/package_json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ attributes.common = {
"lua53",
"lua54",
"lua-latest",
"lua-compatible",
"luajit",
},
markdownDescription = "%lua.debug.launch.luaVersion.description%",
Expand Down
188 changes: 159 additions & 29 deletions compile/common/runtime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,165 @@ lm:source_set 'onelua' {
}
}

lm:source_set 'luadbg' {
deps = "onelua",
includes = {
"src/luadebug",
"3rd/bee.lua",
"3rd/bee.lua/3rd/lua",
},
sources = {
"src/luadebug/luadbg/*.cpp",
},
msvc = {
flags = "/utf-8",
},
windows = {
defines = {
"_CRT_SECURE_NO_WARNINGS",
"_WIN32_WINNT=0x0601",
},
}
}

lm:source_set 'luadbg-compatible' {
defines = {
"LUADBG_DISABLE",
},
includes = {
"src/luadebug",
"3rd/bee.lua",
"3rd/bee.lua/3rd/lua",
},
sources = {
"src/luadebug/luadbg/*.cpp",
"3rd/bee.lua/3rd/lua-seri/lua-seri.c",
},
msvc = {
flags = "/utf-8",
},
windows = {
defines = {
"_CRT_SECURE_NO_WARNINGS",
"_WIN32_WINNT=0x0601",
},
}
}

local compat <const> = {
["lua51"] = "compat/5x",
["lua52"] = "compat/5x",
["lua53"] = "compat/5x",
["lua54"] = "compat/5x",
["lua-latest"] = "compat/5x",
["lua-compatible"] = "compat/5x",
["luajit"] = "compat/jit"
}
for _, luaver in ipairs { "lua51", "lua52", "lua53", "lua54", "lua-latest", "luajit" } do
for _, luaver in ipairs { "lua51", "lua52", "lua53", "lua54", "luajit", "lua-latest", "lua-compatible" } do
runtimes[#runtimes + 1] = luaver.."/lua"
runtimes[#runtimes + 1] = luaver.."/luadebug"
if lm.os == "windows" then
runtimes[#runtimes + 1] = luaver.."/"..luaver
end
if luaver == "luajit" then
if lm.os == "windows" then
require "compile.luajit.make_windows"
else
if lm.cross_compile then
require "compile.common.run_luamake"
lm:build "buildvm" {
rule = "run_luamake",
inputs = "compile/luajit/make_buildtools.lua",
args = {
"-bindir", lm.bindir,
"-runtime_platform", lm.runtime_platform,
},
}
else
require "compile.luajit.make_buildtools"
end
require "compile.luajit.make"
end
elseif luaver == "lua-compatible" then
if lm.os == "windows" then
lm:shared_library(luaver.."/"..luaver) {
rootdir = '3rd/lua/lua-latest',
bindir = bindir,
includes = {
'..',
},
sources = {
"*.c",
"!lua.c",
"!luac.c",
},
defines = {
"LUA_BUILD_AS_DLL",
"LUA_VERSION_LATEST",
}
}

if luaver ~= "luajit" then
lm:executable(luaver..'/lua') {
rootdir = '3rd/lua/lua-latest',
bindir = bindir,
output = "lua",
deps = luaver..'/'..luaver,
includes = {
'..',
},
sources = {
"lua.c",
"../../../compile/windows/lua-debug.rc",
},
defines = {
"LUA_VERSION_LATEST",
}
}
else
lm:executable(luaver..'/lua') {
rootdir = '3rd/lua/lua-latest',
bindir = bindir,
includes = {
'.',
'..',
},
sources = {
"*.c",
"!luac.c",
},
defines = {
"LUA_VERSION_LATEST",
},
visibility = "default",
links = "m",
linux = {
defines = "LUA_USE_LINUX",
links = { "pthread", "dl" },
ldflags = "-Wl,-E",
},
netbsd = {
defines = "LUA_USE_LINUX",
links = "pthread",
ldflags = "-Wl,-E",
},
freebsd = {
defines = "LUA_USE_LINUX",
links = "pthread",
ldflags = "-Wl,-E",
},
android = {
defines = "LUA_USE_LINUX",
links = "dl",
},
macos = {
defines = {
"LUA_USE_MACOSX",
},
}
}
end
else
if lm.os == "windows" then
runtimes[#runtimes + 1] = luaver.."/"..luaver
lm:shared_library(luaver..'/'..luaver) {
lm:shared_library(luaver.."/"..luaver) {
rootdir = '3rd/lua/'..luaver,
bindir = bindir,
includes = {
Expand Down Expand Up @@ -130,40 +273,28 @@ for _, luaver in ipairs { "lua51", "lua52", "lua53", "lua54", "lua-latest", "lua
}
}
end
else
if lm.os == "windows" then
require "compile.luajit.make_windows"
else
if lm.cross_compile then
require "compile.common.run_luamake"
lm:build "buildvm" {
rule = "run_luamake",
inputs = "compile/luajit/make_buildtools.lua",
args = {
"-bindir", lm.bindir,
"-runtime_platform", lm.runtime_platform,
},
}
else
require "compile.luajit.make_buildtools"
end
require "compile.luajit.make"
end
end

local luaSrcDir = "3rd/lua/"..luaver;
if luaver == "luajit" then
luaSrcDir = luaSrcDir.."/src";
local luaSrcDir; do
if luaver == "luajit" then
luaSrcDir = "3rd/lua/luajit/src"
elseif luaver == "lua-compatible" then
luaSrcDir = "3rd/lua/lua-latest"
else
luaSrcDir = "3rd/lua/"..luaver
end
end

runtimes[#runtimes + 1] = luaver.."/luadebug"
lm:shared_library(luaver..'/luadebug') {
bindir = bindir,
deps = {
"onelua",
luaver == "lua-compatible" and "luadbg-compatible" or "luadbg",
"compile_to_luadbg",
},
defines = {
luaver == "lua-latest" and "LUA_VERSION_LATEST",
luaver == "lua-compatible" and "LUADBG_DISABLE",
},
includes = {
luaSrcDir,
Expand All @@ -173,7 +304,6 @@ for _, luaver in ipairs { "lua51", "lua52", "lua53", "lua54", "lua-latest", "lua
},
sources = {
"src/luadebug/*.cpp",
"src/luadebug/luadbg/*.cpp",
"src/luadebug/symbolize/*.cpp",
"src/luadebug/thunk/*.cpp",
"src/luadebug/util/*.cpp",
Expand Down
2 changes: 1 addition & 1 deletion extension/js/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function install() {
return;
}
for (const arch of ["win32-ia32", "win32-x64"]) {
for (const luaversion of ["lua51", "lua52", "lua53", "lua54", "lua-latest","luajit"]) {
for (const luaversion of ["lua51", "lua52", "lua53", "lua54","luajit", "lua-latest", "lua-compatible"]) {
await copyDirectory(path.join(extensionDir, "vcredist", arch), path.join(extensionDir, "runtime", arch, luaversion))
}
}
Expand Down
1 change: 1 addition & 0 deletions extension/script/frontend/debuger_factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local LuaVersionString <const> = {
["lua53"] = true,
["lua54"] = true,
["lua-latest"] = true,
["lua-compatible"] = true,
}
local function getLuaVersion(args)
if LuaVersionString[args.luaVersion] then
Expand Down
13 changes: 10 additions & 3 deletions src/luadebug/luadbg/bee_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
# include <winsock2.h>
#endif

#include "luadbg/lua.hpp"

#if !defined(LUADBG_DISABLE)

#include "luadbg/inc/luadbgexports.h"
#include "luadbg/inc/luadbgrename.h"

#define lua_h
#define luaconf_h
#define lualib_h
#define lauxlib_h
#define _LUALIB_H
#define _LUAJIT_H

#include "luadbg/inc/luadbg.hpp"
#include "luadbg/inc/luadbgexports.h"
#include "luadbg/inc/luadbgrename.h"
#endif

#include "luadbg/bee_module.h"

#include <binding/file.h>
#include <binding/binding.h>
#include <binding/lua_socket.cpp>
#include <binding/lua_thread.cpp>
#include <binding/lua_filesystem.cpp>
Expand Down
8 changes: 8 additions & 0 deletions src/luadebug/luadbg/lua.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#if !defined(LUADBG_DISABLE)
#include "luadbg/inc/luadbg.hpp"
#else
#include <lua.hpp>
#include "luadbg/inc/luadbgimports.h"
#endif
2 changes: 1 addition & 1 deletion src/luadebug/rdebug_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
#endif

#include "compat/lua.h"
#include "luadbg/inc/luadbg.hpp"
#include "luadbg/lua.hpp"

0 comments on commit 75da893

Please sign in to comment.