Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2017 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a42cc000486d5551d3849f3517d4b3a7 to your computer and use it in GitHub Desktop.
Save anonymous/a42cc000486d5551d3849f3517d4b3a7 to your computer and use it in GitHub Desktop.
{
"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"
}
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!");
}
[package]
authors = ["roblabla <unfiltered@roblab.la>"]
name = "libtransistor-sys"
version = "0.1.0"
[build-dependencies]
bindgen = "0.31.3"
[dependencies.libc]
version = "0.2.33"
default-features = false
#![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
Copy link

   Compiling libc v0.2.33
   Compiling libtransistor-sys v0.1.0 (file:///home/roblabla/Dropbox/dev/src/rust/libtransistor-rs/libtransistor-sys)
error[E0463]: can't find crate for `std`
  |
  = note: the `aarch64-nintendo-horizon` target may not be installed

error: aborting due to previous error

error: Could not compile `libc`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment