Skip to content

Commit 23359bd

Browse files
authored
Add Package.swift (#97)
1 parent 9fa0a64 commit 23359bd

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

Package.swift

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// swift-tools-version: 5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "Tokenizers",
8+
platforms: [
9+
.iOS(.v17),
10+
.macOS(.v12),
11+
],
12+
products: [
13+
.library(
14+
name: "Tokenizers",
15+
targets: ["Tokenizers"]
16+
),
17+
],
18+
dependencies: [
19+
// Add external dependencies here if needed
20+
],
21+
targets: [
22+
.target(
23+
name: "Tokenizers",
24+
dependencies: [
25+
"AbseilCpp",
26+
"RE2",
27+
"SentencePiece",
28+
"LlamaCppUnicode"
29+
],
30+
path: ".",
31+
sources: [
32+
"src/bpe_tokenizer_base.cpp",
33+
"src/hf_tokenizer.cpp",
34+
"src/llama2c_tokenizer.cpp",
35+
"src/normalizer.cpp",
36+
"src/pre_tokenizer.cpp",
37+
"src/re2_regex.cpp",
38+
"src/regex.cpp",
39+
"src/sentencepiece.cpp",
40+
"src/tiktoken.cpp",
41+
"src/token_decoder.cpp"
42+
],
43+
publicHeadersPath: "include",
44+
cxxSettings: [
45+
.headerSearchPath("include"),
46+
.headerSearchPath("third-party/sentencepiece"),
47+
.headerSearchPath("third-party/sentencepiece/src"),
48+
.headerSearchPath("third-party/re2"),
49+
.headerSearchPath("third-party/json/single_include"),
50+
.headerSearchPath("third-party/llama.cpp-unicode/include"),
51+
.define("ABSL_ENABLE_INSTALL"),
52+
.define("ABSL_PROPAGATE_CXX_STD"),
53+
.unsafeFlags(["-Wno-attributes"]),
54+
.cxxLanguageStandard(.cxx17)
55+
]
56+
),
57+
58+
// Abseil C++ library
59+
.target(
60+
name: "AbseilCpp",
61+
path: "third-party/abseil-cpp",
62+
publicHeadersPath: ".",
63+
cxxSettings: [
64+
.cxxLanguageStandard(.cxx17)
65+
]
66+
),
67+
68+
// RE2 library
69+
.target(
70+
name: "RE2",
71+
path: "third-party/re2",
72+
publicHeadersPath: ".",
73+
cxxSettings: [
74+
.cxxLanguageStandard(.cxx17)
75+
]
76+
),
77+
78+
// SentencePiece library
79+
.target(
80+
name: "SentencePiece",
81+
path: "third-party/sentencepiece",
82+
publicHeadersPath: "src",
83+
cxxSettings: [
84+
.headerSearchPath("src"),
85+
.headerSearchPath("third_party/protobuf-lite"),
86+
.cxxLanguageStandard(.cxx17)
87+
]
88+
),
89+
90+
// Llama.cpp Unicode library
91+
.target(
92+
name: "LlamaCppUnicode",
93+
path: "third-party/llama.cpp-unicode",
94+
sources: [
95+
"src/unicode.cpp",
96+
"src/unicode-data.cpp"
97+
],
98+
publicHeadersPath: "include",
99+
cxxSettings: [
100+
.cxxLanguageStandard(.cxx17)
101+
]
102+
)
103+
],
104+
cxxLanguageStandard: .cxx17
105+
)

0 commit comments

Comments
 (0)