修改编译脚本

This commit is contained in:
JackLee 2026-02-22 23:58:51 +08:00
parent 664a6b536f
commit 970e87bb03
4 changed files with 23 additions and 22 deletions

View File

@ -4,7 +4,7 @@
"resOptions": {
"copyCodeResource": {
"enable": false
}
},
},
"externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt",
@ -25,6 +25,7 @@
"buildOptionSet": [
{
"name": "release",
"debuggable": true,
"arkOptions": {
"obfuscation": {
"ruleOptions": {

View File

@ -12,8 +12,8 @@ include_directories(${NATIVERENDER_ROOT_PATH}
)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_RPATH_USE_ORIGIN "\${ORIGIN}")
set(CMAKE_INSTALL_RPATH "\${ORIGIN}")
# OCCT
@ -26,12 +26,7 @@ set(OCCT_CORE_LIBS
TKDESTEP TKShHealing TKHLR TKVCAF TKBO TKPrim TKBool TKDE TKXSBase
)
foreach(LIB_NAME ${OCCT_CORE_LIBS})
add_library(occt_${LIB_NAME} SHARED IMPORTED)
set_target_properties(occt_${LIB_NAME} PROPERTIES
IMPORTED_LOCATION ${OCCT_LIB_DIR}/lib${LIB_NAME}.so.${OCCT_VERSION}
IMPORTED_SONAME lib${LIB_NAME}.so.${OCCT_VERSION}
)
list(APPEND OCCT_IMPORTED_LIBS occt_${LIB_NAME})
list(APPEND OCCT_IMPORTED_LIBS ${OCCT_LIB_DIR}/lib${LIB_NAME}.so.${OCCT_VERSION})
endforeach()
#THIRD_PARTY_LIBS
@ -56,27 +51,24 @@ add_library(opencax SHARED
EGLCore/EGLCore.cpp
OCCTRender/OCCTRender.cpp
OCCTRenderThread/OCCTRenderThread.cpp
napi_init.cpp
)
#
find_library(EGL-lib EGL)
find_library(GLES-lib GLESv3)
find_library(hilog-lib hilog_ndk.z)
find_library(libace-lib ace_ndk.z)
find_library(libuv-lib uv)
#System so
set(SYSTEM_LIBS
libace_napi.z.so libnative_window.so
hilog_ndk.z ace_ndk.z uv
)
#
target_link_libraries(opencax PUBLIC ${SYSTEM_LIBS})
target_link_libraries(opencax PUBLIC
# EGL Hilog
${EGL-lib}
${GLES-lib}
${hilog-lib}
${libace-lib}
${libuv-lib}
libnative_window.so
libace_napi.z.so
#OCCT
${OCCT_IMPORTED_LIBS}
${THIRD_PARTY_LIBS}

View File

@ -142,8 +142,8 @@ static napi_module OpenCAXModel = {
.reserved = { 0 }
};
extern "C" __attribute__((constructor))
void RegisterOpenCAXModule(void)
{
napi_module_register(&OpenCAXModel);
}
//extern "C" __attribute__((constructor))
//void RegisterOpenCAXModule(void)
//{
// napi_module_register(&OpenCAXModel);
//}

View File

@ -73,6 +73,14 @@ export struct ModelView {
Button('测试模块加载').onClick(async()=>{
this.loadNativeLibrary();
})
Button('测试so是否存在').onClick(()=>{
try {
fs.accessSync('libs/x86_64/libopencax.so');
console.info("动态库存在!");
} catch (e) {
console.error("动态库不存在!");
}
})
}
XComponent({
id: this.displayContrId,