fix asr compile bug ()

pull/3025/head
Hui Zhang 2 years ago committed by GitHub
parent e9da7e0e07
commit 2beb7ffce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,15 +16,8 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()
project(paddlespeech VERSION 0.1)
# if(ANDROID)
# # when cross compile with ndk under linux,
# # UNIX and ANROID are all True
# set(UNIX)
# endif()
include(FetchContent)
include(ExternalProject)
@ -71,26 +64,26 @@ if(WITH_TESTING)
endif()
# fastdeploy
if(NOT WITH_ASR)
include(fastdeploy)
endif()
if(WITH_ASR)
# openfst
include(openfst)
add_dependencies(openfst gflags glog)
add_dependencies(openfst gflags extern_glog)
endif()
###############################################################################
# Find Package
###############################################################################
# python/pybind11/threads
find_package(Threads REQUIRED)
if(WITH_ASR)
# https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
find_package(Python3 COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)
if(WITH_ASR)
if(Python3_FOUND)
message(STATUS "Python3_FOUND = ${Python3_FOUND}")
message(STATUS "Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
@ -114,17 +107,17 @@ if(WITH_ASR)
# paddle libpaddle.so
# paddle include and link option
# -L/workspace/DeepSpeech-2.x/engine/venv/lib/python3.7/site-packages/paddle/libs -L/workspace/DeepSpeech-2.x/speechx/venv/lib/python3.7/site-packages/paddle/fluid -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so
set(EXECUTE_COMMAND "import os"
"import paddle"
"include_dir = paddle.sysconfig.get_include()"
"paddle_dir=os.path.split(include_dir)[0]"
"libs_dir=os.path.join(paddle_dir, 'libs')"
"fluid_dir=os.path.join(paddle_dir, 'fluid')"
"out=' '.join([\"-L\" + libs_dir, \"-L\" + fluid_dir])"
"out += \" -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so\"; print(out)"
)
execute_process(
COMMAND python -c "\
import os;\
import paddle;\
include_dir=paddle.sysconfig.get_include();\
paddle_dir=os.path.split(include_dir)[0];\
libs_dir=os.path.join(paddle_dir, 'libs');\
fluid_dir=os.path.join(paddle_dir, 'fluid');\
out=' '.join([\"-L\" + libs_dir, \"-L\" + fluid_dir]);\
out += \" -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so\"; print(out);\
"
COMMAND python -c "${EXECUTE_COMMAND}"
OUTPUT_VARIABLE PADDLE_LINK_FLAGS
RESULT_VARIABLE SUCESS)
@ -133,29 +126,28 @@ if(WITH_ASR)
# paddle compile option
# -I/workspace/DeepSpeech-2.x/engine/venv/lib/python3.7/site-packages/paddle/include
set(EXECUTE_COMMAND "import paddle"
"include_dir = paddle.sysconfig.get_include()"
"print(f\"-I{include_dir}\")"
)
execute_process(
COMMAND python -c "\
import paddle; \
include_dir = paddle.sysconfig.get_include(); \
print(f\"-I{include_dir}\"); \
"
COMMAND python -c "${EXECUTE_COMMAND}"
OUTPUT_VARIABLE PADDLE_COMPILE_FLAGS)
message(STATUS PADDLE_COMPILE_FLAGS= ${PADDLE_COMPILE_FLAGS})
string(STRIP ${PADDLE_COMPILE_FLAGS} PADDLE_COMPILE_FLAGS)
# for LD_LIBRARY_PATH
# set(PADDLE_LIB_DIRS /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/fluid:/workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/libs/)
set(EXECUTE_COMMAND "import os"
"import paddle"
"include_dir=paddle.sysconfig.get_include()"
"paddle_dir=os.path.split(include_dir)[0]"
"libs_dir=os.path.join(paddle_dir, 'libs')"
"fluid_dir=os.path.join(paddle_dir, 'fluid')"
"out=':'.join([libs_dir, fluid_dir]); print(out)"
)
execute_process(
COMMAND python -c "\
import os; \
import paddle; \
include_dir=paddle.sysconfig.get_include(); \
paddle_dir=os.path.split(include_dir)[0]; \
libs_dir=os.path.join(paddle_dir, 'libs'); \
fluid_dir=os.path.join(paddle_dir, 'fluid'); \
out=':'.join([libs_dir, fluid_dir]); print(out); \
"
COMMAND python -c "${EXECUTE_COMMAND}"
OUTPUT_VARIABLE PADDLE_LIB_DIRS)
message(STATUS PADDLE_LIB_DIRS= ${PADDLE_LIB_DIRS})
endif()

@ -4,5 +4,5 @@ set -xe
# the build script had verified in the paddlepaddle docker image.
# please follow the instruction below to install PaddlePaddle image.
# https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/linux-docker.html
cmake -B build -DWITH_ASR=OFF -DWITH_CLS=OFF
cmake -B build -DWITH_ASR=ON -DWITH_CLS=OFF -DWITH_VAD=OFF
cmake --build build -j

@ -18,7 +18,7 @@ endif()
if(ANDROID)
add_library(extern_gtest INTERFACE)
else() # UNIX
add_dependencies(gtest gflags gflog)
add_dependencies(gtest gflags extern_glog)
add_library(extern_gtest ALIAS gtest)
endif()

@ -16,6 +16,7 @@ ExternalProject_Add(openfst
PREFIX ${openfst_PREFIX_DIR}
SOURCE_DIR ${openfst_SOURCE_DIR}
BINARY_DIR ${openfst_BINARY_DIR}
BUILD_ALWAYS 0
CONFIGURE_COMMAND ${openfst_SOURCE_DIR}/configure --prefix=${openfst_PREFIX_DIR}
"CPPFLAGS=-I${gflags_BINARY_DIR}/include -I${glog_SOURCE_DIR}/src -I${glog_BINARY_DIR}"
"LDFLAGS=-L${gflags_BINARY_DIR} -L${glog_BINARY_DIR}"

Loading…
Cancel
Save