|
| 1 | +# Generating Bindings with the CLI |
| 2 | + |
| 3 | +Statically linked executables are provided with each release for Linux and macOS. Head over to the [releases page] to download the latest version for your platform. |
| 4 | + |
| 5 | + [releases page]: https://github.com/kornilova-l/scala-native-bindgen/releases |
| 6 | + |
| 7 | +@@@ note |
| 8 | + |
| 9 | +In the following we assume you have renamed the downloaded `scala-native-bindgen-$PLATFORM` file to `scala-native-bindgen`. |
| 10 | + |
| 11 | +@@@ |
| 12 | + |
| 13 | +## Command Line Usage |
| 14 | + |
| 15 | +When generating bindings with the CLI, you need to specify the header file and provide the name of the created bindings using the `--name` option: |
| 16 | + |
| 17 | +```sh |
| 18 | +scala-native-bindgen --name fnmatch /usr/include/fnmatch.h -- |
| 19 | +``` |
| 20 | + |
| 21 | +When running the CLI it will also yield warnings along with the translation. To keep only the bindings please redirect the output to a file like this: |
| 22 | + |
| 23 | +```sh |
| 24 | +scala-native-bindgen --name fnmatch /usr/include/fnmatch.h -- > fnmatch.scala |
| 25 | +``` |
| 26 | + |
| 27 | +By default it is assumed that you want to link with a library based on the name option. |
| 28 | +In case the name of the library to link with is different from the binding name provide the library name using `--link`: |
| 29 | + |
| 30 | +```sh |
| 31 | +scala-native-bindgen --name zlib --link z /usr/include/zlib.h -- |
| 32 | +``` |
| 33 | + |
| 34 | +If the binding does not require any linking, pass `--no-link`: |
| 35 | + |
| 36 | +```sh |
| 37 | +scala-native-bindgen --name fnmatch --no-link /usr/include/fnmatch.h -- |
| 38 | +``` |
| 39 | + |
| 40 | +For libraries that require linking you m |
| 41 | + |
| 42 | +## Options |
| 43 | + |
| 44 | +The generated bindings can be configured using the different options and it is also possible to pass arguments directly to the Clang compiler using the `--extra-arg*` options. |
| 45 | + |
| 46 | +| Option | Description |
| 47 | +|----------------------|---------------------------------------------------------------------------------| |
| 48 | +| `--link` | Library to link with, e.g. `--link` uv for libuv. |
| 49 | +| `--no-link` | Library does not require linking. |
| 50 | +| `--name` | Scala object name that contains bindings. Default value set to library name. |
| 51 | +| `--package` | Package name of generated Scala file. |
| 52 | +| `--exclude-prefix` | Functions and unused typedefs will be removed if their names have given prefix. |
| 53 | +| `--binding-config` | Path to a config file that contains the information about bindings that should be reused. See @ref:[Integrating Bindings](integrating-bindings.md) for more information. |
| 54 | +| `--extra-arg` | Additional argument to append to the compiler command line. |
| 55 | +| `--extra-arg-before` | Additional argument to prepend to the compiler command line. |
0 commit comments