Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/williamvenner/gluac-rs
👨💻 Rust GLua bytecode compiler
https://github.com/williamvenner/gluac-rs
bytecode glua gluac gmod lua luajit rust
Last synced: 18 days ago
JSON representation
👨💻 Rust GLua bytecode compiler
- Host: GitHub
- URL: https://github.com/williamvenner/gluac-rs
- Owner: WilliamVenner
- License: mit
- Created: 2021-06-05T17:28:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-11T19:20:08.000Z (4 months ago)
- Last Synced: 2024-10-11T11:33:47.109Z (about 1 month ago)
- Topics: bytecode, glua, gluac, gmod, lua, luajit, rust
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 10
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 👨💻 gluac-rs
Compile Garry's Mod Lua into bytecode using Rust!
## Features
* Compatible with Windows and Linux
* Works with 32-bit and 64-bit branches of the game (you must compile for the correct target however)
* Thread-safe## Usage
Add to your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) file:
```toml
[dependencies]
gluac-rs = "*"
```#### [`parking_lot`](https://crates.io/crates/parking_lot) support
This crate supports the [`parking_lot`](https://crates.io/crates/parking_lot) Mutex, just add the `parking_lot` feature flag like so:
```toml
[dependencies]
gluac-rs = { version = "*", features = ["parking_lot"] }
```## Example
```rust
// A utility macro for user-friendly generation of Lua-compatible CStrings.
use gluac::lua_string;// The instance of our bytecode compiler. This internally creates and prepares a Lua state and closes it when dropped.
let compiler: BytecodeCompiler = gluac::compiler();// Compiling a Lua source code string
let result: Result, BytecodeError> = compiler.compile_string(lua_string!(r#"print("Hello, world!")"#));
...// Compiling a file
let result: Result, BytecodeError> = compiler.compile_file(lua_string!(r#"path/to/file.lua"#));
...
```## Dependencies
This crate requires a few dependencies to be in the same directory as the executable.
### Where to find them
You can find these libraries in your Garry's Mod installation, they appear to pop up in a number of different paths on different platforms and branches, so here's all the ones I know of:
* `bin/`
* `bin/win64`
* `bin/linux32`
* `bin/linux64`
* `garrysmod/bin`Take care to use the correct dependencies for your target branch of the game (32-bit/64-bit)
### Windows
* `lua_shared.dll`
* `tier0.dll`
* `vstdlib.dll`### Linux
You may also need to add the directory to the `LD_LIBRARY_PATH` environment variable.
* `lua_shared.so`
* `libtier0.so`
* `libvstdlib.so`
* `libsteam_api.so` (32-bit only)I think older Garry's Mod versions have `_srv` suffixes in the file names for these libraries. These are also supported.
## Credits
[Willox](https://github.com/willox) - base code for Lua bindings and lua_shared loading
[Mats](https://github.com/m4tsa) - helping :D