Skip to content

A tool that automatically sets up a Cargo project with bindgen

License

Notifications You must be signed in to change notification settings

garychia/bindgen-init

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A tool that automatically sets up a Cargo project with bindgen

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages