Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
softprops committed Jan 16, 2017
0 parents commit 911703a
Show file tree
Hide file tree
Showing 8 changed files with 39,039 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
Cargo.lock
*.bk
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "openapi"
version = "0.1.0"
authors = ["softprops <[email protected]>"]
build = "build.rs"

[build-dependencies]
serde_codegen = "0.8"
glob = "0.2.11"

[dependencies]
serde = "0.8"
serde_json = "0.8"
serde_yaml = "0.5"
41 changes: 41 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extern crate glob;
extern crate serde_codegen;

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

fn main() {
// Don't re-run this script unless one of the inputs has changed.
for entry in glob::glob("src/**/*.rs.in").expect("Failed to read glob pattern") {
println!("cargo:rerun-if-changed={}", entry.unwrap().display());
}

let out_dir = env::var_os("OUT_DIR").unwrap();

// Switch to our `src` directory so that we have the right base for our
// globs, and so that we won't need to strip `src/` off every path.
env::set_current_dir("src").unwrap();

for entry in glob::glob("**/*.rs.in").expect("Failed to read glob pattern") {
match entry {
Ok(src) => {
let mut dst = Path::new(&out_dir).join(&src);

// Change ".rs.in" to ".rs".
dst.set_file_name(src.file_stem().expect("Failed to get file stem"));
dst.set_extension("rs");

// Make sure our target directory exists. We only need
// this if there are extra nested sudirectories under src/.
fs::create_dir_all(dst.parent().unwrap()).unwrap();

// Process our source file.
serde_codegen::expand(&src, &dst).unwrap();
}
Err(e) => {
panic!("Error globbing: {}", e);
}
}
}
}
Loading

0 comments on commit 911703a

Please sign in to comment.