Crates.io | erfs-rt |
lib.rs | erfs-rt |
version | 0.1.2 |
source | src |
created_at | 2020-02-10 11:33:50.948221 |
updated_at | 2020-02-23 11:15:41.133841 |
description | Embedded resource file system(C/Rust): runtime api to access embedded resources. |
homepage | https://github.com/tinglou/erfs |
repository | https://github.com/tinglou/erfs |
max_upload_size | |
id | 206978 |
size | 20,376 |
This project allow application written in C/C++ or rust to embed required resource files into executable binaries.
There are 2 components:
erfs_gen
can travel a resource directory and generate .c/.h source file which should be added into your project.Usage is described as below:
$./erfs-gen
Usage: ./erfs-gen [options] <src_dir> <id> <dest_dir>
Options:
--gzip compress file if needed.
--rust generate rust binding codes.
where,
<src_dir>: point to the top level directory contains resources.
<id>: the identity of the resource file system, and a executable may have multiple ERFS instances.
<dest_dir>: to specify where the source files are generated.
A cmake function is useful to generate the files during building time.
function(gen_erfs_source sourcedir id target)
add_custom_command(
OUTPUT ${target}/erfs_${id}.c ${target}/erfs_${id}.h
COMMAND ${ERFS_GEN} --gzip --rust ${sourcedir} ${id} ${target}
COMMENT "Generating ERFS source file from: ${sourcedir}"
)
endfunction()
gen_erfs_source("${CMAKE_CURRENT_SOURCE_DIR}/erfs-rt" "rfsrc" "${CMAKE_CURRENT_BINARY_DIR}")
Please refer to the CMakeList.txt
for detail.
Please refer to the header file (erfs-rt/src/resource_fs.h
) and UT example(erfs-rt/tests/erfs_test.cpp
) for detail.
A build.rs is required to generate the .c/.h/.rs files and compile the c files. Please refer to erfs-example/build.rs
for detail.
Please refer to rust wrapper (erfs-rt/src/lib.rs
) and UT example(erfs-example/src/main.rs
) for detail.