|
1 | | -# Serial |
| 1 | +# C++ Bindings for Linux |
| 2 | + |
| 3 | +[](https://github.com/Serial-IO/cpp-bindings-linux/actions/workflows/build_binary.yml) |
| 4 | +[](https://jsr.io/@serial/cpp-bindings-linux) |
| 5 | + |
| 6 | +Linux shared library for serial communication. It implements the |
| 7 | +[`cpp-core`](https://github.com/Serial-IO/cpp-core) interface and provides functions for discovering, opening, |
| 8 | +configuring, reading from, and writing to serial ports. |
| 9 | + |
| 10 | +## Requirements |
| 11 | + |
| 12 | +- Linux |
| 13 | +- Git |
| 14 | +- CMake 3.30 or newer |
| 15 | +- Ninja |
| 16 | +- A compiler with C++26 support (CI uses GCC 16) |
| 17 | + |
| 18 | +CMake downloads `cpp-core` and GoogleTest automatically during configuration. |
| 19 | + |
| 20 | +## Build |
| 21 | + |
| 22 | +```sh |
| 23 | +git clone https://github.com/Serial-IO/cpp-bindings-linux.git |
| 24 | +cd cpp-bindings-linux |
| 25 | +cmake --preset linux-gcc-release |
| 26 | +cmake --build --preset linux-gcc-release --target cpp_bindings_linux |
| 27 | +``` |
| 28 | + |
| 29 | +The shared library is written to `build/libcpp_bindings_linux.so`. |
| 30 | + |
| 31 | +To select a specific compiler, add it while configuring, for example: |
| 32 | + |
| 33 | +```sh |
| 34 | +cmake --preset linux-gcc-release \ |
| 35 | + -DCMAKE_C_COMPILER=gcc-16 \ |
| 36 | + -DCMAKE_CXX_COMPILER=g++-16 |
| 37 | +``` |
| 38 | + |
| 39 | +## Tests |
| 40 | + |
| 41 | +Build and run the C++ test suite: |
| 42 | + |
| 43 | +```sh |
| 44 | +cmake --build --preset linux-gcc-release --target cpp_bindings_linux_tests |
| 45 | +ctest --test-dir build --output-on-failure |
| 46 | +``` |
| 47 | + |
| 48 | +Tests that require a serial device use `SERIAL_TEST_PORT`. They are skipped when no suitable device is available. |
| 49 | + |
| 50 | +The optional Deno FFI smoke tests require Deno 2 and a built library: |
| 51 | + |
| 52 | +```sh |
| 53 | +cd integration_tests |
| 54 | +deno task test |
| 55 | +``` |
| 56 | + |
| 57 | +## License |
| 58 | + |
| 59 | +This project is licensed under the [GNU Lesser General Public License v3.0](LICENSE). |
0 commit comments