Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.84 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.84 KB

Bindgen Project Generator - bindgen-init

This script automates the process of setting up a Cargo project with the bindgen crate installed, generating Rust bindings for a C header file, and creating the necessary build configuration files.

Prerequisites

Installation

To install the package, follow these steps:

  1. Clone this repository by executing the command:
git clone https://github.com/garychia/bindgen-init.git
  1. Change the working directory to the cloned repository:
cd bindgen-init
  1. Install the package using pip:
pip install .

Usage

Run the script using the following command:

python -m bindgeninit [project_name] [-b]
  • project_name: The name of the Cargo project to be created.
  • -b or --bin: (Optional) Generates a Cargo binary project instead of a library project.

The script performs the following steps:

  1. Creates a new Cargo project with the specified project name.
  2. Installs the bindgen crate using cargo add.
  3. Copies the example C header file to the project directory.
  4. Generates a build.rs file with the necessary configuration for bindgen.
  5. Modifies the lib.rs file to include the generated bindings.
  6. Prints a success message.

Configuration

To customize the build configuration, modify the build.rs file generated by the script. You can specify the directories where required shared libraries are located and link the necessary libraries using the println! statements.

Example Header File

The script includes an example C header file (example.h) in the project directory. You can replace it with your own C header file and modify the build.rs file accordingly.

License

This script is released under the MIT License.