- C++ 85.2%
- Rust 6.6%
- CMake 4.2%
- Nix 3.5%
- Shell 0.5%
yayy! Reviewed-on: #60 Reviewed-by: Chris <chris@noreply.git.realliance.net> |
||
|---|---|---|
| .forgejo | ||
| docs | ||
| extern | ||
| src | ||
| src_cpp | ||
| tests | ||
| tools | ||
| .clang-format | ||
| .clang-tidy | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| clippy.toml | ||
| CMakeLists.txt | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
| rust-toolchain.toml | ||
| rustfmt.toml | ||
| shell.nix | ||
libmahjong
libmahjong is a library for running games of Riichi Mahjong, originally built to power Riichi Royale, and later Gametable. The library uses a state machine to represent the status of the game, and allows for players (whether artificial or real) to interact at appropriate times.
Development
libmahjong is being rewritten in Rust. The Rust crate lives in src/ and builds with Cargo, on the toolchain pinned by rust-toolchain.toml. The original C++ engine lives in src_cpp/ and still builds with CMake, as described below.
With Nix, nix develop opens the Rust shell and nix develop .#cpp opens the C++ one. nix build builds the Rust crate, and nix build .#clang builds the C++ library.
Getting Started
Install the following dependencies:
-
git -
cmake -
clangorgcc
Optionally:
-
gtest(For testing support) -
ctcache(For quicker compilation with clang-tidy enabled)
Clone the repository:
git clone https://git.realliance.net/libmahjong/libmahjong.git
Run the following commands within the project directory:
# Bootstrap CMake Environment
cmake -S . -B build
# CMake project opinions (default)
* libmahjong_build_tools: whether or not examples should be built (ON)
* libmahjong_build_tests: whether or not tests should be built (ON)
* libmahjong_use_clang_utils: whether or not project is compiled with clang-tidy (ON)
# Build Project
cmake --build build
Testing and Documentation
The test suite is located in tests/ and can be run with ctest --test-dir build --output-on-failure
CI runs on Forgejo Actions (.forgejo/workflows/): every pull request into next, and every push to it, builds nix build .#clang and runs the tests with nix build .#tests. Each push to next also builds .#coverage and publishes the report at https://libmahjong.realliance.page/libmahjong/.