Skip to content

Commit

Permalink
Merge branch 'master' into UpdateTWPhrasesIT
Browse files Browse the repository at this point in the history
  • Loading branch information
BYVoid committed Jul 26, 2024
2 parents b2a8b60 + edbe199 commit 0435ab4
Show file tree
Hide file tree
Showing 60 changed files with 1,424 additions and 252 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.2.1
16 changes: 16 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: C++ CI with Bazel

on:
push:
branches: [master, bazel]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- run: bazel build //:opencc
- run: bazel test --test_output=all //src/... //data/... //test/...
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: C/C++ CI
name: C++ CI with CMake

on:
push:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -32,9 +32,9 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --exclude deps --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build and install
run: python setup.py build_ext install
run: python -m pip install .
- name: Test with pytest
run: cd python && pytest
run: pytest python/

test-pypi:
strategy:
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Build package and upload from docker (Linux)
if: runner.os == 'Linux'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.cproject
/.vscode
/.mypy_cache
/bazel-*
/build
/other
/doc/html
Expand All @@ -15,3 +16,4 @@
/xcode
/node_modules
/*.egg-info
/.venv/
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CMakeLists.txt
/deps/gtest*
/deps/pybind*
/deps/tclap*
/bazel-*
/build
/debug
/dist
Expand Down
19 changes: 19 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "opencc",
hdrs = [
"//src:Export.hpp",
"//src:SimpleConverter.hpp",
"//src:opencc.h",
],
data = [
"//data/config",
"//data/dictionary:binary_dictionaries",
"//data/dictionary:text_dictionaries",
],
strip_include_prefix = "src",
deps = [
"//src:opencc",
],
)
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ set (PACKAGE_URL https://github.com/BYVoid/Opencc)
set (PACKAGE_BUGREPORT https://github.com/BYVoid/Opencc/issues)
set (OPENCC_VERSION_MAJOR 1)
set (OPENCC_VERSION_MINOR 1)
set (OPENCC_VERSION_REVISION 7)
set (OPENCC_VERSION_REVISION 8)

if (CMAKE_BUILD_TYPE MATCHES Debug)
set (version_suffix .Debug)
Expand Down Expand Up @@ -79,10 +79,10 @@ endif()
######## Directory

set (DIR_PREFIX ${CMAKE_INSTALL_PREFIX})
set (DIR_INCLUDE ${DIR_PREFIX}/include/)
set (DIR_SHARE ${DIR_PREFIX}/share/)
set (DIR_ETC ${DIR_PREFIX}/etc/)
set (DIR_LIBRARY ${DIR_PREFIX}/lib${LIB_SUFFIX}/)
set (DIR_INCLUDE ${DIR_PREFIX}/include)
set (DIR_SHARE ${DIR_PREFIX}/share)
set (DIR_ETC ${DIR_PREFIX}/etc)
set (DIR_LIBRARY ${DIR_PREFIX}/lib${LIB_SUFFIX})

if (DEFINED SHARE_INSTALL_PREFIX)
set (DIR_SHARE ${SHARE_INSTALL_PREFIX})
Expand All @@ -100,8 +100,8 @@ if (DEFINED LIB_INSTALL_DIR)
set (DIR_LIBRARY ${LIB_INSTALL_DIR})
endif (DEFINED LIB_INSTALL_DIR)

set (DIR_SHARE_OPENCC ${DIR_SHARE}/opencc/)
set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale/)
set (DIR_SHARE_OPENCC ${DIR_SHARE}/opencc)
set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale)

######## Configuration

Expand Down
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
graft src
graft deps
graft test
graft data
graft doc
include CMakeLists.txt OpenCCConfig.cmake.in opencc.pc.in README* LICENSE*
global-exclude *~ *.py[cod] *.so
include python/**/__init__.py
graft python/tests
15 changes: 15 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"Open Chinese Convert"

module(
name = "opencc",
version = "1.1.8",
compatibility_level = 1,
)

bazel_dep(name = "darts-clone", version = "0.32")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "marisa-trie", version = "0.2.6")
bazel_dep(name = "rapidjson", version = "1.1.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.34.0")
bazel_dep(name = "tclap", version = "1.2.5")
147 changes: 147 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ xcode-build:
xcodebuild build)

python-build:
python setup.py build_ext
echo "No need to build"

python-install: python-build
python setup.py install
python -m pip install .

python-dist: python-build
python setup.py bdist_wheel
python -m build

python-test: python-build
cd python; pytest .
Expand Down
Loading

0 comments on commit 0435ab4

Please sign in to comment.