Skip to content

Commit

Permalink
Add feature force_unix_path_separator
Browse files Browse the repository at this point in the history
This allows for building without using Cargo, such as with Bazel.
  • Loading branch information
paholg committed Apr 14, 2020
1 parent f31472d commit 694130d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The MSRV (Minimum Supported Rust Version) is 1.22.0, and typenum is tested again
version. Much of typenum should work on as low a version as 1.20.0, but that is not guaranteed.

### Unreleased
- [added] Feature `force_unix_path_separator` to support building without Cargo.
- [added] Greatest common divisor operator `Gcd` with alias `Gcf`.
- [added] `gcd` to the `op!` macro.
- [changed] Added `Copy` bound to `Rhs` of `Mul<Rhs>` impl for `<TArr<V, A>`.
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
no_std = []
i128 = []
strict = []
force_unix_path_separator = []
2 changes: 1 addition & 1 deletion build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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());
println!("cargo:rustc-env=TYPENUM_BUILD_CONSTS={}", dest.display());

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

Expand Down
2 changes: 1 addition & 1 deletion build/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +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());
println!("cargo:rustc-env=TYPENUM_BUILD_OP={}", dest.display());
let mut f = ::std::fs::File::create(&dest).unwrap();

// Operator precedence is taken from
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@

use core::cmp::Ordering;

include!(env!("TYPENUM_BUILD_OP"));
include!(env!("TYPENUM_BUILD_CONSTS"));
#[cfg(feature = "force_unix_path_separator")]
mod generated {
include!(concat!(env!("OUT_DIR"), "/op.rs"));
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
}

#[cfg(not(feature = "force_unix_path_separator"))]
mod generated {
include!(env!("TYPENUM_BUILD_OP"));
include!(env!("TYPENUM_BUILD_CONSTS"));
}

pub mod bit;
pub mod int;
Expand All @@ -79,6 +88,7 @@ pub mod uint;
pub mod array;

pub use consts::*;
pub use generated::consts;
pub use marker_traits::*;
pub use operator_aliases::*;
pub use type_operators::*;
Expand Down

0 comments on commit 694130d

Please sign in to comment.