Skip to content

Commit

Permalink
Remove embed_migrations! temporarily
Browse files Browse the repository at this point in the history
Unfortunately it will be impossible to write this macro using the Macros
1.1 API. While this is an important feature that I want to keep, I more
importantly want to keep the main repository working on stable. It will
have to live as a separate crate, and possibly have an API change to
work around build scripts.
  • Loading branch information
sgrif committed Oct 7, 2016
1 parent ce31e82 commit 250b445
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 512 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist: trusty
rust:
- stable
- beta
- nightly-2016-09-29
- nightly
cache: cargo
addons:
postgresql: '9.4'
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/

[bash completion]: https://github.com/diesel-rs/diesel/blob/b1a0d9901f0f2a8c8d530ccba8173b57f332b891/diesel_cli/README.md#bash-completion

### Removed

* `embed_migrations!` has been removed, as it is incompatible with the Macros
1.1 API. It will be released as a separate crate in the coming weeks.

### Changed

* Structs annotated with `#[has_many]` or `#[belongs_to]` now require
Expand Down
22 changes: 0 additions & 22 deletions diesel_codegen_old/Cargo.toml

This file was deleted.

182 changes: 0 additions & 182 deletions diesel_codegen_old/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions diesel_codegen_old/src/lib.rs

This file was deleted.

11 changes: 5 additions & 6 deletions diesel_codegen_syntex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_codegen"
keywords = ["orm", "database", "postgres", "sql", "codegen"]

[build-dependencies]
syntex = { version = "0.44.0", optional = true }
syntex_syntax = { version = "0.44.0", optional = true }
syntex = { version = "0.44.0" }
syntex_syntax = { version = "0.44.0" }

[dependencies]
syntex = { version = "0.44.0", optional = true }
syntex_syntax = { version = "0.44.0", optional = true }
syntex = { version = "0.44.0" }
syntex_syntax = { version = "0.44.0" }
diesel = { version = "0.7.0", default-features = false }
diesel_codegen_shared = { path = "../diesel_codegen_shared", default-features = false }

[dev-dependencies]
tempdir = "0.3.4"

[features]
default = ["with-syntex", "postgres", "dotenv"]
default = ["postgres", "dotenv"]
dotenv = ["diesel_codegen_shared/dotenv"]
with-syntex = ["syntex", "syntex_syntax"]
postgres = ["diesel/postgres", "diesel_codegen_shared/postgres"]
sqlite = ["diesel/sqlite", "diesel_codegen_shared/sqlite"]
88 changes: 38 additions & 50 deletions diesel_codegen_syntex/build.rs
Original file line number Diff line number Diff line change
@@ -1,58 +1,46 @@
#[cfg(feature = "with-syntex")]
mod inner {
extern crate syntex;
extern crate syntex_syntax as syntax;

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

use self::syntax::codemap::Span;
use self::syntax::ext::base::{self, ExtCtxt};
use self::syntax::tokenstream::TokenTree;

pub fn main() {
with_extra_stack(move || {
let out_dir = env::var_os("OUT_DIR").unwrap();
let mut registry = syntex::Registry::new();

macro_rules! register_quote_macro {
($macro_name: ident, $name: ident) => {
fn $name<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree],
) -> Box<base::MacResult + 'cx> {
syntax::ext::quote::$name(cx, sp, tts)
}

registry.add_macro(stringify!($macro_name), $name);
}
}
extern crate syntex;
extern crate syntex_syntax as syntax;

register_quote_macro!(quote_ty, expand_quote_ty);
register_quote_macro!(quote_item, expand_quote_item);
register_quote_macro!(quote_tokens, expand_quote_tokens);
register_quote_macro!(quote_expr, expand_quote_expr);
use std::env;
use std::path::Path;
use std::thread;

let src = Path::new("src/lib.in.rs");
let dst = Path::new(&out_dir).join("lib.rs");
use self::syntax::codemap::Span;
use self::syntax::ext::base::{self, ExtCtxt};
use self::syntax::tokenstream::TokenTree;

registry.expand("", &src, &dst).unwrap();
});
}
fn main() {
with_extra_stack(move || {
let out_dir = env::var_os("OUT_DIR").unwrap();
let mut registry = syntex::Registry::new();

macro_rules! register_quote_macro {
($macro_name: ident, $name: ident) => {
fn $name<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree],
) -> Box<base::MacResult + 'cx> {
syntax::ext::quote::$name(cx, sp, tts)
}

fn with_extra_stack<F: FnOnce() + Send + 'static>(f: F) {
env::set_var("RUST_MIN_STACK", "16777216"); // 16MB
thread::spawn(f).join().unwrap();
}
}
registry.add_macro(stringify!($macro_name), $name);
}
}

register_quote_macro!(quote_ty, expand_quote_ty);
register_quote_macro!(quote_item, expand_quote_item);
register_quote_macro!(quote_tokens, expand_quote_tokens);
register_quote_macro!(quote_expr, expand_quote_expr);

#[cfg(not(feature = "with-syntex"))]
mod inner {
pub fn main() {}
let src = Path::new("src/lib.in.rs");
let dst = Path::new(&out_dir).join("lib.rs");

registry.expand("", &src, &dst).unwrap();
});
}

fn main() {
inner::main();
fn with_extra_stack<F: FnOnce() + Send + 'static>(f: F) {
env::set_var("RUST_MIN_STACK", "16777216"); // 16MB
thread::spawn(f).join().unwrap();
}
1 change: 0 additions & 1 deletion diesel_codegen_syntex/src/lib.in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod associations;
mod attr;
pub mod identifiable;
pub mod insertable;
pub mod migrations;
mod model;
pub mod queryable;
pub mod schema_inference;
Expand Down
Loading

0 comments on commit 250b445

Please sign in to comment.