Skip to content

Commit fb6904f

Browse files
committed
apply translator
1 parent ce1a23f commit fb6904f

File tree

8 files changed

+2528
-1752
lines changed

8 files changed

+2528
-1752
lines changed

.clang-format

Lines changed: 9 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,9 @@
1-
---
2-
Language: Cpp
3-
AlignAfterOpenBracket: Align
4-
AlignArrayOfStructures: Left
5-
AlignConsecutiveAssignments: AcrossComments
6-
AlignConsecutiveBitFields: AcrossComments
7-
AlignConsecutiveDeclarations: AcrossComments
8-
AlignConsecutiveMacros: AcrossComments
9-
# AlignConsecutiveShortCaseStatements: AcrossComments
10-
AlignEscapedNewlines: Left # LeftWithLastLine
11-
AlignOperands: Align
12-
AlignTrailingComments:
13-
Kind: Always
14-
OverEmptyLines: 1
15-
AllowAllArgumentsOnNextLine: true
16-
AllowAllParametersOfDeclarationOnNextLine: false
17-
# AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
18-
AllowShortBlocksOnASingleLine: Never
19-
AllowShortCaseLabelsOnASingleLine: false
20-
AllowShortFunctionsOnASingleLine: Inline
21-
AllowShortIfStatementsOnASingleLine: Never
22-
AllowShortLambdasOnASingleLine: Inline
23-
AllowShortLoopsOnASingleLine: false
24-
AlwaysBreakBeforeMultilineStrings: true
25-
BinPackArguments: true
26-
BinPackParameters: true # OnePerLine
27-
BitFieldColonSpacing: Both
28-
BreakBeforeBraces: Custom # Attach
29-
BraceWrapping:
30-
AfterCaseLabel: true
31-
AfterClass: false
32-
AfterControlStatement: false
33-
AfterEnum: false
34-
AfterFunction: false
35-
AfterNamespace: false
36-
AfterObjCDeclaration: false
37-
AfterStruct: false
38-
AfterUnion: false
39-
AfterExternBlock: false
40-
BeforeCatch: false
41-
BeforeElse: false
42-
BeforeLambdaBody: false
43-
BeforeWhile: false
44-
IndentBraces: false
45-
SplitEmptyFunction: false
46-
SplitEmptyRecord: false
47-
SplitEmptyNamespace: false
48-
# BreakAdjacentStringLiterals: true
49-
BreakAfterAttributes: Never
50-
BreakBeforeBinaryOperators: None
51-
BreakBeforeInlineASMColon: OnlyMultiline
52-
BreakBeforeTernaryOperators: false
53-
# BreakBinaryOperations: Never
54-
BreakConstructorInitializers: AfterColon
55-
# BreakFunctionDefinitionParameters: false
56-
BreakInheritanceList: AfterComma
57-
BreakStringLiterals: true
58-
# BreakTemplateDeclarations: Yes
59-
ColumnLimit: 120
60-
CommentPragmas: '^ IWYU pragma:'
61-
CompactNamespaces: false
62-
ConstructorInitializerIndentWidth: 4
63-
ContinuationIndentWidth: 4
64-
Cpp11BracedListStyle: false
65-
DerivePointerAlignment: false
66-
DisableFormat: false
67-
EmptyLineBeforeAccessModifier: Leave
68-
EmptyLineAfterAccessModifier: Never
69-
ExperimentalAutoDetectBinPacking: false
70-
FixNamespaceComments: true
71-
IncludeBlocks: Regroup
72-
IncludeCategories:
73-
- Regex: '^<.*\.h>'
74-
Priority: 1
75-
SortPriority: 0
76-
- Regex: '^<.*'
77-
Priority: 2
78-
SortPriority: 0
79-
- Regex: '.*'
80-
Priority: 3
81-
SortPriority: 0
82-
IncludeIsMainRegex: '([-_](test|unittest))?$'
83-
IncludeIsMainSourceRegex: ''
84-
IndentAccessModifiers: false
85-
IndentCaseBlocks: true
86-
IndentCaseLabels: true
87-
IndentExternBlock: NoIndent
88-
IndentGotoLabels: false
89-
IndentPPDirectives: AfterHash
90-
IndentWidth: 4
91-
IndentWrappedFunctionNames: false
92-
InsertBraces: true # NOTE: may lead to incorrect formatting
93-
InsertNewlineAtEOF: true
94-
JavaScriptQuotes: Leave
95-
JavaScriptWrapImports: true
96-
KeepEmptyLinesAtTheStartOfBlocks: false
97-
LambdaBodyIndentation: Signature
98-
LineEnding: LF
99-
MacroBlockBegin: ''
100-
MacroBlockEnd: ''
101-
MaxEmptyLinesToKeep: 1
102-
NamespaceIndentation: None
103-
ObjCBinPackProtocolList: Auto
104-
ObjCBlockIndentWidth: 4
105-
ObjCSpaceAfterProperty: true
106-
ObjCSpaceBeforeProtocolList: true
107-
PPIndentWidth: -1
108-
PackConstructorInitializers: CurrentLine
109-
PenaltyBreakAssignment: 2
110-
PenaltyBreakBeforeFirstCallParameter: 1
111-
PenaltyBreakComment: 300
112-
PenaltyBreakFirstLessLess: 120
113-
PenaltyBreakString: 1000
114-
PenaltyBreakTemplateDeclaration: 10
115-
PenaltyExcessCharacter: 1000000
116-
PenaltyReturnTypeOnItsOwnLine: 200
117-
PointerAlignment: Middle
118-
QualifierAlignment: Left
119-
#QualifierOrder: ['static', 'inline', 'friend', 'constexpr', 'const', 'volatile', 'type', 'restrict']
120-
RawStringFormats:
121-
- Language: Cpp
122-
Delimiters:
123-
- cc
124-
- CC
125-
- cpp
126-
- Cpp
127-
- CPP
128-
- 'c++'
129-
- 'C++'
130-
CanonicalDelimiter: ''
131-
ReferenceAlignment: Middle
132-
ReflowComments: false # IndentOnly
133-
SeparateDefinitionBlocks: Always
134-
SortIncludes: CaseInsensitive
135-
SortUsingDeclarations: LexicographicNumeric
136-
SpaceAfterCStyleCast: true
137-
SpaceAfterLogicalNot: false
138-
SpaceAfterTemplateKeyword: true
139-
SpaceBeforeAssignmentOperators: true
140-
SpaceBeforeCpp11BracedList: false
141-
SpaceBeforeCtorInitializerColon: true
142-
SpaceBeforeInheritanceColon: true
143-
SpaceBeforeParens: ControlStatements
144-
SpaceBeforeRangeBasedForLoopColon: true
145-
SpaceInEmptyBlock: false
146-
SpaceInEmptyParentheses: false
147-
SpacesBeforeTrailingComments: 2
148-
SpacesInAngles: Never
149-
SpacesInContainerLiterals: true
150-
SpacesInLineCommentPrefix:
151-
Minimum: 1
152-
Maximum: -1
153-
SpacesInParentheses: false
154-
SpacesInSquareBrackets: false
155-
SpaceBeforeSquareBrackets: false
156-
Standard: c++17
157-
TabWidth: 4
158-
UseTab: Never
159-
WhitespaceSensitiveMacros: ['STRINGIZE']
160-
...
161-
1+
BasedOnStyle: LLVM
2+
UseTab: Never
3+
IndentWidth: 4
4+
TabWidth: 4
5+
BreakBeforeBraces: Allman
6+
AllowShortIfStatementsOnASingleLine: false
7+
IndentCaseLabels: false
8+
ColumnLimit: 0
9+
AccessModifierOffset: -4

examples/server/CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@ if (MINGW)
99
add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
1010
endif()
1111

12+
# Find necessary packages
13+
find_package(CURL REQUIRED)
14+
find_package(OpenSSL REQUIRED)
15+
16+
if (CURL_FOUND)
17+
message(STATUS "Found CURL: ${CURL_LIBRARIES}")
18+
else()
19+
message(FATAL_ERROR "CURL library not found!")
20+
endif()
21+
1222
set(TARGET_SRCS
1323
server.cpp
24+
translator.hpp
25+
translator.cpp
1426
utils.hpp
1527
httplib.h
1628
)
29+
1730
set(PUBLIC_ASSETS
1831
index.html.gz
1932
loading.html
@@ -23,28 +36,30 @@ foreach(asset ${PUBLIC_ASSETS})
2336
set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}")
2437
set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp")
2538
list(APPEND TARGET_SRCS ${output})
39+
2640
add_custom_command(
2741
DEPENDS "${input}"
2842
OUTPUT "${output}"
2943
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${input}" "-DOUTPUT=${output}" -P "${PROJECT_SOURCE_DIR}/scripts/xxd.cmake"
3044
)
45+
3146
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
3247
endforeach()
3348

3449
add_executable(${TARGET} ${TARGET_SRCS})
50+
3551
install(TARGETS ${TARGET} RUNTIME)
3652

37-
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
38-
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
53+
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR} ${CURL_INCLUDE_DIRS})
54+
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES})
3955

4056
if (LLAMA_SERVER_SSL)
41-
find_package(OpenSSL REQUIRED)
4257
target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
4358
target_compile_definitions(${TARGET} PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
4459
endif()
4560

4661
if (WIN32)
47-
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
62+
target_link_libraries(${TARGET} PRIVATE ws2_32)
4863
endif()
4964

5065
target_compile_features(${TARGET} PRIVATE cxx_std_17)

0 commit comments

Comments
 (0)