Skip to content

Commit

Permalink
[unity]添加quickjs后端的编译支持
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 16, 2020
1 parent e209cb0 commit 336bb84
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
68 changes: 54 additions & 14 deletions unity/native_src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

cmake_minimum_required(VERSION 2.8)

if ( WIN32 AND NOT CYGWIN AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" ) AND NOT ANDROID)
if ( WIN32 AND NOT CYGWIN AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" ) AND NOT ANDROID AND NOT MSYS)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT" CACHE STRING "")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" CACHE STRING "")
Expand All @@ -31,7 +31,14 @@ find_path(PUERTS_PROJECT_DIR NAMES SConstruct

MARK_AS_ADVANCED(PUERTS_PROJECT_DIR)

set(V8_ENGINE ${CMAKE_SOURCE_DIR}/v8)
if ( JS_ENGINE STREQUAL "quickjs")
set(LIB_FILE_NAME libquickjs.a)
else()
set(JS_ENGINE v8)
set(LIB_FILE_NAME libwee8.a)
endif()

set(V8_ENGINE ${CMAKE_SOURCE_DIR}/${JS_ENGINE})

set(V8_INC ${V8_ENGINE}/Inc)

Expand Down Expand Up @@ -109,35 +116,68 @@ if ( WIN32 AND NOT CYGWIN )
target_compile_definitions (puerts PRIVATE BUILDING_V8_SHARED)
endif ( )

if ( WIN32 )
if ( JS_ENGINE STREQUAL "quickjs")
target_compile_definitions (puerts PRIVATE WITHOUT_INSPECTOR)
endif ( )

if (MSYS)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win32/wee8.lib
winmm.lib
dbghelp.lib
shlwapi.lib
${V8_ENGINE}/Lib/Win32/${LIB_FILE_NAME}
)
else ()
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win64/wee8.lib
winmm.lib
dbghelp.lib
shlwapi.lib
${V8_ENGINE}/Lib/Win64/${LIB_FILE_NAME}
)
endif ()
target_compile_definitions (puerts PRIVATE PLATFORM_WINDOWS)
elseif ( WIN32 )
if ( JS_ENGINE STREQUAL "quickjs")
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win32/quickjs.dll.lib
winmm.lib
dbghelp.lib
shlwapi.lib
)
else ()
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win64/quickjs.dll.lib
winmm.lib
dbghelp.lib
shlwapi.lib
)
endif ()
else ()
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win32/wee8.lib
winmm.lib
dbghelp.lib
shlwapi.lib
)
else ()
target_link_libraries(puerts
${V8_ENGINE}/Lib/Win64/wee8.lib
winmm.lib
dbghelp.lib
shlwapi.lib
)
endif ()
endif ()
target_compile_definitions (puerts PRIVATE PLATFORM_WINDOWS)
elseif ( ANDROID )
find_library(log-lib log )

if( ANDROID_ABI STREQUAL "armeabi-v7a")
target_link_libraries(puerts
${V8_ENGINE}/Lib/Android/armv7/libwee8.a
${V8_ENGINE}/Lib/Android/armv7/${LIB_FILE_NAME}
${log-lib}
)
target_compile_definitions (puerts PRIVATE PLATFORM_ANDROID_ARM)
else ( )
target_link_libraries(puerts
${V8_ENGINE}/Lib/Android/arm64/libwee8.a
${V8_ENGINE}/Lib/Android/arm64/${LIB_FILE_NAME}
${log-lib}
)
target_compile_definitions (puerts PRIVATE PLATFORM_ANDROID_ARM64)
Expand All @@ -155,7 +195,7 @@ elseif ( APPLE )
target_compile_definitions (puerts PRIVATE PLATFORM_IOS)
else ()
target_link_libraries(puerts
${V8_ENGINE}/Lib/macOS/libwee8.a
${V8_ENGINE}/Lib/macOS/${LIB_FILE_NAME}
)
target_compile_definitions (puerts PRIVATE PLATFORM_MAC)
endif ( )
Expand Down
5 changes: 5 additions & 0 deletions unity/native_src/make_win64_qjs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdir build64qjs & pushd build64qjs
cmake -DJS_ENGINE=quickjs -G "Visual Studio 16 2019" -A x64 ..
popd
cmake --build build64qjs --config Release
pause
2 changes: 1 addition & 1 deletion unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define USING_UE 0
#endif

#if PLATFORM_WINDOWS || PLATFORM_MAC
#if (PLATFORM_WINDOWS || PLATFORM_MAC || WITH_INSPECTOR) && !WITHOUT_INSPECTOR

#include "V8InspectorImpl.h"

Expand Down

0 comments on commit 336bb84

Please sign in to comment.