Skip to content

Commit 2a8dc1b

Browse files
authored
[vcpkg baseline][sentencepiece] Fix flags, linkage, deps (#42226)
1 parent d81fa4b commit 2a8dc1b

File tree

8 files changed

+101
-14
lines changed

8 files changed

+101
-14
lines changed

ports/sentencepiece/abseil.diff

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 9fa37fa..0e220e6 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -173,6 +173,9 @@ elseif (SPM_ABSL_PROVIDER STREQUAL "package")
6+
find_package(absl REQUIRED)
7+
get_target_property(ABSL_INCLUDE_DIRS absl::base INTERFACE_INCLUDE_DIRECTORIES)
8+
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl.org)
9+
+ file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl)
10+
+ file(COPY "${ABSL_INCLUDE_DIRS}/absl" DESTINATION "${PROJECT_BINARY_DIR}/third_party")
11+
+ elseif(0)
12+
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl.org)
13+
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
14+
${ABSL_INCLUDE_DIRS}/absl ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl)
15+
diff --git a/src/sentencepiece_processor.h b/src/sentencepiece_processor.h
16+
index dd3f092..c1551a7 100644
17+
--- a/src/sentencepiece_processor.h
18+
+++ b/src/sentencepiece_processor.h
19+
@@ -23,9 +23,7 @@
20+
#include <vector>
21+
22+
#ifndef SWIG
23+
-namespace absl {
24+
-using std::string_view;
25+
-} // namespace absl
26+
+#include <absl/strings/string_view.h>
27+
#endif // SWIG
28+
29+
namespace sentencepiece {

ports/sentencepiece/cxxflags.diff

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
2+
index d983089..19736d8 100644
3+
--- a/src/CMakeLists.txt
4+
+++ b/src/CMakeLists.txt
5+
@@ -264,7 +264,6 @@ if (NOT MSVC)
6+
if (SPM_COVERAGE)
7+
set(CMAKE_CXX_FLAGS "-O0 -Wall -fPIC -coverage ${CMAKE_CXX_FLAGS}")
8+
else()
9+
- set(CMAKE_CXX_FLAGS "-O3 -Wall -fPIC ${CMAKE_CXX_FLAGS}")
10+
endif()
11+
if (SPM_ENABLE_TENSORFLOW_SHARED)
12+
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

ports/sentencepiece/linkage.diff

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
2+
index 8d4a34f..6ef8aa9 100644
3+
--- a/src/CMakeLists.txt
4+
+++ b/src/CMakeLists.txt
5+
@@ -250,6 +250,8 @@ if (SPM_ENABLE_SHARED)
6+
set_target_properties(sentencepiece PROPERTIES IMPORT_SUFFIX ".dll.a")
7+
set_target_properties(sentencepiece_train PROPERTIES IMPORT_SUFFIX ".dll.a")
8+
endif()
9+
+ list(REMOVE_ITEM SPM_INSTALLTARGETS sentencepiece-static sentencepiece_train-static)
10+
+ set_target_properties(sentencepiece-static sentencepiece_train-static PROPERTIES EXCLUDE_FROM_ALL 1)
11+
else()
12+
add_library(sentencepiece ALIAS sentencepiece-static)
13+
add_library(sentencepiece_train ALIAS sentencepiece_train-static)

ports/sentencepiece/portfile.cmake

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
if(NOT VCPKG_CMAKE_SYSTEM_NAME)
2-
vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_STATIC_CRT)
1+
if(VCPKG_TARGET_IS_WINDOWS)
2+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
33
endif()
44

55
vcpkg_from_github(
66
OUT_SOURCE_PATH SOURCE_PATH
77
REPO google/sentencepiece
88
REF "v${VERSION}"
9-
SHA512 b4214f5bfbe2a0757794c792e87e7c53fda7e65b2511b37fc757f280bf9287ba59b5d630801e17de6058f8292a3c6433211917324cb3446a212a51735402e614
9+
SHA512 b4214f5bfbe2a0757794c792e87e7c53fda7e65b2511b37fc757f280bf9287ba59b5d630801e17de6058f8292a3c6433211917324cb3446a212a51735402e614
1010
HEAD_REF master
11+
PATCHES
12+
abseil.diff
13+
cxxflags.diff
14+
linkage.diff
15+
protobuf.diff
1116
)
1217

18+
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SPM_ENABLE_SHARED)
19+
1320
vcpkg_cmake_configure(
1421
SOURCE_PATH "${SOURCE_PATH}"
1522
OPTIONS
16-
-DSPM_ENABLE_SHARED=OFF
17-
-DSPM_USE_BUILTIN_PROTOBUF=ON
18-
-DSPM_USE_EXTERNAL_ABSL=OFF
23+
-DSPM_ENABLE_SHARED=${SPM_ENABLE_SHARED}
24+
-DSPM_ENABLE_TCMALLOC=OFF
25+
-DSPM_ABSL_PROVIDER=package
26+
-DSPM_PROTOBUF_PROVIDER=package
1927
)
2028

2129
vcpkg_cmake_install()
22-
23-
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
24-
25-
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
30+
vcpkg_copy_pdbs()
31+
vcpkg_fixup_pkgconfig()
2632

2733
vcpkg_copy_tools(TOOL_NAMES spm_decode spm_encode spm_export_vocab spm_normalize spm_train AUTO_CLEAN)
2834

29-
vcpkg_copy_pdbs()
35+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
3036

31-
vcpkg_fixup_pkgconfig()
37+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

ports/sentencepiece/protobuf.diff

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
2+
index 6ef8aa9..d983089 100644
3+
--- a/src/CMakeLists.txt
4+
+++ b/src/CMakeLists.txt
5+
@@ -70,12 +70,11 @@ if (SPM_PROTOBUF_PROVIDER STREQUAL "internal")
6+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/protobuf-lite)
7+
include_directories(builtin_pb)
8+
elseif (SPM_PROTOBUF_PROVIDER STREQUAL "package")
9+
- find_package(Protobuf REQUIRED)
10+
- include_directories(${Protobuf_INCLUDE_DIRS})
11+
+ find_package(protobuf CONFIG REQUIRED)
12+
+ set(PROTOBUF_LITE_LIBRARY protobuf::libprotobuf-lite)
13+
protobuf_generate_cpp(SPM_PROTO_SRCS SPM_PROTO_HDRS sentencepiece.proto)
14+
protobuf_generate_cpp(SPM_MODEL_PROTO_SRCS SPM_MODEL_PROTO_HDRS sentencepiece_model.proto)
15+
set(PROTOBUF_LITE_SRCS "")
16+
- include_directories(${PROTOBUF_INCLUDE_DIR})
17+
if (MSVC)
18+
add_definitions("/D_USE_EXTERNAL_PROTOBUF")
19+
else()

ports/sentencepiece/vcpkg.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"name": "sentencepiece",
33
"version": "0.2.0",
4+
"port-version": 1,
45
"description": "SentencePiece is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabulary size is predetermined prior to the neural model training",
6+
"homepage": "https://github.com/google/sentencepiece",
57
"license": "Apache-2.0",
6-
"supports": "static",
78
"dependencies": [
9+
"abseil",
10+
"protobuf",
811
{
912
"name": "vcpkg-cmake",
1013
"host": true

versions/baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8266,7 +8266,7 @@
82668266
},
82678267
"sentencepiece": {
82688268
"baseline": "0.2.0",
8269-
"port-version": 0
8269+
"port-version": 1
82708270
},
82718271
"sentry-native": {
82728272
"baseline": "0.7.12",

versions/s-/sentencepiece.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "626e5f5d9e302b9095128148ff4ccd046486c13e",
5+
"version": "0.2.0",
6+
"port-version": 1
7+
},
38
{
49
"git-tree": "60678651110bfbd252017ee568f2cb6484aaaf46",
510
"version": "0.2.0",

0 commit comments

Comments
 (0)