use c style instead of python style in cython
[liba.git] / README.md
blob4235039ae22bbddf7091a167c9482d862e2617c0
1 # An algorithm library {#mainpage}
3 [![docs](https://github.com/tqfx/liba/actions/workflows/docs.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/docs.yml)
4 [![conan](https://github.com/tqfx/liba/actions/workflows/conan.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/conan.yml)
5 [![xmake](https://github.com/tqfx/liba/actions/workflows/xmake.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/xmake.yml)
6 [![meson](https://github.com/tqfx/liba/actions/workflows/meson.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/meson.yml)
7 [![msvc](https://github.com/tqfx/liba/actions/workflows/msvc.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/msvc.yml)
8 [![linux](https://github.com/tqfx/liba/actions/workflows/linux.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/linux.yml)
9 [![macos](https://github.com/tqfx/liba/actions/workflows/macos.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/macos.yml)
10 [![mingw](https://github.com/tqfx/liba/actions/workflows/mingw.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/mingw.yml)
11 [![msys2](https://github.com/tqfx/liba/actions/workflows/msys2.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/msys2.yml)
12 [![freebsd](https://github.com/tqfx/liba/actions/workflows/freebsd.yml/badge.svg)](https://github.com/tqfx/liba/actions/workflows/freebsd.yml)
14 ## documentation
16 - [C/C++](https://tqfx.org/liba/)
17 - [Lua](https://tqfx.org/liba/lua/)
18 - [Java](https://tqfx.org/liba/java/)
19 - [Rust](https://tqfx.org/liba/rust/liba/)
21 ## required tools
23 - C/C++ compiler: [tcc](https://bellard.org/tcc) or [gnu](https://gcc.gnu.org) or [llvm](https://clang.llvm.org) or [msvc](https://visualstudio.microsoft.com/visual-cpp-build-tools) etc
25 ## optional tools
27 - [lua](https://www.lua.org)
28 - [java](https://www.oracle.com/java)
29 - [rust](https://www.rust-lang.org)
30 - [emsdk](https://emscripten.org)
31 - [xmake](https://xmake.io)
32 - [cmake](https://cmake.org)
33 - [conan](https://conan.io)
34 - [vcpkg](https://vcpkg.io)
35 - [meson](https://mesonbuild.com)
36 - [python](https://www.python.org)
37 - [quickjs](https://github.com/bellard/quickjs)
39 ## build
41 ### xmake
43 ```bash
44 xmake f
45 xmake
46 xmake i
47 ```
49 ### cmake
51 ```bash
52 cmake -S . -B build
53 cmake --build build
54 cmake --install build
55 ```
57 ### meson
59 ```bash
60 meson setup builddir
61 meson install -C builddir
62 ```
64 ### vcpkg
66 ```bash
67 cmake -S . -B build -DLIBA_VCPKG=1
68 ```
70 ```bash
71 cp -r build/vcpkg/* $VCPKG_INSTALLATION_ROOT
72 ```
74 ```pwsh
75 cp -r -Force build/vcpkg/* $ENV:VCPKG_INSTALLATION_ROOT
76 ```
78 ### conan
80 ```bash
81 conan create .
82 ```
84 ### cargo
86 ```bash
87 cargo build --release
88 ```
90 ### cython
92 ```bash
93 python setup.py build_ext --inplace
94 ```
96 ## usage
98 ### C/C++
100 #### xmake.lua
102 ```lua
103 add_requires("alib") -- static
104 add_requires("liba") -- shared
107 ### CMakeLists.txt
109 ```cmake
110 find_package(liba CONFIG REQUIRED)
111 target_link_libraries(<TARGET> PRIVATE alib) # static
112 target_link_libraries(<TARGET> PRIVATE liba) # shared
115 #### conanfile.txt
117 ```txt
118 [requires]
119 liba/[~0.1]
122 ### Lua
124 ```bash
125 luarocks install liba # release
128 ```bash
129 luarocks install --server=https://luarocks.org/dev liba # latest
132 ```lua
133 local liba = require("liba")
134 print("version", liba.VERSION)
137 ### Java
139 ```java
140 public class Main {
141     public static void main(String[] args) {
142         System.out.println("version " + liba.VERSION);
143     }
147 ### Rust
149 #### Cargo.toml
151 ```toml
152 [dependencies]
153 liba = { git = "https://github.com/tqfx/liba.git" }
156 #### main.rs
158 ```rs
159 use liba;
160 fn main() {
161     println!(
162         "version {}.{}.{}+{}",
163         liba::version::major(),
164         liba::version::minor(),
165         liba::version::patch(),
166         liba::version::tweak()
167     );
171 ### Python
173 ```bash
174 pip install liba # release
177 ```bash
178 pip install git+https://github.com/tqfx/liba.git # latest
181 #### main.py
183 ```py
184 import liba
185 print("version", liba.VERSION)
188 ### JavaScript
190 ```bash
191 npm i @tqfx/liba
194 #### index.js
196 ```js
197 import liba from "@tqfx/liba";
198 console.log(liba.VERSION)
201 ### QuickJS
203 #### main.js
205 ```js
206 import * as liba from "liba.so";
207 console.log("version", liba.VERSION)
210 ## Copyright {#copyright}
212 Copyright (C) 2020-present tqfx, All rights reserved.
214 This Source Code Form is subject to the terms of the Mozilla Public
215 License, v. 2.0. If a copy of the MPL was not distributed with this
216 file, You can obtain one at <https://mozilla.org/MPL/2.0/>.