mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e178c0e37 | |||
| 40711cbf38 | |||
| 7749b6448e | |||
| 1459992ec4 | |||
| c09dad4ae1 | |||
| 271dc70626 | |||
| c462aeb2ef | |||
| adbdbf3a00 | |||
| 10684d29cd | |||
| 7d58454fdd | |||
| 21b85aa2d3 | |||
| 8439e4176d | |||
| 4b43870ff2 |
@@ -1,14 +1,19 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2020",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2020-3.0.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v3.0.2"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.0.0"}
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.0.2"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022",
|
||||
"hybridclr" : { "branch":"v3.0.2"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.0.0"}
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.0.2"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
# file: CMakeList.txt
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET iOS)
|
||||
|
||||
set(TMP $ENV{HUATUO_IL2CPP_SOURCE_DIR})
|
||||
if ( NOT TMP )
|
||||
message(FATAL_ERROR "需要设置环境变量: HUATUO_IL2CPP_SOURCE_DIR")
|
||||
else()
|
||||
message(STATUS "unity il2cpp 路径为: ${TMP}")
|
||||
endif()
|
||||
|
||||
set(SDK_VERSION $ENV{IPHONESIMULATOR_VERSION})
|
||||
if ( SDK_VERSION )
|
||||
message(STATUS "使用iPhoneSimulator版本:" ${SDK_VERSION})
|
||||
else()
|
||||
message(STATUS "当前使用默认版本的iPhoneSimulator,可以通过设置环境变量IPHONESIMULATOR_VERSION,指定版本")
|
||||
endif()
|
||||
|
||||
project(il2cpp)
|
||||
execute_process(COMMAND sh gen_lump.sh ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(external)
|
||||
add_subdirectory(objective)
|
||||
|
||||
|
||||
set(IL2CPP_SOURCE_DIR $ENV{HUATUO_IL2CPP_SOURCE_DIR})
|
||||
|
||||
message(STATUS "il2cpp project, binary dir: " ${CMAKE_BINARY_DIR})
|
||||
message(STATUS "il2cpp project, build dir: " ${PROJECT_BINARY_DIR})
|
||||
message(STATUS "il2cpp project, il2cpp source dir: " ${IL2CPP_SOURCE_DIR})
|
||||
|
||||
|
||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
find_program(CLANG_EXECUTABLE NAMES clang clang-7 clang-8 clang-9 clang-10)
|
||||
if (NOT CLANG_EXECUTABLE)
|
||||
message(FATAL_ERROR "Cannot find any clang executable.")
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk)
|
||||
|
||||
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
#add_compile_options(-x objective-c++)
|
||||
|
||||
# 以下命令为复制的Xcode生成中的命令
|
||||
set(CMAKE_CXX_FLAGS "-target arm64-apple-ios11.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++1z -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fmodules-ignore-macro=IL2CPP_TARGET_IOS=1 -fembed-bitcode -fmodules-ignore-macro=BASELIB_DYNAMICLIBRARY=1 -fmodules-ignore-macro=BASELIB_INLINE_NAMESPACE=il2cpp_baselib -fmodules-ignore-macro=AARCH64 -fmodules-ignore-macro=__aarch64__ -fmodules-ignore-macro=IL2CPP_SUPPORT_THREADS -fmodules-ignore-macro=IL2CPP_THREADS_PTHREAD -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DIL2CPP_TARGET_IOS=1 -isysroot ${CMAKE_OSX_SYSROOT} -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability ")
|
||||
|
||||
|
||||
add_definitions(-DIL2CPP_TARGET_IOS=1)
|
||||
add_definitions(-DBASELIB_DYNAMICLIBRARY=1)
|
||||
add_definitions(-DBASELIB_INLINE_NAMESPACE=il2cpp_baselib)
|
||||
add_definitions(-DAARCH64)
|
||||
add_definitions(-D__aarch64__)
|
||||
add_definitions(-DIL2CPP_SUPPORT_THREADS)
|
||||
add_definitions(-DIL2CPP_THREADS_PTHREAD)
|
||||
#add_definitions(-DCMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
||||
#add_definitions(-DCMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++)
|
||||
#add_definitions(-DIL2CPP_TARGET_DARWIN)
|
||||
add_definitions(-DIL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO)
|
||||
|
||||
add_definitions(-MMD)
|
||||
add_definitions(-MT dependencies)
|
||||
|
||||
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/libil2cpp/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/bdwgc/include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Platforms/OSX/Include/)
|
||||
|
||||
# 修改为本机对应SDK路径
|
||||
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/v1)
|
||||
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include)
|
||||
|
||||
aux_source_directory(${PROJECT_BINARY_DIR}/lump_cpp LUMP_SOURCE_LIST)
|
||||
aux_source_directory(${IL2CPP_SOURCE_DIR}/libil2cpp LIBIL2CPP_SOURCE_LIST)
|
||||
|
||||
#find_library(zlib ${PROJECT_SOURCE_DIR}/external)
|
||||
add_library(il2cpp_original STATIC ${LIBIL2CPP_SOURCE_LIST} ${LUMP_SOURCE_LIST})
|
||||
add_dependencies(il2cpp_original external objective)
|
||||
|
||||
add_custom_command(TARGET il2cpp_original
|
||||
POST_BUILD
|
||||
COMMAND xcrun -r libtool -static -o libil2cpp.a libil2cpp_original.a external/libexternal.a objective/libobjective.a
|
||||
COMMENT "post build this is command combine libil2cpp_original.a, libojjective.a and libzlib.a into libil2cpp"
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export HUATUO_IL2CPP_SOURCE_DIR=$(pushd ../LocalIl2CppData-OSXEditor/il2cpp > /dev/null && pwd && popd > /dev/null)
|
||||
export IPHONESIMULATOR_VERSION=
|
||||
|
||||
rm -rf build
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_OSX_ARCHITECTURES=arm64 ..
|
||||
make -j24
|
||||
|
||||
if [ -f "libil2cpp.a" ]
|
||||
then
|
||||
echo 'build succ'
|
||||
else
|
||||
echo "build fail"
|
||||
exit 1
|
||||
fi
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
# file: external/CMakeList.txt
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET iOS)
|
||||
|
||||
set(IL2CPP_SOURCE_DIR $ENV{HUATUO_IL2CPP_SOURCE_DIR})
|
||||
set(SDK_VERSION $ENV{IPHONESIMULATOR_VERSION})
|
||||
|
||||
message(STATUS "external project, external source dir: " ${IL2CPP_SOURCE_DIR})
|
||||
|
||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
find_program(CLANG_EXECUTABLE NAMES clang clang-7 clang-8 clang-9 clang-10)
|
||||
if (NOT CLANG_EXECUTABLE)
|
||||
message(FATAL_ERROR "Cannot find any clang executable.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
set(CMAKE_C_FLAGS "-x c -target arm64-apple-ios11.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu11 -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fmodules-ignore-macro=IL2CPP_TARGET_IOS=1 -fembed-bitcode -fmodules-ignore-macro=BASELIB_DYNAMICLIBRARY=1 -fmodules-ignore-macro=BASELIB_INLINE_NAMESPACE=il2cpp_baselib -fmodules-ignore-macro=AARCH64 -fmodules-ignore-macro=__aarch64__ -fmodules-ignore-macro=IL2CPP_SUPPORT_THREADS -fmodules-ignore-macro=IL2CPP_THREADS_PTHREAD -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DIL2CPP_TARGET_IOS=1 -isysroot ${CMAKE_OSX_SYSROOT} -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability")
|
||||
|
||||
|
||||
add_definitions(-DIL2CPP_TARGET_IOS=1)
|
||||
add_definitions(-DBASELIB_DYNAMICLIBRARY=1)
|
||||
add_definitions(-DBASELIB_INLINE_NAMESPACE=il2cpp_baselib)
|
||||
add_definitions(-DAARCH64)
|
||||
add_definitions(-D__aarch64__)
|
||||
#add_definitions(-D__arm64__)
|
||||
add_definitions(-DIL2CPP_SUPPORT_THREADS)
|
||||
add_definitions(-DIL2CPP_THREADS_PTHREAD)
|
||||
#add_definitions(-DCMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
||||
#add_definitions(-DCMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++)
|
||||
#add_definitions(-DIL2CPP_TARGET_DARWIN)
|
||||
add_definitions(-DIL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO=0)
|
||||
|
||||
add_definitions(-MMD)
|
||||
add_definitions(-MT dependencies)
|
||||
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/bdwgc/include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Platforms/OSX/Include/)
|
||||
|
||||
aux_source_directory(${IL2CPP_SOURCE_DIR}/external/zlib/ ZLIB_C_SOURCE_LIST)
|
||||
add_library(external STATIC ${ZLIB_C_SOURCE_LIST})
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
echo '====================================================================='
|
||||
echo 'gen lump'
|
||||
echo '$HUATUO_IL2CPP_SOURCE_DIR='${HUATUO_IL2CPP_SOURCE_DIR} #/Applications/Unity/Unity.app/Contents/il2cpp/
|
||||
|
||||
GEN_SOURCE_DIR=$1
|
||||
BASE_DIR=${HUATUO_IL2CPP_SOURCE_DIR}/libil2cpp
|
||||
echo base dir: ${BASE_DIR}
|
||||
echo " "
|
||||
#BASE_DIR=${HUATUO_IL2CPP_SOURCE_DIR}/libil2cpp
|
||||
function SearchCppFile()
|
||||
{
|
||||
for f in $(ls $1)
|
||||
do
|
||||
SUB_DIR=$1/$f
|
||||
if [ -d ${SUB_DIR} ]; then
|
||||
SearchCppFile ${SUB_DIR}
|
||||
fi
|
||||
done
|
||||
|
||||
CPP_FILE_NUM=`ls -l $1/ | grep "\.cpp$"|wc -l`
|
||||
if (( ${CPP_FILE_NUM} > 0 ))
|
||||
then
|
||||
for f in $1/*.cpp
|
||||
do
|
||||
echo "#include \""$f"\"" >> ${OUTPUT_FILE_NAME}
|
||||
done
|
||||
fi
|
||||
|
||||
MM_FILE_NUM=`ls -l $1/ | grep "\.mm$"|wc -l`
|
||||
if (( ${MM_FILE_NUM} > 0 ))
|
||||
then
|
||||
for f in $1/*.mm
|
||||
do
|
||||
echo "#include \""$f"\"" >> ${OBJECTIVE_FILE_NAME}
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
rm -rf "${GEN_SOURCE_DIR}"/lump_cpp
|
||||
rm -rf "${GEN_SOURCE_DIR}"/lump_mm
|
||||
mkdir "${GEN_SOURCE_DIR}"/lump_cpp
|
||||
mkdir "${GEN_SOURCE_DIR}"/lump_mm
|
||||
|
||||
OBJECTIVE_FILE_NAME=${GEN_SOURCE_DIR}/lump_mm/lump_libil2cpp_ojective.mm
|
||||
echo "#include \"${BASE_DIR}/il2cpp-config.h\"" > ${OBJECTIVE_FILE_NAME}
|
||||
echo gen file: ${OBJECTIVE_FILE_NAME}
|
||||
|
||||
for FOLDER in hybridclr vm pch utils vm-utils codegen metadata os debugger mono gc icalls
|
||||
do
|
||||
OUTPUT_FILE_NAME=${GEN_SOURCE_DIR}/lump_cpp/lump_libil2cpp_${FOLDER}.cpp
|
||||
echo "#include \"${BASE_DIR}/il2cpp-config.h\"" > ${OUTPUT_FILE_NAME}
|
||||
if [ $FOLDER = hybridclr ] || [ $FOLDER = vm ]
|
||||
then
|
||||
echo "#include \"${BASE_DIR}/codegen/il2cpp-codegen.h\"" >> ${OUTPUT_FILE_NAME}
|
||||
fi
|
||||
SearchCppFile ${BASE_DIR}/${FOLDER}
|
||||
echo gen file: ${OUTPUT_FILE_NAME}
|
||||
done
|
||||
|
||||
echo gen done.
|
||||
echo '====================================================================='
|
||||
echo " "
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# file: CMakeList.txt
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET iOS)
|
||||
project(il2cpp)
|
||||
|
||||
set(IL2CPP_SOURCE_DIR $ENV{HUATUO_IL2CPP_SOURCE_DIR})
|
||||
set(SDK_VERSION $ENV{IPHONESIMULATOR_VERSION})
|
||||
|
||||
message(STATUS "objective project, binary dir: " ${PROJECT_BINARY_DIR})
|
||||
message(STATUS "objective project, il2cpp source dir: " ${PROJECT_SOURCE_DIR})
|
||||
|
||||
|
||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
find_program(CLANG_EXECUTABLE NAMES clang clang-7 clang-8 clang-9 clang-10)
|
||||
if (NOT CLANG_EXECUTABLE)
|
||||
message(FATAL_ERROR "Cannot find any clang executable.")
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
#add_compile_options(-x objective-c++)
|
||||
|
||||
# 以下命令为复制的Xcode生成中的命令
|
||||
set(CMAKE_CXX_FLAGS "-target arm64-apple-ios11.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++1z -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fmodules-ignore-macro=IL2CPP_TARGET_IOS=1 -fembed-bitcode -fmodules-ignore-macro=BASELIB_DYNAMICLIBRARY=1 -fmodules-ignore-macro=BASELIB_INLINE_NAMESPACE=il2cpp_baselib -fmodules-ignore-macro=AARCH64 -fmodules-ignore-macro=__aarch64__ -fmodules-ignore-macro=IL2CPP_SUPPORT_THREADS -fmodules-ignore-macro=IL2CPP_THREADS_PTHREAD -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DIL2CPP_TARGET_IOS=1 -isysroot ${SDK_VERSION} -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability ")
|
||||
|
||||
|
||||
add_definitions(-DIL2CPP_TARGET_IOS=1)
|
||||
add_definitions(-DBASELIB_DYNAMICLIBRARY=1)
|
||||
add_definitions(-DBASELIB_INLINE_NAMESPACE=il2cpp_baselib)
|
||||
add_definitions(-DAARCH64)
|
||||
add_definitions(-D__aarch64__)
|
||||
add_definitions(-DIL2CPP_SUPPORT_THREADS)
|
||||
add_definitions(-DIL2CPP_THREADS_PTHREAD)
|
||||
#add_definitions(-DCMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
||||
#add_definitions(-DCMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++)
|
||||
#add_definitions(-DIL2CPP_TARGET_DARWIN)
|
||||
add_definitions(-DIL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO)
|
||||
|
||||
add_definitions(-MMD)
|
||||
add_definitions(-MT dependencies)
|
||||
|
||||
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/libil2cpp)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/bdwgc/include/)
|
||||
include_directories(${IL2CPP_SOURCE_DIR}/external/baselib/Platforms/OSX/Include/)
|
||||
|
||||
# 修改为本机对应SDK路径
|
||||
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/v1)
|
||||
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include)
|
||||
|
||||
get_filename_component(PARENT_PATH ${PROJECT_BINARY_DIR} PATH)
|
||||
aux_source_directory(${PARENT_PATH}/lump_mm LUMP_SOURCE_LIST)
|
||||
|
||||
#find_library(zlib ${PROJECT_SOURCE_DIR}/external)
|
||||
add_library(objective STATIC ${LUMP_SOURCE_LIST})
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59ab7ccacd9a9944bb9456da235d6760
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -19,8 +19,6 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public override bool IsArch32 => false;
|
||||
|
||||
public override bool IsSupportHFA => true;
|
||||
|
||||
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
|
||||
{
|
||||
if (!type.IsGeneralValueType)
|
||||
@@ -42,5 +40,99 @@ namespace HybridCLR.Editor.ABI
|
||||
}
|
||||
return TypeInfo.s_ref;
|
||||
}
|
||||
|
||||
|
||||
private static bool IsNotHFAFastCheck(int typeSize)
|
||||
{
|
||||
return typeSize % 4 != 0 || typeSize > 32;
|
||||
}
|
||||
|
||||
private static bool ComputHFATypeInfo0(TypeSig type, HFATypeInfo typeInfo)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
|
||||
List<TypeSig> klassInst = type.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (FieldDef field in fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TypeSig ftype = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
switch (ftype.ElementType)
|
||||
{
|
||||
case ElementType.R4:
|
||||
case ElementType.R8:
|
||||
{
|
||||
if (ftype == typeInfo.Type || typeInfo.Type == null)
|
||||
{
|
||||
typeInfo.Type = ftype;
|
||||
++typeInfo.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
if (!ComputHFATypeInfo0(ftype, typeInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
if (!ftype.IsValueType || !ComputHFATypeInfo0(ftype, typeInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return typeInfo.Count <= 4;
|
||||
}
|
||||
|
||||
private static bool ComputHFATypeInfo(TypeSig type, int typeSize, out HFATypeInfo typeInfo)
|
||||
{
|
||||
typeInfo = new HFATypeInfo();
|
||||
if (IsNotHFAFastCheck(typeSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = ComputHFATypeInfo0(type, typeInfo);
|
||||
if (ok && typeInfo.Count >= 1 && typeInfo.Count <= 4)
|
||||
{
|
||||
int fieldSize = typeInfo.Type.ElementType == ElementType.R4 ? 4 : 8;
|
||||
return typeSize == fieldSize * typeInfo.Count;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool TryCreateCustomValueTypeInfo(TypeSig type, int typeSize, int typeAligment, out TypeInfo typeInfo)
|
||||
{
|
||||
if (ComputHFATypeInfo(type, typeSize, out HFATypeInfo hfaTypeInfo))
|
||||
{
|
||||
bool isFloat = hfaTypeInfo.Type.ElementType == ElementType.R4;
|
||||
switch (hfaTypeInfo.Count)
|
||||
{
|
||||
case 1: typeInfo = isFloat ? TypeInfo.s_r4 : TypeInfo.s_r8; break;
|
||||
case 2: typeInfo = isFloat ? TypeInfo.s_vf2 : TypeInfo.s_vd2; break;
|
||||
case 3: typeInfo = isFloat ? TypeInfo.s_vf3 : TypeInfo.s_vd3; break;
|
||||
case 4: typeInfo = isFloat ? TypeInfo.s_vf4 : TypeInfo.s_vd4; break;
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
typeInfo = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-194
@@ -13,10 +13,6 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public abstract bool IsArch32 { get; }
|
||||
|
||||
public virtual bool IsSupportHFA => false;
|
||||
|
||||
public virtual bool IsSupportWebGLSpecialValueType => false;
|
||||
|
||||
public TypeInfo GetNativeIntTypeInfo() => IsArch32 ? TypeInfo.s_i4 : TypeInfo.s_i8;
|
||||
|
||||
public ValueTypeSizeAligmentCalculator Calculator => IsArch32 ? ValueTypeSizeAligmentCalculator.Caculator32 : ValueTypeSizeAligmentCalculator.Caculator64;
|
||||
@@ -24,6 +20,9 @@ namespace HybridCLR.Editor.ABI
|
||||
|
||||
private readonly Dictionary<TypeSig, (int, int)> _typeSizeCache = new Dictionary<TypeSig, (int, int)>(TypeEqualityComparer.Instance);
|
||||
|
||||
|
||||
private readonly Dictionary<TypeSig, TypeInfo> _typeInfoCache = new Dictionary<TypeSig, TypeInfo>(TypeEqualityComparer.Instance);
|
||||
|
||||
public (int Size, int Aligment) ComputeSizeAndAligment(TypeSig t)
|
||||
{
|
||||
if (_typeSizeCache.TryGetValue(t, out var sizeAndAligment))
|
||||
@@ -36,6 +35,16 @@ namespace HybridCLR.Editor.ABI
|
||||
}
|
||||
|
||||
public TypeInfo CreateTypeInfo(TypeSig type)
|
||||
{
|
||||
if (!_typeInfoCache.TryGetValue(type, out var typeInfo))
|
||||
{
|
||||
typeInfo = CreateTypeInfo0(type);
|
||||
_typeInfoCache.Add(type, typeInfo);
|
||||
}
|
||||
return new TypeInfo(typeInfo.PorType, typeInfo.Size);
|
||||
}
|
||||
|
||||
TypeInfo CreateTypeInfo0(TypeSig type)
|
||||
{
|
||||
type = type.RemovePinnedAndModifiers();
|
||||
if (type.IsByRef)
|
||||
@@ -103,175 +112,6 @@ namespace HybridCLR.Editor.ABI
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsNotHFAFastCheck(int typeSize)
|
||||
{
|
||||
return typeSize % 4 != 0 || typeSize > 32;
|
||||
}
|
||||
|
||||
private static bool ComputHFATypeInfo0(TypeSig type, HFATypeInfo typeInfo)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
|
||||
List<TypeSig> klassInst = type.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (FieldDef field in fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TypeSig ftype = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
switch (ftype.ElementType)
|
||||
{
|
||||
case ElementType.R4:
|
||||
case ElementType.R8:
|
||||
{
|
||||
if (ftype == typeInfo.Type || typeInfo.Type == null)
|
||||
{
|
||||
typeInfo.Type = ftype;
|
||||
++typeInfo.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
if (!ComputHFATypeInfo0(ftype, typeInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
if (!ftype.IsValueType || !ComputHFATypeInfo0(ftype, typeInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return typeInfo.Count <= 4;
|
||||
}
|
||||
|
||||
private static bool ComputHFATypeInfo(TypeSig type, int typeSize, out HFATypeInfo typeInfo)
|
||||
{
|
||||
typeInfo = new HFATypeInfo();
|
||||
if (IsNotHFAFastCheck(typeSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = ComputHFATypeInfo0(type, typeInfo);
|
||||
if (ok && typeInfo.Count >= 1 && typeInfo.Count <= 4)
|
||||
{
|
||||
int fieldSize = typeInfo.Type.ElementType == ElementType.R4 ? 4 : 8;
|
||||
return typeSize == fieldSize * typeInfo.Count;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool TryComputSingletonStruct(TypeSig type, out SingletonStruct result)
|
||||
{
|
||||
result = new SingletonStruct();
|
||||
return TryComputSingletonStruct0(type, result) && result.Type != null;
|
||||
}
|
||||
|
||||
public static bool TryComputSingletonStruct0(TypeSig type, SingletonStruct result)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
if (result.Type == null)
|
||||
{
|
||||
result.Type = typeDef.GetEnumUnderlyingType();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
List<TypeSig> klassInst = type.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (FieldDef field in fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TypeSig ftype = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
|
||||
switch (ftype.ElementType)
|
||||
{
|
||||
case ElementType.TypedByRef: return false;
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
if (!TryComputSingletonStruct0(ftype, result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
if (!ftype.IsValueType)
|
||||
{
|
||||
goto default;
|
||||
}
|
||||
if (!TryComputSingletonStruct0(ftype, result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (result.Type != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result.Type = ftype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsWebGLSpeicalValueType(TypeSig type)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (fields.Count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (fields.All(f => f.IsStatic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (typeDef.IsExplicitLayout && fields.Count(f => !f.IsStatic) > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static TypeInfo CreateGeneralValueType(TypeSig type, int size, int aligment)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(size % aligment == 0);
|
||||
@@ -285,31 +125,19 @@ namespace HybridCLR.Editor.ABI
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool TryCreateCustomValueTypeInfo(TypeSig type, int typeSize, int typeAligment, out TypeInfo typeInfo)
|
||||
{
|
||||
typeInfo = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected TypeInfo CreateValueType(TypeSig type)
|
||||
{
|
||||
(int typeSize, int typeAligment) = ComputeSizeAndAligment(type);
|
||||
if (IsSupportHFA && ComputHFATypeInfo(type, typeSize, out HFATypeInfo hfaTypeInfo))
|
||||
if (TryCreateCustomValueTypeInfo(type, typeSize, typeAligment, out var typeInfo))
|
||||
{
|
||||
bool isFloat = hfaTypeInfo.Type.ElementType == ElementType.R4;
|
||||
switch (hfaTypeInfo.Count)
|
||||
{
|
||||
case 1: return isFloat ? TypeInfo.s_r4 : TypeInfo.s_r8;
|
||||
case 2: return isFloat ? TypeInfo.s_vf2 : TypeInfo.s_vd2;
|
||||
case 3: return isFloat ? TypeInfo.s_vf3 : TypeInfo.s_vd3;
|
||||
case 4: return isFloat ? TypeInfo.s_vf4 : TypeInfo.s_vd4;
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
if (IsSupportWebGLSpecialValueType && IsWebGLSpeicalValueType(type))
|
||||
{
|
||||
switch (typeAligment)
|
||||
{
|
||||
case 1: return new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN1, typeSize);
|
||||
case 2: return new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN2, typeSize);
|
||||
case 4: return new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN4, typeSize);
|
||||
case 8: return new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN8, typeSize);
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
//Debug.Log($"[{GetType().Name}] CustomeValueType:{type} => {typeInfo.CreateSigName()}");
|
||||
return typeInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public override bool IsArch32 => true;
|
||||
|
||||
public override bool IsSupportHFA => false;
|
||||
|
||||
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
|
||||
{
|
||||
if (type.PorType > ParamOrReturnType.STRUCTURE_ALIGN1 && type.PorType <= ParamOrReturnType.STRUCTURE_ALIGN4)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -10,8 +11,6 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public override bool IsArch32 => false;
|
||||
|
||||
public override bool IsSupportHFA => false;
|
||||
|
||||
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
|
||||
{
|
||||
if (type.PorType > ParamOrReturnType.STRUCTURE_ALIGN1 && type.PorType <= ParamOrReturnType.STRUCTURE_ALIGN8)
|
||||
|
||||
@@ -17,11 +17,6 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public override bool IsArch32 => true;
|
||||
|
||||
public override bool IsSupportHFA => false;
|
||||
|
||||
public override bool IsSupportWebGLSpecialValueType => true;
|
||||
|
||||
|
||||
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
|
||||
{
|
||||
//if (type.PorType > ParamOrReturnType.STRUCTURE_ALIGN1 && type.PorType <= ParamOrReturnType.STRUCTURE_ALIGN4)
|
||||
@@ -30,5 +25,196 @@ namespace HybridCLR.Editor.ABI
|
||||
//}
|
||||
return type;
|
||||
}
|
||||
|
||||
private static bool IsEmptyOrSpeicalValueType(TypeSig type)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (fields.Count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (fields.All(f => f.IsStatic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (typeDef.IsExplicitLayout && fields.Count(f => !f.IsStatic) > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool TryComputSingletonStructTypeInfo(TypeSig type, int typeAligment, int typeSize, out TypeInfo typeInfo)
|
||||
{
|
||||
typeInfo = null;
|
||||
if (typeAligment > 8 || typeSize > 8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ss = new SingletonStruct();
|
||||
if (!TryComputSingletonStruct0(type, ss) || ss.Type == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ss.Type.IsByRef)
|
||||
{
|
||||
typeInfo = TypeInfo.s_i4;
|
||||
return true;
|
||||
}
|
||||
switch (ss.Type.ElementType)
|
||||
{
|
||||
case ElementType.Boolean:
|
||||
case ElementType.Char:
|
||||
case ElementType.I1:
|
||||
case ElementType.U1:
|
||||
case ElementType.I2:
|
||||
case ElementType.U2:
|
||||
case ElementType.I4:
|
||||
case ElementType.U4:
|
||||
case ElementType.I:
|
||||
case ElementType.U:
|
||||
case ElementType.String:
|
||||
case ElementType.Ptr:
|
||||
case ElementType.Class:
|
||||
case ElementType.Array:
|
||||
case ElementType.GenericInst:
|
||||
case ElementType.FnPtr:
|
||||
case ElementType.Object:
|
||||
case ElementType.SZArray:
|
||||
{
|
||||
if (typeAligment <= 4 && typeSize <= 4)
|
||||
{
|
||||
typeInfo = TypeInfo.s_i4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.I8:
|
||||
case ElementType.U8:
|
||||
{
|
||||
if (typeAligment <= 8 && typeSize <= 8)
|
||||
{
|
||||
typeInfo = TypeInfo.s_i8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.R4:
|
||||
{
|
||||
if (typeAligment <= 4 && typeSize <= 4)
|
||||
{
|
||||
typeInfo = TypeInfo.s_r4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.R8:
|
||||
{
|
||||
if (typeAligment <= 8 && typeSize <= 8)
|
||||
{
|
||||
typeInfo = TypeInfo.s_r8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
return typeInfo != null;
|
||||
}
|
||||
|
||||
public static bool TryComputSingletonStruct(TypeSig type, out SingletonStruct result)
|
||||
{
|
||||
result = new SingletonStruct();
|
||||
return TryComputSingletonStruct0(type, result) && result.Type != null;
|
||||
}
|
||||
|
||||
public static bool TryComputSingletonStruct0(TypeSig type, SingletonStruct result)
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
if (result.Type == null)
|
||||
{
|
||||
result.Type = typeDef.GetEnumUnderlyingType();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
List<TypeSig> klassInst = type.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
var fields = typeDef.Fields;// typeDef.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (FieldDef field in fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TypeSig ftype = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
|
||||
switch (ftype.ElementType)
|
||||
{
|
||||
case ElementType.TypedByRef: return false;
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
if (!TryComputSingletonStruct0(ftype, result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
if (!ftype.IsValueType)
|
||||
{
|
||||
goto default;
|
||||
}
|
||||
if (!TryComputSingletonStruct0(ftype, result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (result.Type != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result.Type = ftype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool TryCreateCustomValueTypeInfo(TypeSig type, int typeSize, int typeAligment, out TypeInfo typeInfo)
|
||||
{
|
||||
typeInfo = null;
|
||||
if (IsEmptyOrSpeicalValueType(type))
|
||||
{
|
||||
switch (typeAligment)
|
||||
{
|
||||
case 1: typeInfo = new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN1, typeSize); break;
|
||||
case 2: typeInfo = new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN2, typeSize); break;
|
||||
case 4: typeInfo = new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN4, typeSize); break;
|
||||
case 8: typeInfo = new TypeInfo(ParamOrReturnType.SPECIAL_STRUCTURE_ALIGN8, typeSize); break;
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (TryComputSingletonStructTypeInfo(type, typeAligment, typeSize, out typeInfo))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace HybridCLR.Editor.AOT
|
||||
return IsAotType(method.DeclaringType) && method.HasGenericParameters;
|
||||
}
|
||||
|
||||
private void OnNewMethod(GenericMethod method)
|
||||
private void OnNewMethod(MethodDef methodDef, List<TypeSig> klassGenericInst, List<TypeSig> methodGenericInst, GenericMethod method)
|
||||
{
|
||||
if(method == null)
|
||||
{
|
||||
|
||||
@@ -64,18 +64,22 @@ namespace HybridCLR.Editor.AOT
|
||||
Directory.CreateDirectory(parentDir);
|
||||
|
||||
List<string> codes = new List<string>();
|
||||
codes.Add("using System.Collections.Generic;");
|
||||
codes.Add("public class AOTGenericReferences : UnityEngine.MonoBehaviour");
|
||||
codes.Add("{");
|
||||
|
||||
codes.Add("");
|
||||
codes.Add("\t// {{ AOT assemblies");
|
||||
codes.Add("\tpublic static readonly IReadOnlyList<string> PatchedAOTAssemblyList = new List<string>");
|
||||
codes.Add("\t{");
|
||||
List<dnlib.DotNet.ModuleDef> modules = new HashSet<dnlib.DotNet.ModuleDef>(
|
||||
types.Select(t => t.Type.Module).Concat(methods.Select(m => m.Method.Module))).ToList();
|
||||
modules.Sort((a, b) => a.Name.CompareTo(b.Name));
|
||||
foreach (dnlib.DotNet.ModuleDef module in modules)
|
||||
{
|
||||
codes.Add($"\t// {module.Name}");
|
||||
codes.Add($"\t\t\"{module.Name}\",");
|
||||
}
|
||||
codes.Add("\t};");
|
||||
codes.Add("\t// }}");
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
#if (UNITY_2020 || UNITY_2021) && UNITY_IOS
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2021OrOlder
|
||||
{
|
||||
//[MenuItem("Test/GenProj")]
|
||||
//public static void Modify()
|
||||
//{
|
||||
// OnPostProcessBuild(BuildTarget.iOS, $"{SettingsUtil.ProjectDir}/Build-iOS");
|
||||
//}
|
||||
|
||||
//[MenuItem("Test/CreateLumps")]
|
||||
//public static void CreateLumpsCmd()
|
||||
//{
|
||||
// CreateLumps($"{SettingsUtil.LocalIl2CppDir}/libil2cpp", $"{SettingsUtil.HybridCLRDataDir}/lumps");
|
||||
//}
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS)
|
||||
return;
|
||||
|
||||
/*
|
||||
* 1. 生成lump,并且添加到工程
|
||||
3. 将libil2cpp目录复制到 Library/. 删除旧的. search paths里修改 libil2cpp/include为libil2cpp
|
||||
3. Libraries/bdwgc/include -> Libraries/external/bdwgc/include
|
||||
4. 将external目录复制到 Library/external。删除旧目录
|
||||
5. 将Library/external/baselib/Platforms/OSX改名为 IOS 全大写
|
||||
6. 将 external/zlib下c 文件添加到工程
|
||||
7. 移除libil2cpp.a
|
||||
8. Include path add libil2cpp/os/ClassLibraryPAL/brotli/include
|
||||
9. add external/xxHash
|
||||
*/
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string dstLibil2cppDir = $"{pathToBuiltProject}/Libraries/libil2cpp";
|
||||
string lumpDir = $"{pathToBuiltProject}/Libraries/lumps";
|
||||
string srcExternalDir = $"{SettingsUtil.LocalIl2CppDir}/external";
|
||||
string dstExternalDir = $"{pathToBuiltProject}/Libraries/external";
|
||||
//RemoveExternalLibil2cppOption(srcExternalDir, dstExternalDir);
|
||||
CopyLibil2cppToXcodeProj(srcLibil2cppDir, dstLibil2cppDir);
|
||||
CopyExternalToXcodeProj(srcExternalDir, dstExternalDir);
|
||||
var lumpFiles = CreateLumps(dstLibil2cppDir, lumpDir);
|
||||
var extraSources = GetExtraSourceFiles(dstExternalDir);
|
||||
var cflags = new List<string>()
|
||||
{
|
||||
"-DIL2CPP_MONO_DEBUGGER_DISABLED",
|
||||
};
|
||||
ModifyPBXProject(pathToBuiltProject, pbxprojFile, lumpFiles, extraSources, cflags);
|
||||
}
|
||||
|
||||
private static void ModifyPBXProject(string pathToBuiltProject, string pbxprojFile, List<LumpFile> lumpFiles, List<string> extraFiles, List<string> cflags)
|
||||
{
|
||||
var proj = new PBXProject();
|
||||
proj.ReadFromFile(pbxprojFile);
|
||||
string targetGUID = proj.GetUnityFrameworkTargetGuid();
|
||||
// 移除旧的libil2cpp.a
|
||||
var libil2cppGUID = proj.FindFileGuidByProjectPath("Libraries/libil2cpp.a");
|
||||
if (!string.IsNullOrEmpty(libil2cppGUID))
|
||||
{
|
||||
proj.RemoveFileFromBuild(targetGUID, libil2cppGUID);
|
||||
proj.RemoveFile(libil2cppGUID);
|
||||
File.Delete(Path.Combine(pathToBuiltProject, "Libraries", "libil2cpp.a"));
|
||||
}
|
||||
|
||||
//var lumpGroupGuid = proj.AddFile("Lumps", $"Classes/Lumps", PBXSourceTree.Group);
|
||||
|
||||
foreach (var lumpFile in lumpFiles)
|
||||
{
|
||||
string projPathOfFile = $"Classes/Lumps/{Path.GetFileName(lumpFile.lumpFile)}";
|
||||
string lumpGuid = proj.FindFileGuidByProjectPath(projPathOfFile);
|
||||
if (!string.IsNullOrEmpty(lumpGuid))
|
||||
{
|
||||
proj.RemoveFileFromBuild(targetGUID, lumpGuid);
|
||||
proj.RemoveFile(lumpGuid);
|
||||
}
|
||||
lumpGuid = proj.AddFile(lumpFile.lumpFile, projPathOfFile, PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(targetGUID, lumpGuid);
|
||||
}
|
||||
|
||||
foreach (var extraFile in extraFiles)
|
||||
{
|
||||
string projPathOfFile = $"Classes/Extrals/{Path.GetFileName(extraFile)}";
|
||||
string extraFileGuid = proj.FindFileGuidByProjectPath(projPathOfFile);
|
||||
if (!string.IsNullOrEmpty(extraFileGuid))
|
||||
{
|
||||
proj.RemoveFileFromBuild(targetGUID, extraFileGuid);
|
||||
proj.RemoveFile(extraFileGuid);
|
||||
//Debug.LogWarning($"remove exist extra file:{projPathOfFile} guid:{extraFileGuid}");
|
||||
}
|
||||
var lumpGuid = proj.AddFile(extraFile, projPathOfFile, PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(targetGUID, lumpGuid);
|
||||
}
|
||||
|
||||
foreach(var configName in proj.BuildConfigNames())
|
||||
{
|
||||
//Debug.Log($"build config:{bcn}");
|
||||
string configGuid = proj.BuildConfigByName(targetGUID, configName);
|
||||
string headerSearchPaths = "HEADER_SEARCH_PATHS";
|
||||
string hspProp = proj.GetBuildPropertyForConfig(configGuid, headerSearchPaths);
|
||||
//Debug.Log($"config guid:{configGuid} prop:{hspProp}");
|
||||
string newPro = hspProp.Replace("libil2cpp/include", "libil2cpp")
|
||||
.Replace("Libraries/bdwgc", "Libraries/external/bdwgc");
|
||||
|
||||
if (!newPro.Contains("Libraries/libil2cpp/os/ClassLibraryPAL/brotli/include"))
|
||||
{
|
||||
newPro += " $(SRCROOT)/Libraries/libil2cpp/os/ClassLibraryPAL/brotli/include";
|
||||
}
|
||||
if (!newPro.Contains("Libraries/external/xxHash"))
|
||||
{
|
||||
newPro += " $(SRCROOT)/Libraries/external/xxHash";
|
||||
}
|
||||
//Debug.Log($"config:{bcn} new prop:{newPro}");
|
||||
proj.SetBuildPropertyForConfig(configGuid, headerSearchPaths, newPro);
|
||||
|
||||
string cflagKey = "OTHER_CFLAGS";
|
||||
string cfProp = proj.GetBuildPropertyForConfig(configGuid, cflagKey);
|
||||
foreach (var flag in cflags)
|
||||
{
|
||||
if (!cfProp.Contains(flag))
|
||||
{
|
||||
cfProp += " " + flag;
|
||||
}
|
||||
}
|
||||
if (configName.Contains("Debug") && !cfProp.Contains("-DIL2CPP_DEBUG="))
|
||||
{
|
||||
cfProp += " -DIL2CPP_DEBUG=1 -DDEBUG=1";
|
||||
}
|
||||
proj.SetBuildPropertyForConfig(configGuid, cflagKey, cfProp);
|
||||
|
||||
}
|
||||
proj.WriteToFile(pbxprojFile);
|
||||
}
|
||||
|
||||
private static void CopyLibil2cppToXcodeProj(string srcLibil2cppDir, string dstLibil2cppDir)
|
||||
{
|
||||
BashUtil.RemoveDir(dstLibil2cppDir);
|
||||
BashUtil.CopyDir(srcLibil2cppDir, dstLibil2cppDir, true);
|
||||
}
|
||||
|
||||
|
||||
private static void CopyExternalToXcodeProj(string srcExternalDir, string dstExternalDir)
|
||||
{
|
||||
BashUtil.RemoveDir(dstExternalDir);
|
||||
BashUtil.CopyDir(srcExternalDir, dstExternalDir, true);
|
||||
|
||||
string baselibPlatfromsDir = $"{dstExternalDir}/baselib/Platforms";
|
||||
BashUtil.RemoveDir($"{baselibPlatfromsDir}/IOS");
|
||||
BashUtil.CopyDir($"{baselibPlatfromsDir}/OSX", $"{baselibPlatfromsDir}/IOS", true);
|
||||
}
|
||||
|
||||
class LumpFile
|
||||
{
|
||||
public List<string> cppFiles = new List<string>();
|
||||
|
||||
public readonly string lumpFile;
|
||||
|
||||
public readonly string il2cppConfigFile;
|
||||
|
||||
public LumpFile(string lumpFile, string il2cppConfigFile)
|
||||
{
|
||||
this.lumpFile = lumpFile;
|
||||
this.il2cppConfigFile = il2cppConfigFile;
|
||||
this.cppFiles.Add(il2cppConfigFile);
|
||||
}
|
||||
|
||||
public void SaveFile()
|
||||
{
|
||||
var lumpFileContent = new List<string>();
|
||||
foreach (var file in cppFiles)
|
||||
{
|
||||
lumpFileContent.Add($"#include \"{file}\"");
|
||||
}
|
||||
File.WriteAllLines(lumpFile, lumpFileContent, Encoding.UTF8);
|
||||
Debug.Log($"create lump file:{lumpFile}");
|
||||
}
|
||||
}
|
||||
|
||||
private static List<LumpFile> CreateLumps(string libil2cppDir, string outputDir)
|
||||
{
|
||||
BashUtil.RecreateDir(outputDir);
|
||||
var cppFiles = Directory.GetFiles(libil2cppDir, "*.cpp", SearchOption.AllDirectories);
|
||||
int maxCppFilePerLump = 50;
|
||||
string il2cppConfigFile = $"{libil2cppDir}/il2cpp-config.h";
|
||||
var lumpFiles = new List<LumpFile>();
|
||||
for (int i = 0; i < (cppFiles.Length + maxCppFilePerLump - 1) / maxCppFilePerLump; i++)
|
||||
{
|
||||
var lumpFile = new LumpFile($"{outputDir}/lump_{i}.cpp", il2cppConfigFile);
|
||||
for (int j = 0; j < maxCppFilePerLump; j++)
|
||||
{
|
||||
int index = i * maxCppFilePerLump + j;
|
||||
if (index >= cppFiles.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
lumpFile.cppFiles.Add(cppFiles[index]);
|
||||
}
|
||||
lumpFile.SaveFile();
|
||||
lumpFiles.Add(lumpFile);
|
||||
}
|
||||
|
||||
var mmFiles = Directory.GetFiles(libil2cppDir, "*.mm", SearchOption.AllDirectories);
|
||||
if (mmFiles.Length > 0)
|
||||
{
|
||||
var lumpFile = new LumpFile($"{outputDir}/lump_mm.mm", il2cppConfigFile);
|
||||
foreach (var file in mmFiles)
|
||||
{
|
||||
lumpFile.cppFiles.Add(file);
|
||||
}
|
||||
lumpFile.SaveFile();
|
||||
lumpFiles.Add(lumpFile);
|
||||
}
|
||||
return lumpFiles;
|
||||
}
|
||||
|
||||
private static List<string> GetExtraSourceFiles(string externalDir)
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(Directory.GetFiles($"{externalDir}/zlib", "*.c"));
|
||||
files.Add($"{externalDir}/xxHash/xxhash.c");
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61948fcb1bc40ba47b8c10b0ae801ebb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2022_2_OR_NEWER && UNITY_IOS
|
||||
|
||||
namespace HybridCLR.Editor
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer
|
||||
{
|
||||
//[MenuItem("HybridCLR/Modfiyxcode")]
|
||||
//public static void Modify()
|
||||
//{
|
||||
// OnPostProcessBuild(BuildTarget.iOS, $"{SettingsUtil.ProjectDir}/Build-iOS");
|
||||
//}
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS)
|
||||
return;
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
RemoveExternalLibil2cppOption(pbxprojFile);
|
||||
CopyLibil2cppToXcodeProj(pathToBuiltProject);
|
||||
}
|
||||
|
||||
private static void RemoveExternalLibil2cppOption(string pbxprojFile)
|
||||
{
|
||||
string pbxprojContent = File.ReadAllText(pbxprojFile, Encoding.UTF8);
|
||||
string removeBuildOption = @"--external-lib-il2-cpp=\""$PROJECT_DIR/Libraries/libil2cpp.a\""";
|
||||
if (!pbxprojContent.Contains(removeBuildOption))
|
||||
{
|
||||
//throw new BuildFailedException("modified project.pbxproj fail");
|
||||
Debug.LogError("[AddLil2cppSourceCodeToXcodeproj] modified project.pbxproj fail");
|
||||
return;
|
||||
}
|
||||
pbxprojContent = pbxprojContent.Replace(removeBuildOption, "");
|
||||
File.WriteAllText(pbxprojFile, pbxprojContent, Encoding.UTF8);
|
||||
Debug.Log($"[AddLil2cppSourceCodeToXcodeproj] remove il2cpp build option '{removeBuildOption}' from file '{pbxprojFile}'");
|
||||
}
|
||||
|
||||
private static void CopyLibil2cppToXcodeProj(string pathToBuiltProject)
|
||||
{
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string destLibil2cppDir = $"{pathToBuiltProject}/Il2CppOutputProject/IL2CPP/libil2cpp";
|
||||
BashUtil.RemoveDir(destLibil2cppDir);
|
||||
BashUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4ce072f7e4a17248a3d9ebfd011356b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,7 +17,6 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
HybridCLRSettings globalSettings = SettingsUtil.HybridCLRSettings;
|
||||
#if !UNITY_2020_1_OR_NEWER || !UNITY_IOS
|
||||
if (!globalSettings.enable || globalSettings.useGlobalIl2cpp)
|
||||
{
|
||||
string oldIl2cppPath = Environment.GetEnvironmentVariable("UNITY_IL2CPP_PATH");
|
||||
@@ -36,7 +35,6 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
Debug.Log($"[CheckSettings] UNITY_IL2CPP_PATH 当前值为:'{curIl2cppPath}',更新为:'{SettingsUtil.LocalIl2CppDir}'");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!globalSettings.enable)
|
||||
{
|
||||
return;
|
||||
@@ -54,25 +52,11 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
Debug.LogError($"[CheckSettings] 当前ScriptingBackend是:{curScriptingImplementation},已经自动切换为:{targetScriptingImplementation}");
|
||||
PlayerSettings.SetScriptingBackend(buildTargetGroup, targetScriptingImplementation);
|
||||
}
|
||||
ApiCompatibilityLevel curApiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
ApiCompatibilityLevel targetApiCompatibilityLevel = ApiCompatibilityLevel.NET_Unity_4_8;
|
||||
#else
|
||||
ApiCompatibilityLevel targetApiCompatibilityLevel = ApiCompatibilityLevel.NET_4_6;
|
||||
#endif
|
||||
|
||||
|
||||
if (curApiCompatibilityLevel != targetApiCompatibilityLevel)
|
||||
{
|
||||
Debug.LogError($"[CheckSettings] 当前ApiCompatibilityLevel是:{curApiCompatibilityLevel},已经自动切换为 {targetApiCompatibilityLevel}。由于下一次打包才生效,主动打断本次打包。");
|
||||
PlayerSettings.SetApiCompatibilityLevel(buildTargetGroup, ApiCompatibilityLevel.NET_4_6);
|
||||
throw new BuildFailedException("ApiCompatibilityLevel error");
|
||||
}
|
||||
|
||||
var installer = new Installer.InstallerController();
|
||||
if (!installer.HasInstalledHybridCLR())
|
||||
{
|
||||
throw new Exception($"你没有初始化HybridCLR,请通过菜单'HybridCLR/Installer'安装");
|
||||
throw new BuildFailedException($"你没有初始化HybridCLR,请通过菜单'HybridCLR/Installer'安装");
|
||||
}
|
||||
|
||||
HybridCLRSettings gs = SettingsUtil.HybridCLRSettings;
|
||||
|
||||
@@ -25,10 +25,9 @@ namespace HybridCLR.Editor.Commands
|
||||
}
|
||||
Directory.CreateDirectory(buildDir);
|
||||
ScriptCompilationResult scriptCompilationResult = PlayerBuildInterface.CompilePlayerScripts(scriptCompilationSettings, buildDir);
|
||||
foreach (var ass in scriptCompilationResult.assemblies)
|
||||
{
|
||||
//Debug.LogFormat("compile assemblies:{1}/{0}", ass, buildDir);
|
||||
}
|
||||
#if UNITY_2022
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
#endif
|
||||
Debug.Log("compile finish!!!");
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace HybridCLR.Editor.Commands
|
||||
OutputFile = outputFile,
|
||||
GenericMethods = analyzer.GenericMethods,
|
||||
NotGenericMethods = analyzer.NotGenericMethods,
|
||||
SpeicalPreserveMethods = analyzer.SpeicalPreserveMethods,
|
||||
});
|
||||
|
||||
g.PrepareMethods();
|
||||
|
||||
@@ -6,6 +6,7 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Debug = UnityEngine.Debug;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
|
||||
namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
_curVersion = ParseUnityVersion(Application.unityVersion);
|
||||
_versionManifest = GetHybridCLRVersionManifest();
|
||||
_curDefaultVersion = _versionManifest.versions.Find(v => v.unity_version == _curVersion.major.ToString());
|
||||
_curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => v.unity_version == _curVersion.major.ToString());
|
||||
}
|
||||
|
||||
private HybridclrVersionManifest GetHybridCLRVersionManifest()
|
||||
@@ -74,6 +75,7 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)");
|
||||
|
||||
public const int min2020_3_CompatibleMinorVersion = 26;
|
||||
public const int min2021_3_CompatibleMinorVersion = 0;
|
||||
public const int min2022_3_CompatibleMinorVersion = 0;
|
||||
|
||||
@@ -111,22 +113,26 @@ namespace HybridCLR.Editor.Installer
|
||||
public bool IsComaptibleVersion()
|
||||
{
|
||||
UnityVersion version = _curVersion;
|
||||
if (version == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (version.minor1 != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (version.major)
|
||||
{
|
||||
case 2020:
|
||||
{
|
||||
return version.minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
}
|
||||
case 2021:
|
||||
{
|
||||
if (version.minor1 != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return version.minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
}
|
||||
case 2022:
|
||||
{
|
||||
if (version.minor1 != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return version.minor2 >= min2022_3_CompatibleMinorVersion;
|
||||
}
|
||||
default: throw new Exception($"not support il2cpp_plus branch:{version.major}");
|
||||
@@ -155,25 +161,6 @@ namespace HybridCLR.Editor.Installer
|
||||
return Directory.Exists($"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr");
|
||||
}
|
||||
|
||||
|
||||
private string GetUnityIl2CppDllInstallLocation()
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
return $"{SettingsUtil.LocalIl2CppDir}/build/deploy/net471/Unity.IL2CPP.dll";
|
||||
#else
|
||||
return $"{SettingsUtil.LocalIl2CppDir}/build/deploy/il2cppcore/Unity.IL2CPP.dll";
|
||||
#endif
|
||||
}
|
||||
|
||||
private string GetUnityIl2CppDllModifiedPath(string curVersionStr)
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
return $"{SettingsUtil.ProjectDir}/{SettingsUtil.HybridCLRDataPathInPackage}/ModifiedUnityAssemblies/{curVersionStr}/Unity.IL2CPP-Win.dll.bytes";
|
||||
#else
|
||||
return $"{SettingsUtil.ProjectDir}/{SettingsUtil.HybridCLRDataPathInPackage}/ModifiedUnityAssemblies/{curVersionStr}/Unity.IL2CPP-Mac.dll.bytes";
|
||||
#endif
|
||||
}
|
||||
|
||||
void CloneBranch(string workDir, string repoUrl, string branch, string repoDir)
|
||||
{
|
||||
BashUtil.RemoveDir(repoDir);
|
||||
@@ -224,12 +211,6 @@ namespace HybridCLR.Editor.Installer
|
||||
}
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
Directory.CreateDirectory(workDir);
|
||||
//BashUtil.RecreateDir(workDir);
|
||||
|
||||
string buildiOSDir = $"{workDir}/iOSBuild";
|
||||
BashUtil.RemoveDir(buildiOSDir);
|
||||
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
|
||||
|
||||
|
||||
// create LocalIl2Cpp
|
||||
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
||||
|
||||
@@ -48,24 +48,18 @@ namespace HybridCLR.Editor.Installer
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
||||
//GUILayout.Space(40f);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
if (_controller.IsComaptibleVersion())
|
||||
{
|
||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("与当前版本不兼容", MessageType.Error);
|
||||
}
|
||||
|
||||
//EditorGUILayout.BeginHorizontal();
|
||||
//EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或branch或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
|
||||
//_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
|
||||
//EditorGUILayout.EndHorizontal();
|
||||
|
||||
//EditorGUILayout.BeginHorizontal();
|
||||
//EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或branch或tag)(默认取{_controller.MajorVersion}-main分支最新版本):", GUILayout.MaxWidth(400));
|
||||
//_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
|
||||
//EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.ABI;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,11 +11,11 @@ namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class MethodReferenceAnalyzer
|
||||
{
|
||||
private readonly Action<GenericMethod> _onNewMethod;
|
||||
private readonly Action<MethodDef, List<TypeSig>, List<TypeSig>, GenericMethod> _onNewMethod;
|
||||
|
||||
private readonly ConcurrentDictionary<MethodDef, List<IMethod>> _methodEffectInsts = new ConcurrentDictionary<MethodDef, List<IMethod>>();
|
||||
|
||||
public MethodReferenceAnalyzer(Action<GenericMethod> onNewMethod)
|
||||
public MethodReferenceAnalyzer(Action<MethodDef, List<TypeSig>, List<TypeSig>, GenericMethod> onNewMethod)
|
||||
{
|
||||
_onNewMethod = onNewMethod;
|
||||
}
|
||||
@@ -37,7 +38,7 @@ namespace HybridCLR.Editor.Meta
|
||||
foreach (var met in effectInsts)
|
||||
{
|
||||
var resolveMet = GenericMethod.ResolveMethod(met, ctx)?.ToGenericShare();
|
||||
_onNewMethod(resolveMet);
|
||||
_onNewMethod(method, klassGenericInst, methodGenericInst, resolveMet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ namespace HybridCLR.Editor.Meta
|
||||
continue;
|
||||
}
|
||||
effectInsts.Add(met);
|
||||
_onNewMethod(resolveMet);
|
||||
_onNewMethod(method, klassGenericInst, methodGenericInst, resolveMet);
|
||||
break;
|
||||
}
|
||||
case ITokenOperand token:
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
private readonly HashSet<GenericClass> _genericTypes = new HashSet<GenericClass>();
|
||||
private readonly HashSet<GenericMethod> _genericMethods = new HashSet<GenericMethod>();
|
||||
|
||||
private readonly HashSet<GenericMethod> _speicalPreserveMethods = new HashSet<GenericMethod>();
|
||||
|
||||
private List<GenericMethod> _processingMethods = new List<GenericMethod>();
|
||||
private List<GenericMethod> _newMethods = new List<GenericMethod>();
|
||||
|
||||
@@ -37,6 +39,8 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
public IReadOnlyList<MethodDef> NotGenericMethods => _notGenericMethods;
|
||||
|
||||
public HashSet<GenericMethod> SpeicalPreserveMethods => _speicalPreserveMethods;
|
||||
|
||||
public IReadOnlyCollection<GenericClass> GenericTypes => _genericTypes;
|
||||
|
||||
public IReadOnlyCollection<GenericMethod> GenericMethods => _genericMethods;
|
||||
@@ -67,7 +71,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNewMethod(GenericMethod method)
|
||||
private void OnNewMethod(MethodDef methodDef, List<TypeSig> klassGenericInst, List<TypeSig> methodGenericInst, GenericMethod method)
|
||||
{
|
||||
lock(_lock)
|
||||
{
|
||||
@@ -75,6 +79,10 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
_newMethods.Add(method);
|
||||
}
|
||||
if (methodDef.HasGenericParameters)
|
||||
{
|
||||
_speicalPreserveMethods.Add(method);
|
||||
}
|
||||
if (method.KlassInst != null)
|
||||
{
|
||||
TryAddAndWalkGenericType(new GenericClass(method.Method.DeclaringType, method.KlassInst));
|
||||
|
||||
@@ -4,6 +4,7 @@ using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Editor.Template;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -28,6 +29,8 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
public IReadOnlyList<MethodDef> NotGenericMethods { get; set; }
|
||||
|
||||
public IReadOnlyCollection<GenericMethod> GenericMethods { get; set; }
|
||||
|
||||
public HashSet<GenericMethod> SpeicalPreserveMethods { get; set; }
|
||||
}
|
||||
|
||||
private PlatformABI _platformABI;
|
||||
@@ -36,6 +39,8 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private readonly IReadOnlyCollection<GenericMethod> _genericMethods;
|
||||
|
||||
private readonly HashSet<GenericMethod> _preservedMethods;
|
||||
|
||||
private readonly string _templateCode;
|
||||
|
||||
private readonly string _outputFile;
|
||||
@@ -61,6 +66,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
_platformABI = options.PlatformABI;
|
||||
_notGenericMethods = options.NotGenericMethods;
|
||||
_genericMethods = options.GenericMethods;
|
||||
_preservedMethods = options.SpeicalPreserveMethods;
|
||||
_templateCode = options.TemplateCode;
|
||||
_outputFile = options.OutputFile;
|
||||
_platformAdaptor = CreatePlatformAdaptor(options.PlatformABI);
|
||||
@@ -122,7 +128,14 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
if (method.IsPrivate || (method.IsAssembly && !method.IsPublic && !method.IsFamily))
|
||||
{
|
||||
return;
|
||||
if (!_preservedMethods.Contains(new GenericMethod(method, klassInst, methodInst)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log($"[PreservedMethod] method:{method}");
|
||||
}
|
||||
}
|
||||
|
||||
TypeSig returnType;
|
||||
|
||||
@@ -1,5 +1,40 @@
|
||||
# 发布日志
|
||||
|
||||
## 3.2.0
|
||||
|
||||
- [new] 支持直接从源码打包iOS,不再需要单独编译libil2cpp.a
|
||||
- [opt] 优化版本不兼容时错误提示,不再抛出异常,而是显示"与当前版本不兼容"
|
||||
- [fix] 修复未在PlaceHolder中的Assembly加载时,如果由于不在Assembly列表,也没有任何解释器栈,导致Class::resolve_parse_info_internal查找不到类型的bug
|
||||
- [fix] 修复读取CustomAttribute System.Type类型数据崩溃的bug
|
||||
|
||||
|
||||
## 3.1.1
|
||||
|
||||
- [fix] 修复 Win32、Android32、WebGL平台的编译错误
|
||||
- [fix] 修复计算桥接函数时未考虑到补充元数据泛型实例化会导致访问到一些非公开的函数的情况,导致少生成一些必要的桥接函数
|
||||
- [fix] 修复2021及更高版本,InterpreterModule::Managed2NativeCallByReflectionInvoke调用值类型成员函数时,对this指针多余this=this-1操作。
|
||||
- [fix] 修复解析CustomAttribute中Enum[]类型字段的bug
|
||||
- [fix] 修复2021及更高版本反射调用值类型 close Delegate的Invoke函数时未修复target指针的bug
|
||||
- [opt] 生成AOTGenericReferences时,补充元数据assembly列表由注释改成List<string>列表,方便在代码中直接使用。
|
||||
- [new] 新增对增量式GC宏的检查,避免build.gradle中意外开启增量式GC引发的极其隐蔽的问题
|
||||
- [change] CheckSettings中不再自动设置Api Compatible Level
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### 改动
|
||||
|
||||
- 还原对Unity 2020.3.x支持
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复 WebGL平台ABI的bug
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复Enum::GetValues返回值不正确的bug
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### 改动
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "3.0.2",
|
||||
"version": "3.2.0",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.",
|
||||
"category": "Runtime",
|
||||
|
||||
Reference in New Issue
Block a user