From 7a4c80ca9fcb904bffc2100883919e6fa9d63e23 Mon Sep 17 00:00:00 2001 From: ming Date: Mon, 21 Aug 2023 18:51:53 +0800 Subject: [PATCH 1/5] exp isoloate --- unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs | 6 ++++++ unity/Assets/core/upm/Runtime/Src/IL2Cpp/JsEnv.cs | 6 ++++++ .../Assets/core/upm/Runtime/Src/IL2Cpp/Native/NativeAPI.cs | 3 +++ 3 files changed, 15 insertions(+) diff --git a/unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs b/unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs index 1f7a0ae0b6..88b20ce6ef 100644 --- a/unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs +++ b/unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs @@ -52,6 +52,12 @@ internal TypeManager TypeRegister internal IntPtr isolate; + public IntPtr Isolate { + get { + return isolate; + } + } + internal ObjectPool objectPool; private readonly ILoader loader; diff --git a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/JsEnv.cs b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/JsEnv.cs index 5fff0cc58a..cb1d5a423a 100644 --- a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/JsEnv.cs +++ b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/JsEnv.cs @@ -52,6 +52,12 @@ public ILoader GetLoader() return loader; } + public IntPtr Isolate { + get { + return PuertsIl2cpp.NativeAPI.GetIsolate(nativeJsEnv); + } + } + public JsEnv(): this(new DefaultLoader(), -1) {} public JsEnv(ILoader loader, int debugPort = -1) diff --git a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/Native/NativeAPI.cs b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/Native/NativeAPI.cs index 1e564886a5..47974d19e3 100644 --- a/unity/Assets/core/upm/Runtime/Src/IL2Cpp/Native/NativeAPI.cs +++ b/unity/Assets/core/upm/Runtime/Src/IL2Cpp/Native/NativeAPI.cs @@ -52,6 +52,9 @@ public class NativeAPI [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetPesapiEnvHolder(IntPtr jsEnv); + [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr GetIsolate(IntPtr jsEnv); + [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr CreateCSharpTypeInfo(string name, IntPtr type_id, IntPtr super_type_id, IntPtr klass, bool isValueType, bool isDelegate, string delegateSignature); From 13cb456af11977cb9b215046aac538295331bc03 Mon Sep 17 00:00:00 2001 From: ming Date: Mon, 21 Aug 2023 18:48:59 +0800 Subject: [PATCH 2/5] exp il2cpp isolate --- unity/native_src_il2cpp/Src/Puerts.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unity/native_src_il2cpp/Src/Puerts.cpp b/unity/native_src_il2cpp/Src/Puerts.cpp index 9849127397..53401e33d0 100644 --- a/unity/native_src_il2cpp/Src/Puerts.cpp +++ b/unity/native_src_il2cpp/Src/Puerts.cpp @@ -823,6 +823,11 @@ V8_EXPORT void SetLogCallback(puerts::LogCallback Log) puerts::GLogCallback = Log; } +V8_EXPORT v8::Isolate* GetIsolate(puerts::JSEnv* jsEnv) +{ + return jsEnv->MainIsolate; +} + V8_EXPORT pesapi_env_holder GetPesapiEnvHolder(puerts::JSEnv* jsEnv) { v8::Isolate* Isolate = jsEnv->MainIsolate; From e9c45b2a44a5beca4ba30a872948969ac7bb7b6e Mon Sep 17 00:00:00 2001 From: ming Date: Fri, 25 Aug 2023 15:31:37 +0800 Subject: [PATCH 3/5] combine wee8 for android static & append extra src to puerts src by user --- unity/native_src/CMakeLists.txt | 4 ++++ unity/native_src_il2cpp/CMakeLists.txt | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/unity/native_src/CMakeLists.txt b/unity/native_src/CMakeLists.txt index 8d464b3e49..98f4269743 100644 --- a/unity/native_src/CMakeLists.txt +++ b/unity/native_src/CMakeLists.txt @@ -64,6 +64,10 @@ set ( PUERTS_SRC ${PROJECT_SOURCE_DIR}/../../unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.cpp ) +if(DEFINED PUERTS_EXTRA_SRC) + list(APPEND PUERTS_SRC ${PUERTS_EXTRA_SRC}) +endif() + macro(source_group_by_dir proj_dir source_files) if(MSVC OR APPLE) get_filename_component(sgbd_cur_dir ${proj_dir} ABSOLUTE) diff --git a/unity/native_src_il2cpp/CMakeLists.txt b/unity/native_src_il2cpp/CMakeLists.txt index 6b50add3ad..0d33a7dfc3 100644 --- a/unity/native_src_il2cpp/CMakeLists.txt +++ b/unity/native_src_il2cpp/CMakeLists.txt @@ -64,6 +64,9 @@ set ( PUERTS_SRC ${PROJECT_SOURCE_DIR}/../../unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.cpp ) +if(DEFINED PUERTS_EXTRA_SRC) + list(APPEND PUERTS_SRC ${PUERTS_EXTRA_SRC}) +endif() macro(source_group_by_dir proj_dir source_files) if(MSVC OR APPLE) @@ -107,6 +110,7 @@ if ( APPLE ) ) endif () elseif ( ANDROID ) + set(COMBINE_WEE8 on) add_library(puerts_il2cpp STATIC ${PUERTS_SRC} ${PUERTS_INC} ) @@ -172,7 +176,6 @@ elseif ( ANDROID ) # "${CMAKE_BINARY_DIR}/libpuerts_il2cpp.so" -o # "${CMAKE_BINARY_DIR}/libpuerts_il2cpp.stripped.so~" # COMMENT "Strip debug symbols done on final binary.") - elseif ( APPLE ) if ( IOS ) @@ -215,4 +218,16 @@ if ( WIN32 AND NOT CYGWIN AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" ) MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif () +if(COMBINE_WEE8) + add_custom_command(TARGET puerts_il2cpp POST_BUILD + COMMAND cp ARGS ${BACKEND_LIB_NAMES} ./ + COMMAND cp ARGS ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a ./libpuerts_il2cpp_tmp.a + COMMAND ar ARGS -x libpuerts_il2cpp_tmp.a + COMMAND ar ARGS -rs libwee8.a *.o + COMMAND mv ARGS libwee8.a ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a + COMMAND rm ARGS libpuerts_il2cpp_tmp.a + COMMAND rm ARGS -f *.o + COMMENT "combine wee8.") +endif() + install(TARGETS puerts_il2cpp DESTINATION bin) \ No newline at end of file From d6b3000ae1cc968e56072d3ed5386a604742639b Mon Sep 17 00:00:00 2001 From: ming Date: Fri, 25 Aug 2023 16:06:36 +0800 Subject: [PATCH 4/5] extra include --- unity/native_src/CMakeLists.txt | 4 ++++ unity/native_src_il2cpp/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/unity/native_src/CMakeLists.txt b/unity/native_src/CMakeLists.txt index 98f4269743..8eb8b2274f 100644 --- a/unity/native_src/CMakeLists.txt +++ b/unity/native_src/CMakeLists.txt @@ -68,6 +68,10 @@ if(DEFINED PUERTS_EXTRA_SRC) list(APPEND PUERTS_SRC ${PUERTS_EXTRA_SRC}) endif() +if(DEFINED PUERTS_EXTRA_INC) + include_directories(${PUERTS_EXTRA_INC}) +endif() + macro(source_group_by_dir proj_dir source_files) if(MSVC OR APPLE) get_filename_component(sgbd_cur_dir ${proj_dir} ABSOLUTE) diff --git a/unity/native_src_il2cpp/CMakeLists.txt b/unity/native_src_il2cpp/CMakeLists.txt index 0d33a7dfc3..3ef96c4156 100644 --- a/unity/native_src_il2cpp/CMakeLists.txt +++ b/unity/native_src_il2cpp/CMakeLists.txt @@ -68,6 +68,10 @@ if(DEFINED PUERTS_EXTRA_SRC) list(APPEND PUERTS_SRC ${PUERTS_EXTRA_SRC}) endif() +if(DEFINED PUERTS_EXTRA_INC) + include_directories(${PUERTS_EXTRA_INC}) +endif() + macro(source_group_by_dir proj_dir source_files) if(MSVC OR APPLE) get_filename_component(sgbd_cur_dir ${proj_dir} ABSOLUTE) From 52536745e9d7af0a8c3d7f3afea4070a9c5f6f6d Mon Sep 17 00:00:00 2001 From: zombieyang Date: Fri, 25 Aug 2023 20:18:47 +0800 Subject: [PATCH 5/5] [unity] compat with nodejs and mac fix --- unity/native_src_il2cpp/CMakeLists.txt | 25 ++++++++++----------- unity/native_src_il2cpp/cmake/backends.json | 22 +++++++++--------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/unity/native_src_il2cpp/CMakeLists.txt b/unity/native_src_il2cpp/CMakeLists.txt index 3ef96c4156..41453555e5 100644 --- a/unity/native_src_il2cpp/CMakeLists.txt +++ b/unity/native_src_il2cpp/CMakeLists.txt @@ -114,7 +114,6 @@ if ( APPLE ) ) endif () elseif ( ANDROID ) - set(COMBINE_WEE8 on) add_library(puerts_il2cpp STATIC ${PUERTS_SRC} ${PUERTS_INC} ) @@ -180,6 +179,18 @@ elseif ( ANDROID ) # "${CMAKE_BINARY_DIR}/libpuerts_il2cpp.so" -o # "${CMAKE_BINARY_DIR}/libpuerts_il2cpp.stripped.so~" # COMMENT "Strip debug symbols done on final binary.") + if (JS_ENGINE EQUAL "v8_9.4") + add_custom_command(TARGET puerts_il2cpp POST_BUILD + COMMAND cp ARGS ${BACKEND_LIB_NAMES} ./ + COMMAND cp ARGS ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a ./libpuerts_il2cpp_tmp.a + COMMAND ${ANDROID_TOOLCHAIN_PREFIX}ar ARGS -x libpuerts_il2cpp_tmp.a + COMMAND ${ANDROID_TOOLCHAIN_PREFIX}ar ARGS -rs libwee8.a *.o + COMMAND mv ARGS libwee8.a ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a + COMMAND rm ARGS libpuerts_il2cpp_tmp.a + COMMAND rm ARGS -f *.o + COMMENT "combine wee8." + ) + endif() elseif ( APPLE ) if ( IOS ) @@ -222,16 +233,4 @@ if ( WIN32 AND NOT CYGWIN AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" ) MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif () -if(COMBINE_WEE8) - add_custom_command(TARGET puerts_il2cpp POST_BUILD - COMMAND cp ARGS ${BACKEND_LIB_NAMES} ./ - COMMAND cp ARGS ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a ./libpuerts_il2cpp_tmp.a - COMMAND ar ARGS -x libpuerts_il2cpp_tmp.a - COMMAND ar ARGS -rs libwee8.a *.o - COMMAND mv ARGS libwee8.a ${CMAKE_BINARY_DIR}/libpuerts_il2cpp.a - COMMAND rm ARGS libpuerts_il2cpp_tmp.a - COMMAND rm ARGS -f *.o - COMMENT "combine wee8.") -endif() - install(TARGETS puerts_il2cpp DESTINATION bin) \ No newline at end of file diff --git a/unity/native_src_il2cpp/cmake/backends.json b/unity/native_src_il2cpp/cmake/backends.json index fc2ecc5271..bd508f12c8 100644 --- a/unity/native_src_il2cpp/cmake/backends.json +++ b/unity/native_src_il2cpp/cmake/backends.json @@ -200,6 +200,17 @@ "/Inc" ], "link-libraries": { + "android": { + "armv7": [ + "/Lib/Android/armeabi-v7a/libwee8.a" + ], + "arm64": [ + "/Lib/Android/arm64-v8a/libwee8.a" + ], + "x64": [ + "/Lib/Android/x64/libwee8.a" + ] + }, "win": { "ia32": [ "/Lib/Win32/wee8.lib" @@ -223,17 +234,6 @@ } }, "copy-libraries": { - "android": { - "armv7": [ - "/Lib/Android/armeabi-v7a/libwee8.a" - ], - "arm64": [ - "/Lib/Android/arm64-v8a/libwee8.a" - ], - "x64": [ - "/Lib/Android/x64/libwee8.a" - ] - }, "ios": { "arm64": [ "/Lib/iOS/arm64/libwee8.a"