-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from jdroenner/build.rs
Add build.rs to gdal-sys
- Loading branch information
Showing
11 changed files
with
65 additions
and
13 deletions.
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
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
name = "gdal-sys" | ||
version = "0.1.0" | ||
authors = ["Johannes Drönner <[email protected]>"] | ||
build="build.rs" | ||
|
||
|
||
[dependencies] | ||
libc = "0.2.13" | ||
libc = "0.2.20" |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
|
||
fn main() { | ||
|
||
let link_type = "dylib"; | ||
let lib_name = "gdal"; | ||
|
||
#[cfg(windows)] | ||
{ | ||
use std::path::Path; | ||
use std::env; | ||
|
||
// get the path to GDAL_HOME | ||
let home_path = env::var("GDAL_HOME").expect("Environment variable $GDAL_HOME not found!"); | ||
|
||
// detect the path to gdal_i.lib (works for MSVC and GNU) | ||
let lib_suffix = "_i"; | ||
let lib_search_path = Path::new(&home_path).join("lib"); | ||
let lib_path = lib_search_path.join(&format!("{}{}.lib", lib_name, lib_suffix)); | ||
|
||
if lib_search_path.exists() && lib_path.exists() { | ||
println!("cargo:rustc-link-search={}", lib_search_path.to_string_lossy()); | ||
println!("cargo:rustc-link-lib={}={}", link_type, format!("{}{}",lib_name, lib_suffix)); | ||
} else { | ||
|
||
#[cfg(target_env="msvc")] | ||
{ | ||
panic!("windows-msvc requires gdal_i.lib to be found in $GDAL_HOME\\lib."); | ||
} | ||
|
||
#[cfg(target_env="gnu")] | ||
{ | ||
// detect if a gdal{version}.dll is available | ||
let versions = [201, 200, 111, 110]; | ||
let bin_path = Path::new(&home_path).join("bin"); | ||
if let Some(version) = versions.iter().find(|v| bin_path.join(&format!("{}{}.dll", lib_name, v)).exists()){ | ||
println!("cargo:rustc-link-search={}", bin_path.to_string_lossy()); | ||
println!("cargo:rustc-link-lib={}={}", link_type, format!("{}{}",lib_name, version)); | ||
} | ||
else { | ||
panic!("windows-gnu requires either gdal_i.lib in $GDAL_HOME\\lib OR gdal{version}.dll in $GDAL_HOME\\bin."); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(unix)] | ||
{ | ||
println!("cargo:rustc-link-lib={}={}", link_type, lib_name); | ||
} | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -12,4 +12,4 @@ pub mod ogr_enums; | |
pub mod osr; | ||
|
||
// cpl modules | ||
pub mod cpl_error; | ||
pub mod cpl_error; |
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
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
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
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