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); diff --git a/unity/native_src/CMakeLists.txt b/unity/native_src/CMakeLists.txt index 8d464b3e49..8eb8b2274f 100644 --- a/unity/native_src/CMakeLists.txt +++ b/unity/native_src/CMakeLists.txt @@ -64,6 +64,14 @@ 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() + +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 6b50add3ad..41453555e5 100644 --- a/unity/native_src_il2cpp/CMakeLists.txt +++ b/unity/native_src_il2cpp/CMakeLists.txt @@ -64,6 +64,13 @@ 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() + +if(DEFINED PUERTS_EXTRA_INC) + include_directories(${PUERTS_EXTRA_INC}) +endif() macro(source_group_by_dir proj_dir source_files) if(MSVC OR APPLE) @@ -172,7 +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 ) 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; 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"