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

Allow passing additional clang arguments #57

Merged
merged 2 commits into from
Jul 2, 2017

Conversation

shinglyu
Copy link
Contributor

Hi Kyle,

I'm trying to fix a linux 64 to 32 cross compiling issue for Stylo. Therefore I'm going to need to pass some additional clang argumens from bindgen.

I'm sorry the code involves some ugly transformations between &[&str] to Vec<String> and back, I'll be glad to change it if there are more elegant way to do it.

src/support.rs Outdated
@@ -59,10 +59,10 @@ pub struct Clang {
impl Clang {
//- Constructors -----------------------------

fn new(path: PathBuf) -> Clang {
fn new(path: PathBuf, args: &Vec<String>) -> Clang {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Make this &[String] instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or even I: Iterator<Item=&'a str> or something like that).

src/support.rs Outdated
@@ -78,9 +78,9 @@ impl Clang {
/// first directory searched. Then, the directory returned by `llvm-config --bindir` is
/// searched. On OS X systems, `xcodebuild -find clang` will next be queried. Last, the
/// directories in the system's `PATH` are searched.
pub fn find(path: Option<&Path>) -> Option<Clang> {
pub fn find(path: Option<&Path>, args: &Vec<String>) -> Option<Clang> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this.

src/support.rs Outdated
fn parse_search_paths(path: &Path, language: &str, args: &Vec<String>) -> Option<Vec<PathBuf>> {
let clang_args = vec!["-E", "-x", language, "-", "-v"];
let mut clang_args_temp: Vec<String> = clang_args.into_iter().map(|s| s.to_owned()).collect();
clang_args_temp.extend(args.iter().cloned());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just:

let mut clang_args = vec!["..."];
clang_args.extend_from_slice(args);
run_clang(..);

@shinglyu
Copy link
Contributor Author

I pushed the nits in a separate commit for ease of review. Let me know when it's good to go and I'll squash them into one.

@KyleMayes
Copy link
Owner

LGTM, but could you fix the test, thanks.

@KyleMayes KyleMayes merged commit a8b1159 into KyleMayes:master Jul 2, 2017
@KyleMayes
Copy link
Owner

Released as part of v0.19.0.

bors-servo pushed a commit to rust-lang/rust-bindgen that referenced this pull request Jul 4, 2017
Passing additional clang arguments for Linux 32 cross compiling

This is for https://bugzilla.mozilla.org/show_bug.cgi?id=1366050

But it has to wait for KyleMayes/clang-sys#57 to land and version number bumped.

(I'm making up the new version numbers for now.)

r? @emilio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants