Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary flag from rustfmt invocation #1148

Merged

Conversation

Projects
None yet
4 participants
@roblabla
Copy link
Contributor

roblabla commented Nov 10, 2017

From rustfmt docs, the --write-mode flag is unecessary when passing the flag to stdin. If we leave it there, rustfmt-nightly complains that it cannot find the file named --write-mode, so let's remove the flag.

here's the logs when I leave the flag :

Error: file `--write-mode=display` does not exist
Error { repr: Custom(Custom { kind: Other, error: StringError("Internal rustfmt error") }) }
The build.rs :
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)")
        .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!");
}
Remove unnecessary flag from rustfmt invocation
From rustfmt docs, the --write-mode flag is unecessary when passing the
flag to stdin. If we leave it there, rustfmt-nightly complains that it
cannot find the file named --write-mode, so let's remove the flag.
@fitzgen

This comment has been minimized.

Copy link
Member

fitzgen commented Nov 10, 2017

@bors-servo r+

Thanks @roblabla !

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Nov 10, 2017

📌 Commit a6d4506 has been approved by fitzgen

bors-servo added a commit that referenced this pull request Nov 10, 2017

Auto merge of #1148 - roblabla:bugfix-unnecessaryWriteModeRustfmt, r=…
…fitzgen

Remove unnecessary flag from rustfmt invocation

From rustfmt docs, the --write-mode flag is unecessary when passing the flag to stdin. If we leave it there, rustfmt-nightly complains that it cannot find the file named --write-mode, so let's remove the flag.

here's the logs when I leave the flag :

```
Error: file `--write-mode=display` does not exist
Error { repr: Custom(Custom { kind: Other, error: StringError("Internal rustfmt error") }) }
```

<details>
<summary>The build.rs : </summary>

```rust
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)")
        .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!");
}
```
</details>
@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Nov 10, 2017

⌛️ Testing commit a6d4506 with merge 433e9c0...

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Nov 10, 2017

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing 433e9c0 to master...

@bors-servo bors-servo merged commit a6d4506 into rust-lang:master Nov 10, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.