refactor: enhance Android build scripts with dynamic example discovery and configurable ABI, and correct LLM SDK path.
This commit is contained in:
parent
194e4b6b18
commit
72e0647351
4 changed files with 92 additions and 31 deletions
|
|
@ -3,14 +3,16 @@ cmake_minimum_required(VERSION 3.5.1)
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
project(AML_LLM_NNSDK)
|
||||
|
||||
# xinxin, 后面yocto的编so的时候,如果用的cmake的话,可以把这些cmakelist.txt里面指定sysroot的都去掉,
|
||||
# 然后用官方推荐的方式,source完之后它会增加很多环境变量,你可以export命令看一下,后续cmake根据环境变量自己会配置,就不用再cmakelist里面配置了
|
||||
# xinxin, when building the .so with Yocto using CMake, you can remove the sysroot settings
|
||||
# from these CMakeLists.txt files and use the officially recommended approach instead:
|
||||
# after sourcing the environment script, many environment variables will be set (check with `export`),
|
||||
# and CMake will configure itself automatically based on them without needing explicit settings here.
|
||||
# source /mnt/fileroot/xinxin.he/environment/new-yocto/64/environment-setup-armv8a-poky-linux
|
||||
# export CXXFLAGS=$(echo "$CXXFLAGS" | sed 's/-g//g')
|
||||
# export CFLAGS=$(echo "$CXXFLAGS" | sed 's/-g//g')
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=${OE_CMAKE_TOOLCHAIN_FILE} ..
|
||||
|
||||
# # 设置 Yocto 交叉编译环境
|
||||
# # Set Yocto cross-compilation environment
|
||||
# set(SYSROOT_PATH /mnt/fileroot/xinxin.he/environment/new-yocto/64/sysroots/x86_64-pokysdk-linux)
|
||||
# set(CMAKE_SYSROOT "${SYSROOT_PATH}")
|
||||
# message(STATUS "Using sysroot path as ${SYSROOT_PATH}")
|
||||
|
|
@ -19,7 +21,7 @@ project(AML_LLM_NNSDK)
|
|||
# cmake_force_c_compiler("${SYSROOT_PATH}/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc" GNU)
|
||||
# cmake_force_cxx_compiler("${SYSROOT_PATH}/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++" GNU)
|
||||
|
||||
# # 设置真正目标板的 sysroot
|
||||
# # Set the sysroot for the actual target board
|
||||
# set(MYSYSROOT "/mnt/fileroot/xinxin.he/environment/new-yocto/64/sysroots/armv8a-poky-linux")
|
||||
# add_definitions("--sysroot=${MYSYSROOT}")
|
||||
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${MYSYSROOT}" CACHE INTERNAL "" FORCE)
|
||||
|
|
@ -29,22 +31,22 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
# SDK路径
|
||||
# SDK paths
|
||||
set(LLM_NNSDK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../01_src/jni")
|
||||
set(NNSDK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../01_src/jni/nnsdk_v2.8.1_2025_0317/lib/linux/lib64_yocto")
|
||||
|
||||
# 包含头文件路径
|
||||
# Include header paths
|
||||
include_directories(
|
||||
${LLM_NNSDK_PATH}
|
||||
)
|
||||
|
||||
# 源文件
|
||||
# Source files
|
||||
aux_source_directory(. SRC_LIST)
|
||||
|
||||
# 生成可执行文件
|
||||
# Build executable
|
||||
add_executable(demo_llm_yocto ${SRC_LIST})
|
||||
|
||||
# 链接库
|
||||
# Link libraries
|
||||
target_link_libraries(demo_llm_yocto
|
||||
${LLM_NNSDK_PATH}/build/libllm_nnsdk.so
|
||||
${NNSDK_PATH}/libnnsdk.so
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue