Skip to content

Commit

Permalink
Fix cross compilation from Linux to Windows (#125)
Browse files Browse the repository at this point in the history
Use the proper path building in the build script in lib.rs by exposing
it as an environment variable.
  • Loading branch information
paholg authored Aug 26, 2019
1 parent e79dd13 commit e23e8af
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version. Much of typenum should work on as low a version as 1.20.0, but that is

### Unreleased

### 1.11.2 (2019-08-26)
- [fixed] Cross compilation from Linux to Windows.

### 1.11.1 (2019-08-25)
- [fixed] Builds on earlier Rust builds again and added Rust 1.22.0 to Travis to prevent future breakage.

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "typenum"
build = "build/main.rs"
version = "1.11.1"
version = "1.11.2"
authors = [
"Paho Lurie-Gregg <[email protected]>",
"Andre Bogus <[email protected]>"
Expand Down
1 change: 1 addition & 0 deletions build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn main() {

let out_dir = env::var("OUT_DIR").unwrap();
let dest = Path::new(&out_dir).join("consts.rs");
println!("cargo:rustc-env=TYPENUM_BUILD_OP={}", dest.display());

let mut f = File::create(&dest).unwrap();

Expand Down
1 change: 1 addition & 0 deletions build/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct Op {
pub fn write_op_macro() -> ::std::io::Result<()> {
let out_dir = ::std::env::var("OUT_DIR").unwrap();
let dest = ::std::path::Path::new(&out_dir).join("op.rs");
println!("cargo:rustc-env=TYPENUM_BUILD_CONSTS={}", dest.display());
let mut f = ::std::fs::File::create(&dest).unwrap();

// Operator precedence is taken from
Expand Down
11 changes: 3 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,9 @@
// trace_macros!(true);

use core::cmp::Ordering;
#[cfg(not(target_os = "windows"))]
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
#[cfg(not(target_os = "windows"))]
include!(concat!(env!("OUT_DIR"), "/op.rs"));
#[cfg(target_os = "windows")]
include!(concat!(env!("OUT_DIR"), "\\consts.rs"));
#[cfg(target_os = "windows")]
include!(concat!(env!("OUT_DIR"), "\\op.rs"));

include!(env!("TYPENUM_BUILD_OP"));
include!(env!("TYPENUM_BUILD_CONSTS"));

pub mod bit;
pub mod int;
Expand Down

0 comments on commit e23e8af

Please sign in to comment.