Skip to content

fix: [build] [Dependencies] [Windows] 修复编译问题 #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions Dependencies/build_dep_with_source_code.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ call .\bootstrap-vcpkg.bat
vcpkg install libevent:x64-windows-static

vcpkg install protobuf:x64-windows-static

::vcpkg install lua:x64-windows-static

vcpkg install lua:x64-windows-static --overlay-ports=..\vcpkg_port\lua_3.5
vcpkg install sdl2:x64-windows-static

cd..

xcopy vcpkg\installed\x64-windows-static\lib lib\Release\ /s /e /Y
xcopy vcpkg\installed\x64-windows-static\bin ..\_Out\Release\ /s /e /Y
ren lib\Release\SDL2-static.lib SDL2.lib

xcopy vcpkg\installed\x64-windows-static\debug\lib lib\Debug\ /s /e /Y
xcopy vcpkg\installed\x64-windows-static\debug\bin ..\_Out\Debug\ /s /e /Y
ren lib\Debug\SDL2-staticd.lib SDL2d.lib
ren lib\Debug\eventd.lib event.lib
ren lib\Debug\event_cored.lib event_core.lib
ren lib\Debug\event_extrad.lib event_extra.lib



xcopy vcpkg\installed\x64-windows-static\tools\protobuf\protoc.exe ..\NFComm\NFMessageDefine\ /s /e /Y

xcopy vcpkg\installed\x64-windows-static\tools\protobuf\* ..\NFComm\NFMessageDefine\ /s /e /Y
cd ..\NFComm\NFMessageDefine
.\cpp.bat



Expand Down
28 changes: 28 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/CMakeLists-cpp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SET(SRC_LIBLUACPP ${SRC_LIBLUA})
ADD_LIBRARY ( lua-cpp ${SRC_LIBLUACPP} ${HDR_LIBLUACPP} )
SET_TARGET_PROPERTIES(lua-cpp PROPERTIES OUTPUT_NAME "lua-c++")
SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUACPP} PROPERTIES LANGUAGE CXX)
TARGET_INCLUDE_DIRECTORIES(lua-cpp PRIVATE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> PUBLIC $<INSTALL_INTERFACE:include>)
IF (BUILD_SHARED_LIBS AND WIN32)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_BUILD_AS_DLL )
ENDIF ()
IF (UNIX)
IF (APPLE)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN)
ELSE ()
FIND_LIBRARY (LIB_DLOPEN NAMES dl)
IF (LIB_DLOPEN)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN)
TARGET_LINK_LIBRARIES (lua-cpp ${LIB_DLOPEN})
ENDIF ()
ENDIF ()
ENDIF ()

INSTALL ( TARGETS lua-cpp
EXPORT unofficial-lua-cpp-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

INSTALL(EXPORT unofficial-lua-cpp-config DESTINATION share/unofficial-lua-cpp)
114 changes: 114 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Lua can be compiled as either C or C++.
# Default configuration is C, set COMPILE_AS_CPP to ON to use C++.
# See http://stackoverflow.com/questions/13560945/c-and-c-library-using-longjmp for why would you want to do that.
# Primary differences:
# - Exceptions will be used instead of setjmp/longjmp
# - The name mangling for functions will be C++ instead of C.
# - This is a source-incompatible change because extern "C" is chosen by the including application.
# - The lua.hpp header will not be available.

PROJECT ( lua )


CMAKE_MINIMUM_REQUIRED(VERSION 3.18)

# Build Libraries
FILE(GLOB HDR_LIBLUA "${CMAKE_SOURCE_DIR}/src/*.h")
# For luac.c
LIST(REMOVE_ITEM HDR_LIBLUA "${CMAKE_SOURCE_DIR}/src/lopnames.h")

FILE(GLOB SRC_LIBLUA "${CMAKE_SOURCE_DIR}/src/*.c")
# Executables luac and luai
LIST(REMOVE_ITEM SRC_LIBLUA "${CMAKE_SOURCE_DIR}/src/luac.c" "${CMAKE_SOURCE_DIR}/src/lua.c")

IF (WIN32)
# remove warnings
ADD_DEFINITIONS (-D_CRT_SECURE_NO_WARNINGS )
ENDIF ()

IF (UNIX)
ADD_DEFINITIONS (-DLUA_USE_POSIX)
ENDIF ()

# C library
SET (CMAKE_C_STANDARD 99)
SET(SRC_LIBLUAC ${SRC_LIBLUA})
ADD_LIBRARY ( lua ${SRC_LIBLUAC} ${HDR_LIBLUA} )
TARGET_INCLUDE_DIRECTORIES(lua PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> PUBLIC $<INSTALL_INTERFACE:include>)
SET_PROPERTY (TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON)
SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUAC} PROPERTIES LANGUAGE C)

IF (BUILD_SHARED_LIBS AND WIN32)
TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_BUILD_AS_DLL )
ENDIF ()

IF (UNIX)
IF (APPLE)
TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_USE_DLOPEN)
ELSE ()
FIND_LIBRARY (LIB_DLOPEN NAMES dl)
IF (LIB_DLOPEN)
TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_USE_DLOPEN)
TARGET_LINK_LIBRARIES (lua ${CMAKE_DL_LIBS})
ENDIF ()
FIND_LIBRARY (LIB_MATH NAMES m)
IF (LIB_MATH)
TARGET_LINK_LIBRARIES (lua m)
ENDIF ()
ENDIF ()
ENDIF ()

INSTALL ( TARGETS lua
EXPORT unofficial-lua-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

install(EXPORT unofficial-lua-config DESTINATION share/unofficial-lua)

# CXX library
IF (COMPILE_AS_CPP)
ADD_SUBDIRECTORY(cpp)
ENDIF()

IF (INSTALL_TOOLS)
# compiler uses non-exported APIs, so must include sources directly.
ADD_EXECUTABLE ( luac ${CMAKE_SOURCE_DIR}/src/luac.c ${SRC_LIBLUA} ${CMAKE_SOURCE_DIR}/src/lopnames.h )
ADD_EXECUTABLE ( luai ${CMAKE_SOURCE_DIR}/src/lua.c ) # interpreter

TARGET_INCLUDE_DIRECTORIES(luac PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
TARGET_LINK_LIBRARIES ( luai PRIVATE lua )
SET_TARGET_PROPERTIES ( luai PROPERTIES OUTPUT_NAME lua PDB_NAME luai )
IF (UNIX)
IF (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
SET (_LIB_READLINE_NAME edit)
ELSE ()
SET (_LIB_READLINE_NAME readline)
ENDIF ()
FIND_LIBRARY (LIB_READLINE NAMES ${_LIB_READLINE_NAME})
IF (LIB_READLINE)
TARGET_COMPILE_DEFINITIONS (luai PUBLIC -DLUA_USE_READLINE)
TARGET_LINK_LIBRARIES(luai PRIVATE ${LIB_READLINE})
IF (_LIB_READLINE_NAME STREQUAL edit)
TARGET_INCLUDE_DIRECTORIES (luai PUBLIC /usr/include/edit)
ENDIF ()
ENDIF ()
ENDIF ()
INSTALL ( TARGETS luai luac RUNTIME DESTINATION tools/lua )
ENDIF ()

IF (NOT SKIP_INSTALL_HEADERS)
INSTALL(
FILES
src/lualib.h
src/lua.h
src/luaconf.h
src/lauxlib.h
DESTINATION include
)
# If using C++, don't install extern "C" wrapper.
IF (NOT COMPILE_AS_CPP)
INSTALL(FILES src/lua.hpp DESTINATION include)
ENDIF ()
ENDIF ()
6 changes: 6 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright � 1994�2016 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/fix-ios-system.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/src/loslib.c b/src/loslib.c
index e65e188..3595601 100644
--- a/src/loslib.c
+++ b/src/loslib.c
@@ -3,7 +3,9 @@
** Standard Operating System library
** See Copyright Notice in lua.h
*/
-
+#if defined(__APPLE__)
+#include <TargetConditionals.h>
+#endif
#define loslib_c
#define LUA_LIB

@@ -143,7 +145,12 @@ static int os_execute (lua_State *L) {
const char *cmd = luaL_optstring(L, 1, NULL);
int stat;
errno = 0;
- stat = system(cmd);
+#if defined(__APPLE__) && !TARGET_OS_OSX
+ // system() is __IOS_PROHIBITED, __WATCHOS_PROHIBITED, and __TVOS_PROHIBITED.
+ stat = 127; // error: shell execution failed
+#else
+ stat = system(cmd);
+#endif
if (cmd != NULL)
return luaL_execresult(L, stat);
else {
54 changes: 54 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
vcpkg_download_distfile(ARCHIVE
URLS "http://www.lua.org/ftp/lua-5.3.6.tar.gz"
FILENAME "lua-5.3.6.tar.gz"
SHA512 CCC380D5E114D54504DE0BFB0321CA25EC325D6FF1BFEE44B11870B660762D1A9BF120490C027A0088128B58BB6B5271BBC648400CAB84D2DC22B512C4841681
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
vs2015-impl-c99.patch
#fix-ios-system.patch
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/CMakeLists-cpp.txt" DESTINATION "${SOURCE_PATH}/cpp" RENAME "CMakeLists.txt")

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
cpp COMPILE_AS_CPP # Also used in cmake wrapper
tools INSTALL_TOOLS
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
)
vcpkg_cmake_install()

vcpkg_copy_pdbs()

vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-lua CONFIG_PATH share/unofficial-lua)

if("cpp" IN_LIST FEATURES)
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-lua-cpp CONFIG_PATH "share/unofficial-lua-cpp")
endif()

if ("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES lua luac SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/luaconf.h" "defined(LUA_BUILD_AS_DLL)" "1")
endif()
endif()

# Suitable for old version
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
5 changes: 5 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Use this package via the module FindLua that comes with CMake. To use in your CMakeLists.txt:

find_package(Lua REQUIRED)
target_include_directories(main PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(main PRIVATE ${LUA_LIBRARIES})
23 changes: 23 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/vcpkg-cmake-wrapper.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(REQUIRES )
foreach(ARG IN_LISTS ${ARGS})
if (ARG STREQUAL "REQUIRED")
set(REQUIRES "REQUIRED")
endif()
endforeach()

_find_package(unofficial-lua CONFIG ${REQUIRES})

if (@COMPILE_AS_CPP@)
_find_package(unofficial-lua-cpp CONFIG ${REQUIRES})
endif()

get_filename_component(LUA_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}" PATH)
get_filename_component(LUA_INCLUDE_DIR "${LUA_INCLUDE_DIR}" PATH)
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR}/include)

list(APPEND LUA_LIBRARIES lua)
if (TARGET lua-cpp)
list(APPEND LUA_LIBRARIES lua-cpp)
endif()

set(LUA_FOUND 1)
28 changes: 28 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "lua",
"version": "3.5.6",
"port-version": 0,
"description": "A powerful, fast, lightweight, embeddable scripting language",
"homepage": "https://www.lua.org",
"license": null,
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"cpp": {
"description": "Builds Lua for C++ linkage",
"supports": "!uwp"
},
"tools": {
"description": "Builds Lua compiler and interpreter",
"supports": "!ios"
}
}
}
11 changes: 11 additions & 0 deletions Dependencies/vcpkg_port/lua_3.5/vs2015-impl-c99.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -54,7 +54,7 @@

#if defined(LUA_USE_WINDOWS)
#define LUA_DL_DLL /* enable support for DLL */
-#define LUA_USE_C89 /* broadly, Windows is C89 */
+//#define LUA_USE_C89 /* broadly, Windows is C89 */
#endif


12 changes: 8 additions & 4 deletions NFComm/NFMessageDefine/cpp.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

protoc.exe -I=./ --cpp_out=./ ./NFDefine.proto
protoc.exe -I=./ --cpp_out=./ ./NFMsgBase.proto
protoc.exe -I=./ --cpp_out=./ ./NFMsgPreGame.proto
protoc.exe -I=./ --cpp_out=./ ./NFMsgShare.proto
del NFDefine.pb*
del NFMsgBase.pb*
del NFMsgPreGame.pb*
del NFMsgShare.pb*
protoc.exe -I=. --cpp_out=. ./NFDefine.proto
protoc.exe -I=. --cpp_out=. ./NFMsgBase.proto
protoc.exe -I=. --cpp_out=. ./NFMsgPreGame.proto
protoc.exe -I=. --cpp_out=. ./NFMsgShare.proto



Expand Down
2 changes: 2 additions & 0 deletions NFComm/NFNetPlugin/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#if NF_PLATFORM == NF_PLATFORM_WIN
#pragma comment( lib, "ws2_32" )
#pragma comment( lib, "Bcrypt" )
#pragma comment( lib, "NFCore.lib" )
#pragma comment( lib, "NFMessageDefine.lib" )
#pragma comment( lib, "event.lib" )
Expand All @@ -45,6 +46,7 @@

#if NF_PLATFORM == NF_PLATFORM_WIN
#pragma comment( lib, "ws2_32" )
#pragma comment( lib, "Bcrypt" )
#pragma comment( lib, "NFCore.lib" )
#pragma comment( lib, "NFMessageDefine.lib" )
#pragma comment( lib, "event.lib" )
Expand Down
2 changes: 2 additions & 0 deletions NFComm/NFNoSqlPlugin/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#if NF_PLATFORM == NF_PLATFORM_WIN
#pragma comment( lib, "ws2_32" )
#pragma comment( lib, "Bcrypt" )
#pragma comment( lib, "event.lib" )
#pragma comment( lib, "hiredis.lib")
#else
Expand All @@ -37,6 +38,7 @@

#if NF_PLATFORM == NF_PLATFORM_WIN
#pragma comment( lib, "ws2_32" )
#pragma comment( lib, "Bcrypt" )
#pragma comment( lib, "event.lib" )
#pragma comment( lib, "hiredis.lib")

Expand Down
2 changes: 2 additions & 0 deletions NFComm/NFPluginLoader/NFPluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#pragma comment( lib, "imm32.lib" )
//#pragma comment( lib, "msvcrt.lib" )
#pragma comment (lib, "Setupapi.lib")
#pragma comment( lib, "Bcrypt" )


#ifndef NF_DYNAMIC_PLUGIN
#ifdef NF_DEBUG_MODE
Expand Down