Skip to content

Commit

Permalink
luadbg fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oceancx committed Aug 15, 2019
1 parent 94f7753 commit 48b3a52
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 33 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/dist CACHE PATH "..." FORCE)
endif()


# list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_SOURCE_DIR}/internals)
# list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_SOURCE_DIR}/luadbg)

Expand Down
10 changes: 10 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

if [ $1 = "test" ]; then
cd test;
start ./Debug/luadbgtest.exe --cwd='E:/Github/luadebugger/test/'
fi

if [ $1 = "vscode" ]; then
cd vscode;
start ./Debug/vsdbgadapter.exe --cwd='E:/Github/luadebugger/vscode/'
fi
81 changes: 61 additions & 20 deletions luadbg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,88 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "Source Files" FILES $
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "Header Files" FILES ${SOURCES_HEADER_RPI})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include PREFIX "Header Files" FILES ${SOURCES_HEADER_PUB})

add_library(luadbg
add_library(luadbg_static
${SOURCES_HEADER_PUB}
${SOURCES_HEADER_PRI}
src/luadbg.cpp
)
set_source_files_properties(lua_cjson.c PROPERTIES LANGUAGE C )
set_source_files_properties(strbuf.c PROPERTIES LANGUAGE C )
target_compile_definitions(luadbg_static
PRIVATE
-D_LUADBG_BUILD_DLL
-DVERSION="${PROJECT_VERSION}"
-DLUA_COMPAT_5_2
-DLUA_COMPAT_5_1
)


target_compile_definitions(luadbg PRIVATE -D_LUADBG_BUILD_DLL)
target_compile_definitions(luadbg PRIVATE -DVERSION="${PROJECT_VERSION}")
target_compile_definitions(luadbg PRIVATE -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1)
target_include_directories(luadbg
target_include_directories(luadbg_static
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(luadbg
target_link_libraries(luadbg_static
PUBLIC
CXLua::CXLua
)

include(cmake/HelperMacroFunction.cmake)
export_library_macro(luadbg luadbg "" lib/cmake/luadbg)
export_library_macro(luadbg_static luadbg_static "" lib/cmake/luadbg)

set_target_properties(luadbg PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg_static PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

# execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_inl.sh ${CMAKE_CURRENT_LIST_DIR})
add_custom_command(TARGET luadbg

add_custom_command(TARGET luadbg_static
PRE_BUILD
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_inl.sh ${CMAKE_CURRENT_LIST_DIR}
)

if(CMAKE_RUNTIME_OUTPUT_DIRECTORY )
add_custom_command(TARGET luadbg
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIG>/luadbg.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIG>/luadbg.lib ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/
# add_custom_command(TARGET luadbg
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIG>/luadbg.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIG>/luadbg.lib ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/
# )

add_library(luadbg_shared SHARED
${SOURCES_HEADER_PUB}
${SOURCES_HEADER_PRI}
src/luadbg.cpp
)

target_compile_definitions(luadbg_shared
PRIVATE
-D_LUADBG_BUILD_DLL
-DVERSION="${PROJECT_VERSION}"
-DLUA_COMPAT_5_2
-DLUA_COMPAT_5_1
)
endif()

target_include_directories(luadbg_shared
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(luadbg_shared
PUBLIC
CXLua::CXLua
)

include(cmake/HelperMacroFunction.cmake)
export_library_macro(luadbg_shared luadbg_shared "" lib/cmake/luadbg)

set_target_properties(luadbg_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg_shared PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(luadbg_shared PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})


add_custom_command(TARGET luadbg_shared
PRE_BUILD
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_inl.sh ${CMAKE_CURRENT_LIST_DIR}
)
4 changes: 0 additions & 4 deletions luadbg/cmake/luadbgConfig.cmake

This file was deleted.

4 changes: 4 additions & 0 deletions luadbg/cmake/luadbg_sharedConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if(NOT TARGET luadbg)
find_package(CXLua)
include("${CMAKE_CURRENT_LIST_DIR}/luadbg_sharedTargets.cmake")
endif()
4 changes: 4 additions & 0 deletions luadbg/cmake/luadbg_staticConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if(NOT TARGET luadbg)
find_package(CXLua)
include("${CMAKE_CURRENT_LIST_DIR}/luadbg_staticTargets.cmake")
endif()
11 changes: 7 additions & 4 deletions luadbg/debuggee.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function create_on_message_parser()
end
elseif readstate == 3 then
if buf:readable_size() >= parsed_len then
local js = buf:ReadAsString(parsed_len)
readstate = 1
netq:push_back(0,js)
netq:push_back(0,buf,parsed_len)
buf:Consume(parsed_len)
readstate = 1
else
break
end
Expand All @@ -52,7 +52,10 @@ end

function debuggee_on_connection(conn,netq)
--print('[debuggee]' ..conn:tohostport().. ' ' ..(conn:connected() and 'connected' or 'disconnected'))
netq:push_back(0,cjson.encode({ type='debuggee', event='connection_state', connected = conn:connected(), addr = conn:tohostport() }))
local buf = ezio_buffer_create()
buf:WriteString(cjson.encode({ type='debuggee', event='connection_state', connected = conn:connected(), addr = conn:tohostport() }))
netq:push_back(0,buf,buf:readable_size())
ezio_buffer_destroy(buf)
end

local debuggee_on_message_parser = create_on_message_parser()
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_include_directories(luadbgtest
)

target_link_libraries(luadbgtest
luadbg
luadbg_static
)
#target_compile_definitions(luadbgtest PUBLIC -LUADBG_DLL)
set_target_properties(luadbgtest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion test/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dofile('F:/Github/luadebugger/test/hello.lua')
dofile('E:/Github/luadebugger/test/hello.lua')

function main()
luadbg_listen(9527)
Expand Down
3 changes: 0 additions & 3 deletions test/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include <luadbg.h>
#include <string>




std::string PATH_SEP("");
std::string CWD = "";
int port = 4711;
Expand Down

0 comments on commit 48b3a52

Please sign in to comment.