Skip to content

Commit 160a126

Browse files
mallocnewFei Hao
andauthored
✅ Update runtime deps & CXX standard (#331)
- update openfst to 1.8.5 - update gflags, glog & gtest - update CXX from std14 to std17 Issue-ID: #329 Co-authored-by: Fei Hao <haof1@chinatelecom.cn>
1 parent bb14572 commit 160a126

10 files changed

Lines changed: 24 additions & 21 deletions

File tree

runtime/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
22

33
project(wetextprocessing VERSION 0.1)
4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55

66
set(CMAKE_VERBOSE_MAKEFILE OFF)
7+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
78
option(BUILD_TESTING "whether to build unit test" OFF)
89

910
include(FetchContent)
@@ -12,10 +13,8 @@ get_filename_component(fc_base "fc_base-${CMAKE_CXX_COMPILER_ID}" REALPATH BASE_
1213
set(FETCHCONTENT_BASE_DIR ${fc_base})
1314
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
1415

15-
if(NOT MSVC)
16-
# Keep the same with openfst, -fPIC or -fpic
17-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fPIC")
18-
else()
16+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
17+
if(MSVC)
1918
# For windows, please use unicode(3 bytes per chinese char) instead of gbk(2 bytes per chinese char).
2019
# https://github.com/wenet-e2e/wenet/issues/882#issuecomment-1101246299
2120
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

runtime/bin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_executable(processor_main processor_main.cc)
22
target_link_libraries(processor_main PUBLIC wetext_processor)
3+
target_link_libraries(processor_main PUBLIC gflags glog)

runtime/bin/processor_main.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include "processor/wetext_processor.h"
2020
#include "utils/wetext_flags.h"
2121

22+
#include <gflags/gflags.h>
23+
#include <glog/logging.h>
24+
2225
DEFINE_string(text, "", "input string");
2326
DEFINE_string(file, "", "input file");
2427
DEFINE_string(tagger, "", "tagger fst path");

runtime/cmake/gflags.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
set(GFLAGS_NAMESPACE "gflags")
22

33
FetchContent_Declare(gflags
4-
URL https://github.com/gflags/gflags/archive/v2.2.2.zip
5-
URL_HASH MD5=ff856ff64757f1381f7da260f79ba79b
4+
URL https://github.com/gflags/gflags/archive/refs/tags/v2.3.0.tar.gz
5+
URL_HASH SHA256=f619a51371f41c0ad6837b2a98af9d4643b3371015d873887f7e8d3237320b2f
66
)
77
FetchContent_MakeAvailable(gflags)
88
include_directories(${gflags_BINARY_DIR}/include)

runtime/cmake/glog.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FetchContent_Declare(glog
2-
URL https://github.com/google/glog/archive/v0.4.0.zip
3-
URL_HASH MD5=2899b069b8229d49cd65eda5271315ad
2+
URL https://github.com/google/glog/archive/refs/tags/v0.7.1.zip
3+
URL_HASH SHA256=c17d85c03ad9630006ef32c7be7c65656aba2e7e2fbfc82226b7e680c771fc88
44
)
55
FetchContent_MakeAvailable(glog)
66
include_directories(${glog_SOURCE_DIR}/src ${glog_BINARY_DIR})

runtime/cmake/gtest.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FetchContent_Declare(googletest
2-
URL https://github.com/google/googletest/archive/release-1.12.1.zip
3-
URL_HASH MD5=2648d4138129812611cf6b6b4b497a3b
2+
URL https://github.com/google/googletest/archive/refs/tags/v1.17.0.zip
3+
URL_HASH SHA256=40d4ec942217dcc84a9ebe2a68584ada7d4a33a8ee958755763278ea1c5e18ff
44
)
55
if(MSVC)
66
set(gtest_force_shared_crt ON CACHE BOOL "Always use msvcrt.dll" FORCE)

runtime/cmake/openfst.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ if(NOT ANDROID)
2727
# To build openfst with gflags and glog, we comment out some vars of {flags, log}.h and flags.cc.
2828
set(openfst_SOURCE_DIR ${fc_base}/openfst-src CACHE PATH "OpenFST source directory")
2929
FetchContent_Declare(openfst
30-
URL https://github.com/kkm000/openfst/archive/refs/tags/win/1.7.2.1.tar.gz
31-
URL_HASH SHA256=e04e1dabcecf3a687ace699ccb43a8a27da385777a56e69da6e103344cc66bca
32-
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${openfst_SOURCE_DIR}
30+
URL https://github.com/csukuangfj/openfst/archive/refs/tags/v1.8.5-2026-04-11.tar.gz
31+
URL_HASH SHA256=57fbc4b950ae81b1a0e1e298af15652da968a6723a592b7874e9b4027a80a5b4
32+
# PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${openfst_SOURCE_DIR}
3333
)
3434
FetchContent_MakeAvailable(openfst)
35-
add_dependencies(fst gflags glog)
36-
target_link_libraries(fst PUBLIC gflags_nothreads_static glog)
35+
# add_dependencies(fst gflags glog)
36+
# target_link_libraries(fst PUBLIC gflags_nothreads_static glog)
3737
include_directories(${openfst_SOURCE_DIR}/src/include)
3838
else()
3939
set(openfst_BINARY_DIR ${build_DIR}/wenet-openfst-android-1.0.2.aar/jni)

runtime/processor/wetext_processor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
#include "processor/wetext_processor.h"
1616

17-
using fst::StringTokenType;
17+
using fst::TokenType;
1818

1919
namespace wetext {
2020
Processor::Processor(const std::string& tagger_path,
2121
const std::string& verbalizer_path) {
2222
tagger_.reset(StdVectorFst::Read(tagger_path));
2323
verbalizer_.reset(StdVectorFst::Read(verbalizer_path));
24-
compiler_ = std::make_shared<StringCompiler<StdArc>>(StringTokenType::BYTE);
25-
printer_ = std::make_shared<StringPrinter<StdArc>>(StringTokenType::BYTE);
24+
compiler_ = std::make_shared<StringCompiler<StdArc>>(TokenType::BYTE);
25+
printer_ = std::make_shared<StringPrinter<StdArc>>(TokenType::BYTE);
2626

2727
if (tagger_path.find("zh_tn_") != tagger_path.npos) {
2828
parse_type_ = ParseType::kZH_TN;

runtime/test/processor_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::vector<std::pair<std::string, std::string>> ParseTestCase(
2828
std::vector<std::pair<std::string, std::string>> test_cases;
2929
std::string line;
3030
while (getline(file, line)) {
31-
CHECK_NE(line.find(delimiter), string::npos);
31+
CHECK_NE(line.find(delimiter), std::string::npos);
3232
std::vector<std::string> arr;
3333
wetext::Split(line, delimiter, &arr);
3434
CHECK_GT(arr.size(), 0);

runtime/test/token_parser_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TokenParserTest : public testing::Test {
2626
wetext::TokenParser* parser;
2727

2828
virtual void SetUp() {
29-
parser = new wetext::TokenParser(wetext::ParseType::kTN);
29+
parser = new wetext::TokenParser(wetext::ParseType::kZH_TN);
3030
}
3131

3232
virtual void TearDown() { delete parser; }

0 commit comments

Comments
 (0)