Skip to content

Commit

Permalink
always pass -target flag to clang
Browse files Browse the repository at this point in the history
Currently, com-scrape only passes the `-target` flag to clang if the `TARGET`
env var is present and it doesn't match the value of `HOST_TARGET` (which is
set to the `TARGET` env var passed to com-scrape's build script). Instead,
always pass the value of `TARGET` if it is present, and `HOST_TARGET`
otherwise.
  • Loading branch information
micahrj committed Feb 3, 2024
1 parent cabdab3 commit a6f29d5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions com-scrape/src/generator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::collections::HashSet;
use std::env;
use std::error::Error;
Expand Down Expand Up @@ -144,18 +145,14 @@ impl Generator {
clang_sys::load()?;
}

let mut clang_target = None;
if let Ok(target) = env::var("TARGET") {
if target != HOST_TARGET {
clang_target = Some(rust_to_clang_target(&target));
}
}
let rust_target = if let Ok(target) = env::var("TARGET") {
Cow::from(target)
} else {
Cow::from(HOST_TARGET)
};
let clang_target = rust_to_clang_target(&rust_target);

let unit = TranslationUnit::new(
source.as_ref(),
&self.include_paths,
clang_target.as_deref(),
)?;
let unit = TranslationUnit::new(source.as_ref(), &self.include_paths, Some(&clang_target))?;

let namespace = Namespace::parse(&unit.cursor(), &self)?;

Expand Down

0 comments on commit a6f29d5

Please sign in to comment.