7 releases

0.3.2 Jun 24, 2024
0.3.1 Jun 24, 2024
0.2.2 Jun 23, 2024
0.1.0 Jun 22, 2024

#570 in Programming languages

Download history 9/week @ 2024-09-10 1/week @ 2024-09-17 5/week @ 2024-09-24 1/week @ 2024-10-01

194 downloads per month

MIT license

110KB
511 lines

racket-sys

crates.io

Rust bindings to Racket C API

About Racket: https://racket-lang.org/.

Prerequisites:

  • Base env: Rust toolchain, Clang toolchain and Racket installation
  • Windows: Visual Studio
  • MacOS: Xcode CommandLine tools, iconv, ncurses
  • Linux:
    • Only tested on Ubuntu 24.04
    • sudo apt install racket libncurses-dev, liblz4-dev, libzstd-dev

Installation:

Use bundled Racket (default feature):

This crate includes a prebuilt Racket runtime for Windows, MacOS, and Linux.

  • For Windows and MacOS, the bundled Racket 8.13 comes from official Racket distribution.
  • For Linux, the bundled Racket 8.10 comes from Ubuntu APT.

Use system Racket:

Set environment variables (see below):

  • RACKET_CS_VERSION: Only for MacOS. If not set, default to 8.13.

  • RACKET_CS_HOME: Racket installation directory. If not set, default to:

    • Windows: C:\Program Files\Racket
    • MacOS: /Applications/Racket v{RACKET_CS_VERSION}
    • Linux: /usr

Examples:

  • helloworld examples/helloworld.rs:

    cargo run --example helloworld
    

    screenshot on Windows:

  • factorial examples/factorial.rs and examples/factorial.rkt:

    This example demos how to require Racket module from Rust code.

    cargo run --example factorial
    

    screenshot on Windows:

    Note: set env variable RKT_COLLECTS_DIR to racket installation/collects. For example, on MacOS:

    RKT_COLLECTS_DIR=/Applications/Racket\ v8.13/collects cargo run --example factorial
    

APIs:

https://rn7s2.github.io/racket-sys/racket_sys/

Read https://docs.racket-lang.org/inside/cs-embedding.html for more information on how to embed Racket in your application.

No runtime deps

~0–2MB
~40K SLoC