Frankoslaw / FExers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exers πŸ’»

Exers is a rust library for compiling and running code in different languages and runtimes.

Usage example

fn main() {
    // Imports...

    let code = r#"
    fn main() {
        println!("Hello World!");
    }
    "#;

    let compiled_code = RustCompiler.compile(&mut code.as_bytes(), Default::default());
    let result = WasmRuntime.run(&compiled_code, Default::default()).unwrap();
}

Supported languages πŸ“š

Language Supported Runtimes Required Dependencies
Rust Wasm, Native Rustc
C++ Wasm, Native clang++, wasi sdk (wasm)
Python Native python3, Cython (optional)
JavaScript Wasm (read docs), Native node js, javy (wasm)
C# None ---
Go None ---

Jailed runtime is not listed, because it supports all languages that support the Native runtime. (In theory)

Available runtimes πŸƒβ€β™‚οΈ

Runtime Status
WASM Implemented
Native Implemented
Jailed Implemented (Requires more testing)
Firecracker Not started
Docker/Podman Not started

Contributing 🀝

If you want to contribute to this project, please keep my code style and formatting. I use rustfmt to format my code. Please also make sure that your code compiles and that all tests pass. If you want to add a new language or runtime, remember to write tests and comment your code well.

Commits should follow the Conventional Commits specification.

Requirements πŸ“‹

WASM

If you want to use the WASM runtime, you need to install the wasm32-wasi target for rustc. You can do this by running rustup target add wasm32-wasi.

For C++ you need to install wasi-sdk or other WASI sdk/libc and specify WASI_SDK environment variable to point to the sdk.

Native

Native runtime just requires dependencies for the language you want to use.

Additional features ✨

wasm-llvm

This feature allows you to use the LLVM backend for the WASM runtime. LLVM offers better performance, but has longer compilation times.

cython

This feature allows you to use Cython for the Python runtime. This makes code execution faster, but requires Cython to be installed.

Bundled πŸ“¦ (planned)

contains all the dependencies for all the languages and runtimes, so you don't have to install them yourself. This may be useful for some use cases, but it will make the library much larger (probably over 1GB).

Examples πŸ“„

Examples can be found in the examples directory. To run them, you need to install the required dependencies for the languages you want to use. You can then run the examples with cargo run --example <example_name>.

Dockerfile 🐳

This project contains a Dockerfile that can be used to build a docker image with all the required dependencies for all the languages and runtimes. This image can be used to base your own images on πŸ˜„. I'm currently working on minimizing the size of the image (currently about 2GB) and allowing you to choose which languages and runtimes you want to include.

Warning: I've not tested the image yet, so it might not work for some languages and runtimes.

About

License:MIT License


Languages

Language:Rust 96.7%Language:Dockerfile 2.3%Language:Shell 1.0%