Skip to content

Commit

Permalink
Factor out a sys crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
im-apbecker committed Apr 23, 2022
1 parent 14f3008 commit 90b72a8
Show file tree
Hide file tree
Showing 12 changed files with 4,124 additions and 4,467 deletions.
19 changes: 0 additions & 19 deletions .devcontainer/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions .devcontainer/devcontainer.json

This file was deleted.

2 changes: 1 addition & 1 deletion example/Cargo.toml
Expand Up @@ -2,7 +2,7 @@
name = "example"
version = "0.1.0"
authors = ["Adam Becker <im.adam.becker@gmail.com>"]
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
12 changes: 12 additions & 0 deletions libretro-rs-sys/Cargo.toml
@@ -0,0 +1,12 @@
[package]
name = "libretro-rs-sys"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2"

[build-dependencies]
bindgen = "0.59"
3 changes: 3 additions & 0 deletions libretro-rs-sys/README.md
@@ -0,0 +1,3 @@
# libretro-rs-sys

Raw API bindings for `libretro.h`, minus the forward declarations for functions.
25 changes: 25 additions & 0 deletions libretro-rs-sys/build.rs
@@ -0,0 +1,25 @@
extern crate bindgen;

use std::env;
use std::path::PathBuf;

const LIBRETRO_HEADER_FILE: &'static str = "include/libretro.h";

fn main() {
println!("cargo:rerun-if-changed={}", LIBRETRO_HEADER_FILE);

let bindings = bindgen::Builder::default()
.header(LIBRETRO_HEADER_FILE)
.allowlist_type("^retro_.+$")
.allowlist_var("^RETRO_.+$")
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
.layout_tests(false)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("libretro.rs"))
.expect("Couldn't write bindings!");
}

0 comments on commit 90b72a8

Please sign in to comment.