-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup and import lemonade as ibus-slimt-t8n
- Loading branch information
0 parents
commit d79d766
Showing
32 changed files
with
3,157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
# Configure clang-tidy for this project. | ||
|
||
# Here is an explanation for why some of the checks are disabled: | ||
# | ||
# -google-readability-namespace-comments: the *_CLIENT_NS is a macro, and | ||
# clang-tidy fails to match it against the initial value. | ||
# | ||
# -modernize-use-trailing-return-type: clang-tidy recommends using | ||
# `auto Foo() -> std::string { return ...; }`, we think the code is less | ||
# readable in this form. | ||
# | ||
# -modernize-return-braced-init-list: We think removing typenames and using | ||
# only braced-init can hurt readability. | ||
# | ||
# -modernize-avoid-c-arrays: We only use C arrays when they seem to be the | ||
# right tool for the job, such as `char foo[] = "hello"`. In these cases, | ||
# avoiding C arrays often makes the code less readable, and std::array is | ||
# not a drop-in replacement because it doesn't deduce the size. | ||
# | ||
# -performance-move-const-arg: This warning requires the developer to | ||
# know/care more about the implementation details of types/functions than | ||
# should be necessary. For example, `A a; F(std::move(a));` will trigger a | ||
# warning IFF `A` is a trivial type (and therefore the move is | ||
# meaningless). It would also warn if `F` accepts by `const&`, which is | ||
# another detail that the caller need not care about. | ||
# | ||
# -readability-redundant-declaration: A friend declaration inside a class | ||
# counts as a declaration, so if we also declare that friend outside the | ||
# class in order to document it as part of the public API, that will | ||
# trigger a redundant declaration warning from this check. | ||
# | ||
# -readability-function-cognitive-complexity: too many false positives with | ||
# clang-tidy-12. We need to disable this check in macros, and that setting | ||
# only appears in clang-tidy-13. | ||
# | ||
# -bugprone-narrowing-conversions: too many false positives around | ||
# `std::size_t` vs. `*::difference_type`. | ||
# | ||
# -bugprone-easily-swappable-parameters: too many false positives. | ||
# | ||
# -bugprone-implicit-widening-of-multiplication-result: too many false positives. | ||
# Almost any expression of the form `2 * variable` or `long x = a_int * b_int;` | ||
# generates an error. | ||
# | ||
# -bugprone-unchecked-optional-access: too many false positives in tests. | ||
# Despite what the documentation says, this warning appears after | ||
# `ASSERT_TRUE(variable)` or `ASSERT_TRUE(variable.has_value())`. | ||
# | ||
Checks: > | ||
-*, | ||
bugprone-*, | ||
google-*, | ||
misc-*, | ||
modernize-*, | ||
performance-*, | ||
portability-*, | ||
readability-*, | ||
-google-readability-braces-around-statements, | ||
-google-readability-namespace-comments, | ||
-google-runtime-references, | ||
-misc-non-private-member-variables-in-classes, | ||
-misc-const-correctness, | ||
-modernize-return-braced-init-list, | ||
-modernize-use-trailing-return-type, | ||
-modernize-use-nodiscard, | ||
-modernize-avoid-c-arrays, | ||
-performance-move-const-arg, | ||
-readability-braces-around-statements, | ||
-readability-identifier-length, | ||
-readability-named-parameter, | ||
-readability-redundant-declaration, | ||
-readability-function-cognitive-complexity, | ||
-bugprone-narrowing-conversions, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-implicit-widening-of-multiplication-result, | ||
-bugprone-exception-escape, | ||
-bugprone-unchecked-optional-access, | ||
-portability-simd-intrinsics | ||
# Turn all the warnings from the checks above into errors. | ||
WarningsAsErrors: "*" | ||
|
||
HeaderFilterRegex: "(google/cloud/|generator/).*\\.h$" | ||
|
||
CheckOptions: | ||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassCase, value: CamelCase } | ||
- { key: readability-identifier-naming.StructCase, value: CamelCase } | ||
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } | ||
- { key: readability-identifier-naming.FunctionCase, value: lower_case } | ||
- { key: readability-identifier-naming.VariableCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassMethodCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase } | ||
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k } | ||
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k } | ||
- { key: readability-identifier-naming.MemberCase, value: lower_case } | ||
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.MemberConstantPrefix, value: k } | ||
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.StaticConstantPrefix, value: k } | ||
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 } | ||
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 } | ||
- { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 } | ||
- { key: readability-identifier-naming.TemplateParameterIgnoredRegexp, value: 'expr-type'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: "g" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '**' | ||
env: | ||
ccache_basedir: ${{ github.workspace }} | ||
ccache_dir: "${{ github.workspace }}/.ccache" | ||
ccache_compilercheck: content | ||
ccache_compress: 'true' | ||
ccache_compresslevel: 9 | ||
ccache_maxsize: 200M | ||
ccache_cmake: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache | ||
|
||
jobs: | ||
main: | ||
name: "build-test" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Install Dependencies | ||
run: |- | ||
sudo apt-get update | ||
sudo apt-get install -y \ | ||
ccache libprotobuf-dev protobuf-compiler \ | ||
libibus-1.0-dev \ | ||
qttools5-dev qtbase5-dev \ | ||
libyaml-cpp-dev \ | ||
rapidjson-dev | ||
- name: Install slimt | ||
run: |- | ||
sudo apt-get install -y libopenblas-dev libsentencepiece-dev | ||
# libxsimd-dev fails due to some issue. | ||
git clone https://github.com/xtensor-stack/xsimd --branch 11.1.0 --depth 1 | ||
cmake -B xsimd/build -S xsimd | ||
cmake --build xsimd/build --target all | ||
sudo cmake --build xsimd/build --target install | ||
git clone --recursive https://github.com/jerinphilip/slimt --single-branch --branch main | ||
cmake -B slimt/build -S slimt -DEXPORT_CMAKE_FILE=ON -DUSE_BUILTIN_SENTENCEPIECE=OFF \ | ||
-DWITH_GEMMOLOGY=ON -DUSE_AVX2=ON -DUSE_SSE2=ON -DUSE_SSSE3=ON -DUSE_AVX512=ON \ | ||
-DWITH_INTGEMM=OFF | ||
cmake --build slimt/build --target all | ||
sudo cmake --build slimt/build --target install | ||
- name: Generate ccache_vars for ccache based on machine | ||
shell: bash | ||
id: ccache_vars | ||
run: |- | ||
echo "::set-output name=hash::$(echo ${{ env.ccache_compilercheck }})" | ||
echo "::set-output name=timestamp::$(date '+%Y-%m-%dT%H.%M.%S')" | ||
- name: Cache-op for build-cache through ccache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.ccache_dir }} | ||
key: ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }} | ||
restore-keys: |- | ||
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }} | ||
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }} | ||
ccache-${{ matrix.identifier }} | ||
- name: ccache environment setup | ||
run: |- | ||
echo "CCACHE_COMPILER_CHECK=${{ env.ccache_compilercheck }}" >> $GITHUB_ENV | ||
echo "CCACHE_BASEDIR=${{ env.ccache_basedir }}" >> $GITHUB_ENV | ||
echo "CCACHE_COMPRESS=${{ env.ccache_compress }}" >> $GITHUB_ENV | ||
echo "CCACHE_COMPRESSLEVEL=${{ env.ccache_compresslevel }}" >> $GITHUB_ENV | ||
echo "CCACHE_DIR=${{ env.ccache_dir }}" >> $GITHUB_ENV | ||
echo "CCACHE_MAXSIZE=${{ env.ccache_maxsize }}" >> $GITHUB_ENV | ||
- name: ccache prolog | ||
run: |- | ||
ccache -s # Print current cache stats | ||
ccache -z # Zero cache entry | ||
- name: cmake | ||
run: |- | ||
mkdir -p build | ||
cd build | ||
cmake -L .. -DCOMPILE_TESTS=on ${{ env.ccache_cmake }} | ||
- name: Build from source | ||
working-directory: build | ||
run: | | ||
make -j2 | ||
- name: Test translator backend | ||
working-directory: build/ibus-slimt-t8n | ||
run: |- | ||
# Install bergamot, which will manage models. | ||
python3 -m pip install slimt -f https://github.com/jerinphilip/slimt/releases/expanded_assets/latest | ||
# Download models. | ||
slimt download -m en-fr-tiny | ||
slimt download -m fr-en-tiny | ||
slimt download -m de-en-tiny | ||
slimt download -m en-de-tiny | ||
./test fake < ${{ github.workspace }}/data/samples.txt | ||
./test real < ${{ github.workspace }}/data/samples.txt | ||
- name: ccache epilog | ||
run: 'ccache -s # Print current cache stats' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
build/ | ||
dist/ | ||
.*sw[op] | ||
|
||
lemonade/ibus_config.h | ||
*.egg-info | ||
*.pyc | ||
__pycache__ | ||
env/ | ||
|
||
docs/_build | ||
docs/make.bat | ||
|
||
ibus-slimt-t8n.fossil | ||
*.marks | ||
|
||
.cache | ||
.fslckout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
cmake_minimum_required(VERSION 3.5.1) | ||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
include(CMakeDependentOption) | ||
|
||
if(POLICY CMP0074) | ||
cmake_policy(SET CMP0074 NEW) # CMake 3.12 | ||
endif() | ||
project(ibus-slimt-t8n CXX C) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
include(GetVersionFromFile) | ||
message(STATUS "Project name: ${PROJECT_NAME}") | ||
message(STATUS "Project version: ${PROJECT_VERSION_STRING_FULL}") | ||
|
||
set(AUTHOR "Jerin Philip <[email protected]>") | ||
set(AUTHOR_XML_ESCAPED "Jerin Philip <[email protected]>") | ||
set(PROJECT_SHORTNAME "ibus-slimt-t8n") | ||
set(PROJECT_LONGNAME "slimt-t8n") | ||
set(PROJECT_DESCRIPTION | ||
"slimt-t8n provides client-side translation on the local *nix machine.") | ||
set(PROJECT_VERSION ${PROJECT_VERSION_STRING}) | ||
set(PROJECT_HOMEPAGE "https://github.com/jerinphilip/ibus-slimt-t8n") | ||
set(PROJECT_LICENSE "GPL") | ||
|
||
find_package(yaml-cpp REQUIRED) | ||
find_package(slimt REQUIRED) | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(GLIB2 REQUIRED glib-2.0) | ||
pkg_check_modules(IBUS REQUIRED ibus-1.0) | ||
|
||
if(NOT TARGET yaml-cpp::yaml-cpp) | ||
add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp) | ||
endif() | ||
|
||
set(SLIMT_T8N_PRIVATE_LIBS slimt::slimt-shared yaml-cpp::yaml-cpp | ||
${GLIB2_LIBRARIES} ${IBUS_LIBRARIES}) | ||
|
||
include(GNUInstallDirs) | ||
|
||
add_subdirectory(ibus-slimt-t8n) | ||
|
||
install(TARGETS ibus-slimt-t8n RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) | ||
install(FILES ${CMAKE_BINARY_DIR}/slimt-t8n.xml | ||
DESTINATION /usr/share/ibus/component) | ||
install(FILES ${CMAKE_SOURCE_DIR}/assets/bergamot.png | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons) |
Oops, something went wrong.