Giter Site home page Giter Site logo

erfs's Introduction

Embedded Resource Filesystem (C/Rust)

This project allow application written in C/C++ or rust to embed required resource files into executable binaries.

There are 2 components:

  • A command-line tool named erfs_gen can travel a resource directory and generate .c/.h source file which should be added into your project.
  • A runtime library in pure C or Rust lib crate to access the content of resources.

Usage

Command-Line Interface

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 

C developer

Code generation

A cmake function is useful to generate the files duration 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.

C API

Please refer to the header file (erfs-rt/src/resource_fs.h) and UT example(erfs-rt/tests/erfs_test.cpp) for detail.

Rust developer

Rust code generation

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.

Rust API

Please refer to rust wrapper (erfs-rt/src/lib.rs) and UT example(erfs-example/src/main.rs) for detail.

TODO

  • symbolic/hard link support
  • pure Rust implementation for runtime library and code generator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.