-
Notifications
You must be signed in to change notification settings - Fork 32
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
Make cross-compilation possible #40
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,11 +77,34 @@ impl Display for LinkingOptions { | |
} | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-env-changed=PQ_LIB_DIR"); | ||
println!("cargo:rerun-if-env-changed=PQ_LIB_STATIC"); | ||
println!("cargo:rerun-if-env-changed=TARGET"); | ||
|
||
if let Ok(lib_dir) = env::var("PQ_LIB_DIR") { | ||
// if target is specified the more concrete pq_lib_dir overwrites a more general one | ||
let lib_dir = if let Ok(target) = env::var("TARGET") { | ||
let pq_lib_dir_for_target = format!("PQ_LIB_DIR_{}", target.to_ascii_uppercase().replace("-", "_")); | ||
println!("cargo:rerun-if-env-changed={}", pq_lib_dir_for_target); | ||
if let Ok(pg_lib_path) = env::var(pq_lib_dir_for_target.clone()) { | ||
let path = PathBuf::from(&pg_lib_path); | ||
if !path.exists() { | ||
panic!("Folder {:?} doesn't exist in the configured path: {:?}", pq_lib_dir_for_target, path); | ||
} | ||
println!("{:?} = {:?}", pq_lib_dir_for_target, pg_lib_path); // list in output for small debuggability | ||
Ok(pg_lib_path) | ||
} | ||
else{ | ||
println!("cargo:rerun-if-env-changed=PQ_LIB_DIR"); | ||
println!("PQ_LIB_DIR = {:?}", env::var("PQ_LIB_DIR")); | ||
env::var("PQ_LIB_DIR") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to unify this block with that one below as they are identical. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refactored it into a function |
||
} | ||
} | ||
else{ | ||
println!("cargo:rerun-if-env-changed=PQ_LIB_DIR"); | ||
println!("PQ_LIB_DIR = {:?}", env::var("PQ_LIB_DIR")); | ||
env::var("PQ_LIB_DIR") | ||
}; | ||
|
||
if let Ok(lib_dir) = lib_dir { | ||
println!("cargo:rustc-link-search=native={}", lib_dir); | ||
} else if configured_by_pkg_config() { | ||
return // pkg_config does everything for us, including output for cargo | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is not performed for the "normal"
PQ_LIB_DIR
variable at all. Either we need to change that there or remove it from here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the "normal" variable as well. As I find it to be good practice to give as many hints as possible as to why something fails.