Skip to content
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

With syntex feature #8

Merged
merged 3 commits into from
Mar 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "textnonce"
version = "0.2.4"
version = "0.2.5"
description = "Text based random nonce generator"
authors = [
"Mike Dilger <[email protected]>",
Expand All @@ -13,13 +13,18 @@ license = "MIT OR Apache-2.0"
keywords = [ "nonce", "random" ]
build = "build.rs"

[features]
default = ["with-syntex"]
with-syntex = ["syntex", "serde_codegen"]

[build-dependencies]
serde_codegen = "^0"
syntex = "^0"
serde_codegen = { version = "^0", optional = true }
syntex = { version = "^0", optional = true }

[dependencies]
rand = "^0.3"
time = "^0.1"
rustc-serialize = "^0.3"
serde = "^0"
clippy = { version = "^0", optional = true }
serde_macros = { version = "^0", optional = true }
clippy = { version = "^0", optional = true }
34 changes: 23 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
extern crate syntex;
extern crate serde_codegen;
#[cfg(feature = "with-syntex")]
mod inner {
extern crate syntex;
extern crate serde_codegen;

use std::env;
use std::path::Path;
use std::env;
use std::path::Path;

fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();

let src = Path::new("src/lib.rs.in");
let dst = Path::new(&out_dir).join("lib.rs");

let src = Path::new("src/lib.rs.in");
let dst = Path::new(&out_dir).join("lib.rs");
let mut registry = syntex::Registry::new();

let mut registry = syntex::Registry::new();
serde_codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
}
}

serde_codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
#[cfg(not(feature = "with-syntex"))]
mod inner {
pub fn main() {}
}

fn main() {
inner::main();
}
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]

#![cfg_attr(not(feature = "with-syntex"), feature(custom_attribute, custom_derive, plugin))]
#![cfg_attr(not(feature = "with-syntex"), plugin(serde_macros))]

extern crate rand;
extern crate time;
extern crate rustc_serialize;
extern crate serde;

include!(concat!(env!("OUT_DIR"), "/lib.rs"));

#[cfg(not(feature = "with-syntex"))]
include!("lib.rs.in");

#[cfg(feature = "with-syntex")]
include!(concat!(env!("OUT_DIR"), "/lib.rs"));