Created
November 10, 2017 17:59
-
-
Save anonymous/a42cc000486d5551d3849f3517d4b3a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"abi-blacklist": [ | |
"stdcall", | |
"fastcall", | |
"vectorcall", | |
"thiscall", | |
"win64", | |
"sysv64" | |
], | |
"arch": "aarch64", | |
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", | |
"env": "horizon", | |
"has-elf-tls": false, | |
"has-rpath": true, | |
"linker-flavor": "ld", | |
"llvm-target": "aarch64-unknown-none", | |
"max-atomic-width": 128, | |
"position-independent-executables": true, | |
"os": "horizon", | |
"pre-link-args": { | |
"gcc": [ | |
"-Wl,--as-needed", | |
"-Wl,-z,noexecstack" | |
] | |
}, | |
"relro-level": "full", | |
"target-endian": "little", | |
"target-pointer-width": "64", | |
"target-c-int-width": "32", | |
"vendor": "nintendo", | |
"cpu": "cortex-a53", | |
"eliminate-frame-pointer": false, | |
"panic-strategy": "abort", | |
"dynamic-linking": true, | |
"linker": "ld.lld" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate bindgen; | |
use std::env; | |
use std::path::PathBuf; | |
fn main() { | |
println!("cargo:rustc-link-lib=static=transistor.nro"); | |
println!("cargo:rustc-link-search=native=libtransistor/build/lib"); | |
let bindings = bindgen::Builder::default() | |
.header("libtransistor/include/libtransistor/nx.h") | |
// Don't use host headers, to make sure we're building against newlib | |
.clang_arg("-nostdinc") | |
// Include the newlib/transistor headers, and the clang builtin headers | |
.clang_args(&["-isystem", "/usr/lib/clang/5.0.0/include"]) | |
.clang_args(&["-isystem", "libtransistor/newlib/newlib/libc/include"]) | |
.clang_args(&["-isystem", "libtransistor/newlib/newlib/libc/sys/switch/include"]) | |
.clang_arg("-Ilibtransistor/include") | |
// We don't need to define those types, rust has them already anyways. | |
// Blacklisting avoids a bug in bindgen where it creates cyclic references | |
// (pub type u8 = u8) | |
.blacklist_type("u(8|16|32|64)") | |
.use_core() | |
.ctypes_prefix("::libc") | |
.rustfmt_bindings(true) | |
.rustfmt_configuration_file(None) | |
.generate() | |
.expect("Unable to generate bindings"); | |
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | |
bindings | |
.write_to_file(out_path.join("bindings.rs")) | |
.expect("Couldn't write bindings!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
authors = ["roblabla <[email protected]>"] | |
name = "libtransistor-sys" | |
version = "0.1.0" | |
[build-dependencies] | |
bindgen = "0.31.3" | |
[dependencies.libc] | |
version = "0.2.33" | |
default-features = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
extern crate libc; | |
include!(concat!(env!("OUT_DIR"), "/bindings.rs")); | |
#[cfg(test)] | |
mod tests { | |
#[test] | |
fn it_works() { | |
assert_eq!(2 + 2, 4); | |
} | |
} |
roblabla
commented
Nov 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment