No description
Find a file
2023-02-21 04:34:49 +02:00
build-config Update documentation 2023-02-21 04:34:49 +02:00
src Update documentation 2023-02-21 04:34:49 +02:00
.gitignore Remove the libc dependency from linux builds 2023-02-16 03:31:21 +02:00
build.rs Update documentation 2023-02-21 04:34:49 +02:00
Cargo.lock Update documentation 2023-02-21 04:34:49 +02:00
Cargo.toml Update documentation 2023-02-21 04:34:49 +02:00
LICENSE Add license and rename 2021-11-18 02:05:45 +02:00
README.md Update documentation 2023-02-21 04:34:49 +02:00

A minimal no_std application linking against SDL2. There are various OS-and-architecture-specific hacks to set this up in src/no_std_wrangling.rs.

The motivation behind this crate is to allow making games which use SDL as their interface to the OS, but are otherwise much leaner than regular Rust programs to be a project I can use to learn about cross-platform systems programming. Shipping real programs with a base like this doesn't seem appropriate, I'm sure there are very good reasons for everything in the standard library and whatever it depends on.

Features

  • Support for Linux and Windows.
  • Glue between the log crate and the SDL2 logging functions, so you can just log::info!() and it'll use the SDL2 logging functions.
  • A safe(ish) iterator for command line arguments.
  • A panic handler that logs the panic message, and then pops up a message box or executes a breakpoint trap, in release and debug builds respectively.
  • A cross config that compiles against SDL 2.0.4, so building your Linux builds with cross will also check that you're not using any newer SDL functions.
  • Portable libc setup?
    • On Windows, this is achieved by statically building in the UCRT, seems to work pretty great.
    • On Linux, it's very hard to avoid glibc, so we don't. To ensure wide compatibility, there's custom Dockerfiles for cross in build-config. Building with cross results in executables that can at most require glibc 2.23 (the glibc used by Ubuntu Xenial), which is from 2016. In practice, since generally not all of libc is used, the glibc requirement is even lower - the hello world requires 2.14. Use readelf -V <executable> to check!

Building

Dependencies:

  • Rust and cargo
  • SDL2 development libraries
  • LLVM
  • CMake
  • (On Linux) The -gnu variant of the Rust toolchain (musl does not work)
  • (On Windows) The -msvc variant of the Rust toolchain, and some components from the Visual Studio Installer (should be installable by importing WindowsDeps.vsconfig):
    • Universal C Runtime
    • MSVC
    • Windows 10 SDK (any Windows SDK probably works)

On Linux, install cross and use cross build --release to build, for two good reasons: the build dependencies are satisfied by the Dockerfiles defined in build-config which are read by cross, and cross uses an old Ubuntu image as a base, which makes your binaries compatible with systems with an old glibc.

On all platforms, consider using the bundled-sdl feature for shipping builds, as it will also build SDL alongside your executable, so that you can distribute that to users that don't have SDL on their system.

License

This crate is distributed under the MIT license.