36 lines
1.1 KiB
Markdown
36 lines
1.1 KiB
Markdown
# bin2hpp
|
|
|
|
> _One day we'll get #embed and std::embed, but today is not that day._
|
|
|
|
CLI tool for converting files into header files which one can use to directly embed data in their C++ projects.
|
|
|
|
## Building
|
|
|
|
1. `cargo build`
|
|
|
|
## Usage
|
|
|
|
### Basic usage
|
|
|
|
`$ bin2hpp -i ~/my_library.dll --overwrite` will generate an `my_library_dll.h` file in your current working directory containing something similar to the following:
|
|
|
|
```c
|
|
// Generated by bin2hpp 0.2.4
|
|
#ifndef MY_LIBRARY_DLL_H
|
|
#define MY_LIBRARY_DLL_H
|
|
#define MY_LIBRARY_DLL_LEN 9728
|
|
const unsigned char MY_LIBRARY_DLL[MY_LIBRARY_DLL_LEN] = {0x4d,0x5a,0x90,0x0,0x3,0x0,0x0, ...};
|
|
#else
|
|
extern const unsigned char MY_LIBRARY_DLL[MY_LIBRARY_DLL_LEN];
|
|
#endif
|
|
```
|
|
|
|
### Note about CLI arguments
|
|
|
|
Command line arguments are not positional. The input file path argument is the
|
|
only required command line argument. The command line argument parser will
|
|
choose the first instance of any provided argument. For example, if you provide
|
|
the `-i` argument twice; only the first `-i ./file/path` will be used. This behaviour
|
|
should not be relied upon as the implementation of the command line argument
|
|
parser may change at any time.
|