From 36b8801bf5e9594443743e6a7c62e29d3dce36b7 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 1 Aug 2016 13:43:10 -0400 Subject: [PATCH] Split `diesel_codegen` into two crates. Having the same crate for both has caused a ton of problems with linking. I had hoped to just use cargo features for this, but it wasn't working out that way. `diesel_codegen` now only targets nightly. `diesel_codegen_syntex` handles syntex separately (and also contains the common code between the two crates). Neither crate includes the postgres feature by default. How to migrate -------------- If your Cargo.toml previously looked like this: ```rust [build-dependencies] diesel_codegen = "0.6.0" ``` it should change to ```rust [build-dependencies] diesel_codegen_syntex = { version = "0.7.0", features = ["postgres"] } ``` (You'll need to change the `extern crate` line in `build.rs`) If your Cargo.toml previously looked like this: ```rust [dependencies] diesel_codegen = { version = "0.6.0", default-features = false, features = ["nightly", "postgres"] } ``` it should change to ```rust [dependencies] diesel_codegen = { version = "0.7.0", features = ["postgres"] } ``` I've had to split out the cargo features in our test suite, since Cargo doesn't give me a way to say "turn on the diesel_codegen_syntex/postgres" feature only if the `with-syntex` and `postgres` features are on, and I don't want to have to build syntex every time I run the tests against nightly. --- .cargo/config | 2 +- .travis.yml | 8 +- CHANGELOG.md | 4 + bin/test | 10 +- diesel_codegen/Cargo.toml | 22 +-- diesel_codegen/README.md | 173 ------------------ diesel_codegen/src/lib.in.rs | 10 - diesel_codegen/src/lib.rs | 44 +---- diesel_codegen_syntex/Cargo.toml | 29 +++ .../build.rs | 0 .../src/associations/belongs_to.rs | 0 .../src/associations/has_many.rs | 0 .../src/associations/mod.rs | 0 .../src/attr.rs | 0 .../src/dummy_schema_inference.rs | 0 .../src/identifiable.rs | 0 .../src/insertable.rs | 0 diesel_codegen_syntex/src/lib.in.rs | 9 + diesel_codegen_syntex/src/lib.rs | 42 +++++ .../src/migrations.rs | 0 .../src/model.rs | 0 .../src/queryable.rs | 0 .../src/schema_inference/data_structures.rs | 0 .../src/schema_inference/mod.rs | 0 .../src/schema_inference/pg.rs | 0 .../src/schema_inference/sqlite.rs | 0 .../src/update.rs | 0 .../src/util.rs | 0 diesel_tests/Cargo.toml | 16 +- diesel_tests/build.rs | 2 +- 30 files changed, 113 insertions(+), 258 deletions(-) delete mode 100644 diesel_codegen/README.md delete mode 100644 diesel_codegen/src/lib.in.rs create mode 100644 diesel_codegen_syntex/Cargo.toml rename {diesel_codegen => diesel_codegen_syntex}/build.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/associations/belongs_to.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/associations/has_many.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/associations/mod.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/attr.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/dummy_schema_inference.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/identifiable.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/insertable.rs (100%) create mode 100644 diesel_codegen_syntex/src/lib.in.rs create mode 100644 diesel_codegen_syntex/src/lib.rs rename {diesel_codegen => diesel_codegen_syntex}/src/migrations.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/model.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/queryable.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/schema_inference/data_structures.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/schema_inference/mod.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/schema_inference/pg.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/schema_inference/sqlite.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/update.rs (100%) rename {diesel_codegen => diesel_codegen_syntex}/src/util.rs (100%) diff --git a/.cargo/config b/.cargo/config index f7a0ea304fff..bdf8de476f30 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1 +1 @@ -paths = ["diesel"] +paths = ["diesel", "diesel_codegen_syntex"] diff --git a/.travis.yml b/.travis.yml index 5fbfdcc083d1..f9103d697d5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,14 +22,14 @@ script: fi && (cd diesel_cli && travis-cargo test -- --no-default-features --features "$BACKEND") && if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then - (cd diesel_codegen && travis-cargo test -- --no-default-features --features "nightly $BACKEND") + (cd diesel_codegen_syntex && travis-cargo test -- --no-default-features --features "$BACKEND") else - (cd diesel_codegen && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND") + (cd diesel_codegen_syntex && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND") fi && if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then - (cd diesel_tests && travis-cargo test -- --no-default-features --features "unstable $BACKEND") + (cd diesel_tests && travis-cargo test -- --no-default-features --features "unstable_$BACKEND") else - (cd diesel_tests && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND") + (cd diesel_tests && travis-cargo test -- --no-default-features --features "stable_$BACKEND") fi && if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then (cd diesel_compile_tests && travis-cargo test) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed5f04307eec..ac0eb871dc20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/ * Diesel now targets `nightly-2016-07-07`. Future releases will update to a newer nightly version on the date that Rust releases. +* `diesel_codegen` has been split into two crates. `diesel_codegen` and + `diesel_codegen_syntex`. See [this commit](FIXME COMMIT LINK HERE) for + migration information. + * Most structs that implement `Queryable` will now also need `#[derive(Identifiable)]`. diff --git a/bin/test b/bin/test index e24c888fb638..b4d5111bf12f 100755 --- a/bin/test +++ b/bin/test @@ -2,17 +2,17 @@ set -e if [ "$1" == "integration" ] && [ "$2" == "sqlite" ]; then - (cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable sqlite" --no-default-features) + (cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable_sqlite" --no-default-features) elif [ "$1" == "integration" ]; then - (cd diesel_tests && cargo test --features "unstable postgres" --no-default-features) + (cd diesel_tests && cargo test --features "unstable_postgres" --no-default-features) elif [ "$1" == "compile" ]; then (cd diesel_compile_tests && cargo test) else (cd diesel && cargo test --features "unstable chrono sqlite") (cd diesel_cli && cargo test --features "postgres" --no-default-features) (cd diesel_cli && cargo test --features "sqlite" --no-default-features) - (cd diesel_codegen && cargo test --no-default-features --features "nightly postgres") - (cd diesel_tests && cargo test --features "unstable postgres" --no-default-features) - (cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable sqlite" --no-default-features) + (cd diesel_codegen_syntex && cargo test --no-default-features --features "postgres") + (cd diesel_tests && cargo test --features "unstable_postgres" --no-default-features) + (cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable_sqlite" --no-default-features) (cd diesel_compile_tests && cargo test) fi; diff --git a/diesel_codegen/Cargo.toml b/diesel_codegen/Cargo.toml index 9045d7822f4e..79555f272a53 100644 --- a/diesel_codegen/Cargo.toml +++ b/diesel_codegen/Cargo.toml @@ -3,32 +3,18 @@ name = "diesel_codegen" version = "0.6.1" authors = ["Sean Griffin "] license = "MIT OR Apache-2.0" -build = "build.rs" description = "Annotations to remove boilerplate from Diesel" documentation = "https://github.com/diesel-rs/diesel/blob/master/diesel_codegen" homepage = "http://diesel.rs" repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_codegen" keywords = ["orm", "database", "postgres", "sql", "codegen"] -[build-dependencies] -syntex = { version = ">= 0.37.0, < 0.39.0", optional = true } -syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true } - [dependencies] -syntex = { version = ">= 0.37.0, < 0.39.0", optional = true } -syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true } -diesel = { git = "https://github.com/diesel-rs/diesel.git", default-features = false } - -[dev-dependencies] -tempdir = "0.3.4" +diesel_codegen_syntex = { path = "../diesel_codegen_syntex", default-features = false } [features] -default = ["with-syntex", "postgres"] -nightly = [] -with-syntex = ["syntex", "syntex_syntax"] -postgres = ["diesel/postgres"] -sqlite = ["diesel/sqlite"] +postgres = ["diesel_codegen_syntex/postgres"] +sqlite = ["diesel_codegen_syntex/sqlite"] [lib] -name = "diesel_codegen" -crate-type = ["rlib", "dylib"] +plugin = true diff --git a/diesel_codegen/README.md b/diesel_codegen/README.md deleted file mode 100644 index dd1fffe81169..000000000000 --- a/diesel_codegen/README.md +++ /dev/null @@ -1,173 +0,0 @@ -Diesel Codegen -============ - -Provides various macros and annotations for -[Diesel](http://docs.diesel.rs/diesel/index.html) to reduce the amount of -boilerplate needing to be written. It can be used through `rustc_plugin`, or -`syntex` on stable. - -Using on nightly ----------------- - -Make sure you're on a nightly from 2016-04-25 or later, we don't compile on earlier versions. To use with nightly, you'll want to turn off the default features. Add this -line to your dependencies section in `Cargo.toml` - -```toml -diesel_codegen = { version = "0.5.0", default-features = false, features = ["nightly", "postgres"] } -``` - -Then you'll need to add two lines to the root of your crate. - -```rust -#![feature(custom_derive, custom_attribute, plugin)] -#![plugin(diesel_codegen)] -``` - -After that, you'll be good to go. - -Using on stable ---------------- - -On stable, you'll need to use [`syntex`](https://crates.io/crates/syntex) to -build any modules using our annotations. Add the following to your -build-dependencies. - -```toml -diesel_codegen = "0.5.0" -syntex = "0.28.0" -``` - -You'll need to move any code using annotations into a different file. - -`src/schema.rs` - -```rust -include!(concat!(env!("OUT_DIR"), "/schema.rs")); -``` - -`src/schema.in.rs` - -```rust -#[derive(Queryable)] -pub struct User { - id -> i32, - name -> String, -} -``` - -Then create a `build.rs` with the following: - -```rust -extern crate syntex; -extern crate diesel_codegen; - -use std::env; -use std::path::Path; - -pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - let mut registry = syntex::Registry::new(); - diesel_codegen::register(&mut registry); - - let src = Path::new("src/schema.in.rs"); - let dst = Path::new(&out_dir).join("schema.rs"); - - registry.expand("", &src, &dst).unwrap(); -} -``` - -Note that compiler errors will be reported in the generated file, not the source -file. For that reason, it's often easier to develop with nightly rust, and -deploy or test on stable. You can see an example of how to do this by looking at -[Diesel's tests](https://github.com/diesel-rs/diesel/tree/master/diesel_tests). - -Struct annotations ------------------- - -### `#[derive(Queryable)]` - -Adds an implementation of the [`Queryable`][queryable] trait to the annotated -item. At this time it only supports structs with named fields. Enums and tuple -structs are not supported. - -### `#[insertable_into(table_name)]` - -Adds an implementation of the [`Insertable`][insertable] trait to the annotated -item, targeting the given table. Can only annotate structs and tuple structs. -Enums are not supported. See [field annotations][#field-annotations] for -additional configurations. - -### `#[changeset_for(table_name)]` - -Adds an implementation of the [`AsChangeset`][as_changeset] trait to the -annotated item, targeting the given table. At this time, it only supports -structs with named fields. Tuple structs and enums are not supported. See [field -annotations][#field-annotations] for additional configurations. - -Any fields which are of the type `Option` will be skipped when their value is -`None`. This makes it easy to support APIs where you may not want to update all -of the fields of a record on every request. - -If you'd like `None` to change a field to `NULL`, instead of skipping it, you -can pass the `treat_none_as_null` option like so: `#[changeset_for(posts, -treat_none_as_null="true")]` - -If the struct has a field for the primary key, an additional function, -`save_changes>(&self, connection: &Connection) -> -QueryResult`, will be added to the model. This will persist any changes made, -and return the resulting record. It is intended to be a shorthand for filtering -by the primary key. - -[queryable]: http://docs.diesel.rs/diesel/query_source/trait.Queryable.html -[insertable]: http://docs.diesel.rs/diesel/trait.Insertable.html -[as_changeset]: http://docs.diesel.rs/diesel/query_builder/trait.AsChangeset.html - -Field annotations ------------------ - -### `#[column_name="value"]` - -Any field can be annotated with `column_name=` to have it map to a column with a -different name. This is required for all fields of tuple structs. - -Macros ---------------------- - -### `infer_schema!("database_url")` - -Queries the database for the names of all tables, and calls -`infer_table_from_schema!` for each one. We recommend using with the -[`dotenv`](https://github.com/slapresta/rust-dotenv) crate, and invoking this as -`infer_schema!(dotenv!("DATABASE_URL"))` - -### `infer_table_from_schema!("database_url", "table_name")` - -Establishes a database connection at compile time, loads the schema information -about a table's columns, and invokes -[`table`](http://docs.diesel.rs/diesel/macro.table!.html) for you -automatically. We recommend using with the -[`dotenv`](https://github.com/slapresta/rust-dotenv) crate, and invoking this as -`infer_table_from_schema!(dotenv!("DATABASE_URL"), "table_name")` - -At this time, the schema inference macros do not support types from third party -crates, and having any columns with a type not already supported will result in -a compiler error (please open an issue if this happens unexpectedly for a type -listed in [our -docs](http://docs.diesel.rs/diesel/types/index.html#structs).) - -### `embed_migrations!()` - -This macro will read your migrations at compile time, and embed a module you can -use to execute them at runtime without the migration files being present on the -file system. This is useful if you would like to use Diesel's migration -infrastructure, but want to ship a single executable file (such as for embedded -applications). It can also be used to apply migrations to an in memory database -(Diesel does this for its own test suite). - -You can optionally pass the path to the migrations directory to this macro. When -left unspecified, Diesel Codegen will search for the migrations directory in the -same way that Diesel CLI does. If specified, the path should be relative to the -directory where the macro was invoked (similar to -[`include_str!`][include-str]). - -[include-str]: https://doc.rust-lang.org/nightly/std/macro.include_str!.html diff --git a/diesel_codegen/src/lib.in.rs b/diesel_codegen/src/lib.in.rs deleted file mode 100644 index be5226a3406b..000000000000 --- a/diesel_codegen/src/lib.in.rs +++ /dev/null @@ -1,10 +0,0 @@ -mod associations; -mod attr; -mod identifiable; -mod insertable; -mod migrations; -mod model; -mod queryable; -mod schema_inference; - -mod update; diff --git a/diesel_codegen/src/lib.rs b/diesel_codegen/src/lib.rs index b05c3f79d912..bfe870d42296 100644 --- a/diesel_codegen/src/lib.rs +++ b/diesel_codegen/src/lib.rs @@ -1,48 +1,12 @@ -#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin_registrar, quote))] -#![deny(warnings)] +#![feature(rustc_private, plugin_registrar)] -#[macro_use] extern crate diesel; - -#[cfg(feature = "with-syntex")] -extern crate syntex; - -#[cfg(feature = "with-syntex")] -extern crate syntex_syntax as syntax; - -#[cfg(not(feature = "with-syntex"))] +extern crate diesel_codegen_syntex; extern crate syntax; - -#[cfg(not(feature = "with-syntex"))] extern crate rustc_plugin; -#[cfg(feature = "with-syntex")] -include!(concat!(env!("OUT_DIR"), "/lib.rs")); - -#[cfg(not(feature = "with-syntex"))] -include!("lib.in.rs"); - -mod util; - -#[cfg(feature = "with-syntex")] -pub fn register(reg: &mut syntex::Registry) { - reg.add_attr("feature(custom_derive)"); - reg.add_attr("feature(custom_attribute)"); - - reg.add_decorator("derive_Queryable", queryable::expand_derive_queryable); - reg.add_decorator("derive_Identifiable", identifiable::expand_derive_identifiable); - reg.add_decorator("insertable_into", insertable::expand_insert); - reg.add_decorator("changeset_for", update::expand_changeset_for); - reg.add_decorator("has_many", associations::expand_has_many); - reg.add_decorator("belongs_to", associations::expand_belongs_to); - reg.add_macro("embed_migrations", migrations::expand_embed_migrations); - reg.add_macro("infer_table_from_schema", schema_inference::expand_load_table); - reg.add_macro("infer_schema", schema_inference::expand_infer_schema); - - reg.add_post_expansion_pass(util::strip_attributes); -} +use diesel_codegen_syntex::*; -#[cfg_attr(not(feature = "with-syntex"), plugin_registrar)] -#[cfg(not(feature = "with-syntex"))] +#[plugin_registrar] pub fn register(reg: &mut rustc_plugin::Registry) { use syntax::parse::token::intern; use syntax::ext::base::MultiDecorator; diff --git a/diesel_codegen_syntex/Cargo.toml b/diesel_codegen_syntex/Cargo.toml new file mode 100644 index 000000000000..83e3c3af5886 --- /dev/null +++ b/diesel_codegen_syntex/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "diesel_codegen_syntex" +version = "0.6.1" +authors = ["Sean Griffin "] +license = "MIT OR Apache-2.0" +build = "build.rs" +description = "Allows use of `diesel_codegen` with `syntex`" +documentation = "https://github.com/diesel-rs/diesel/blob/master/diesel_codegen" +homepage = "http://diesel.rs" +repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_codegen" +keywords = ["orm", "database", "postgres", "sql", "codegen"] + +[build-dependencies] +syntex = { version = ">= 0.37.0, < 0.39.0", optional = true } +syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true } + +[dependencies] +syntex = { version = ">= 0.37.0, < 0.39.0", optional = true } +syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true } +diesel = { git = "https://github.com/diesel-rs/diesel.git", default-features = false } + +[dev-dependencies] +tempdir = "0.3.4" + +[features] +default = ["with-syntex"] +with-syntex = ["syntex", "syntex_syntax"] +postgres = ["diesel/postgres"] +sqlite = ["diesel/sqlite"] diff --git a/diesel_codegen/build.rs b/diesel_codegen_syntex/build.rs similarity index 100% rename from diesel_codegen/build.rs rename to diesel_codegen_syntex/build.rs diff --git a/diesel_codegen/src/associations/belongs_to.rs b/diesel_codegen_syntex/src/associations/belongs_to.rs similarity index 100% rename from diesel_codegen/src/associations/belongs_to.rs rename to diesel_codegen_syntex/src/associations/belongs_to.rs diff --git a/diesel_codegen/src/associations/has_many.rs b/diesel_codegen_syntex/src/associations/has_many.rs similarity index 100% rename from diesel_codegen/src/associations/has_many.rs rename to diesel_codegen_syntex/src/associations/has_many.rs diff --git a/diesel_codegen/src/associations/mod.rs b/diesel_codegen_syntex/src/associations/mod.rs similarity index 100% rename from diesel_codegen/src/associations/mod.rs rename to diesel_codegen_syntex/src/associations/mod.rs diff --git a/diesel_codegen/src/attr.rs b/diesel_codegen_syntex/src/attr.rs similarity index 100% rename from diesel_codegen/src/attr.rs rename to diesel_codegen_syntex/src/attr.rs diff --git a/diesel_codegen/src/dummy_schema_inference.rs b/diesel_codegen_syntex/src/dummy_schema_inference.rs similarity index 100% rename from diesel_codegen/src/dummy_schema_inference.rs rename to diesel_codegen_syntex/src/dummy_schema_inference.rs diff --git a/diesel_codegen/src/identifiable.rs b/diesel_codegen_syntex/src/identifiable.rs similarity index 100% rename from diesel_codegen/src/identifiable.rs rename to diesel_codegen_syntex/src/identifiable.rs diff --git a/diesel_codegen/src/insertable.rs b/diesel_codegen_syntex/src/insertable.rs similarity index 100% rename from diesel_codegen/src/insertable.rs rename to diesel_codegen_syntex/src/insertable.rs diff --git a/diesel_codegen_syntex/src/lib.in.rs b/diesel_codegen_syntex/src/lib.in.rs new file mode 100644 index 000000000000..3ae49f9f5dab --- /dev/null +++ b/diesel_codegen_syntex/src/lib.in.rs @@ -0,0 +1,9 @@ +pub mod associations; +mod attr; +pub mod identifiable; +pub mod insertable; +pub mod migrations; +mod model; +pub mod queryable; +pub mod schema_inference; +pub mod update; diff --git a/diesel_codegen_syntex/src/lib.rs b/diesel_codegen_syntex/src/lib.rs new file mode 100644 index 000000000000..25dfcd16387e --- /dev/null +++ b/diesel_codegen_syntex/src/lib.rs @@ -0,0 +1,42 @@ +#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, quote))] +#![deny(warnings)] + +#[macro_use] extern crate diesel; + +#[cfg(feature = "with-syntex")] +extern crate syntex; + +#[cfg(feature = "with-syntex")] +extern crate syntex_syntax as syntax; + +#[cfg(not(feature = "with-syntex"))] +extern crate syntax; + +#[cfg(not(feature = "with-syntex"))] +extern crate rustc_plugin; + +#[cfg(feature = "with-syntex")] +include!(concat!(env!("OUT_DIR"), "/lib.rs")); + +#[cfg(not(feature = "with-syntex"))] +include!("lib.in.rs"); + +mod util; + +#[cfg(feature = "with-syntex")] +pub fn register(reg: &mut syntex::Registry) { + reg.add_attr("feature(custom_derive)"); + reg.add_attr("feature(custom_attribute)"); + + reg.add_decorator("derive_Queryable", queryable::expand_derive_queryable); + reg.add_decorator("derive_Identifiable", identifiable::expand_derive_identifiable); + reg.add_decorator("insertable_into", insertable::expand_insert); + reg.add_decorator("changeset_for", update::expand_changeset_for); + reg.add_decorator("has_many", associations::expand_has_many); + reg.add_decorator("belongs_to", associations::expand_belongs_to); + reg.add_macro("embed_migrations", migrations::expand_embed_migrations); + reg.add_macro("infer_table_from_schema", schema_inference::expand_load_table); + reg.add_macro("infer_schema", schema_inference::expand_infer_schema); + + reg.add_post_expansion_pass(util::strip_attributes); +} diff --git a/diesel_codegen/src/migrations.rs b/diesel_codegen_syntex/src/migrations.rs similarity index 100% rename from diesel_codegen/src/migrations.rs rename to diesel_codegen_syntex/src/migrations.rs diff --git a/diesel_codegen/src/model.rs b/diesel_codegen_syntex/src/model.rs similarity index 100% rename from diesel_codegen/src/model.rs rename to diesel_codegen_syntex/src/model.rs diff --git a/diesel_codegen/src/queryable.rs b/diesel_codegen_syntex/src/queryable.rs similarity index 100% rename from diesel_codegen/src/queryable.rs rename to diesel_codegen_syntex/src/queryable.rs diff --git a/diesel_codegen/src/schema_inference/data_structures.rs b/diesel_codegen_syntex/src/schema_inference/data_structures.rs similarity index 100% rename from diesel_codegen/src/schema_inference/data_structures.rs rename to diesel_codegen_syntex/src/schema_inference/data_structures.rs diff --git a/diesel_codegen/src/schema_inference/mod.rs b/diesel_codegen_syntex/src/schema_inference/mod.rs similarity index 100% rename from diesel_codegen/src/schema_inference/mod.rs rename to diesel_codegen_syntex/src/schema_inference/mod.rs diff --git a/diesel_codegen/src/schema_inference/pg.rs b/diesel_codegen_syntex/src/schema_inference/pg.rs similarity index 100% rename from diesel_codegen/src/schema_inference/pg.rs rename to diesel_codegen_syntex/src/schema_inference/pg.rs diff --git a/diesel_codegen/src/schema_inference/sqlite.rs b/diesel_codegen_syntex/src/schema_inference/sqlite.rs similarity index 100% rename from diesel_codegen/src/schema_inference/sqlite.rs rename to diesel_codegen_syntex/src/schema_inference/sqlite.rs diff --git a/diesel_codegen/src/update.rs b/diesel_codegen_syntex/src/update.rs similarity index 100% rename from diesel_codegen/src/update.rs rename to diesel_codegen_syntex/src/update.rs diff --git a/diesel_codegen/src/util.rs b/diesel_codegen_syntex/src/util.rs similarity index 100% rename from diesel_codegen/src/util.rs rename to diesel_codegen_syntex/src/util.rs diff --git a/diesel_tests/Cargo.toml b/diesel_tests/Cargo.toml index f7982dbaef64..6cd2f3f84446 100644 --- a/diesel_tests/Cargo.toml +++ b/diesel_tests/Cargo.toml @@ -7,7 +7,7 @@ build = "build.rs" [build-dependencies] syntex = { version = "0.38.0", optional = true } -diesel_codegen = { path = "../diesel_codegen", default-features = false } +diesel_codegen_syntex = { path = "../diesel_codegen_syntex", optional = true } dotenv_codegen = { version = "0.9.0", optional = true } diesel = { path = "../diesel", default-features = false } dotenv = { git = "https://github.com/slapresta/rust-dotenv.git" } @@ -16,17 +16,21 @@ dotenv = { git = "https://github.com/slapresta/rust-dotenv.git" } assert_matches = "1.0.1" chrono = { version = "^0.2.17" } diesel = { path = "../diesel", default-features = false, features = ["quickcheck", "chrono", "uuid"] } -diesel_codegen = { path = "../diesel_codegen", default-features = false } +diesel_codegen = { path = "../diesel_codegen", default-features = false, optional = true } dotenv_macros = { version = "0.9.0", optional = true } quickcheck = "0.2.25" uuid = { version = "^0.2.0" } [features] default = ["with-syntex"] -unstable = ["diesel_codegen/nightly", "diesel/unstable", "dotenv_macros"] -with-syntex = ["syntex", "dotenv_codegen", "diesel_codegen/with-syntex"] -postgres = ["diesel/postgres", "diesel_codegen/postgres"] -sqlite = ["diesel/sqlite", "diesel_codegen/sqlite"] +unstable = ["diesel/unstable", "dotenv_macros", "diesel_codegen"] +with-syntex = ["syntex", "dotenv_codegen", "diesel_codegen_syntex"] +postgres = ["diesel/postgres"] +sqlite = ["diesel/sqlite"] +stable_postgres = ["with-syntex", "postgres", "diesel_codegen_syntex/postgres"] +stable_sqlite = ["with-syntex", "sqlite", "diesel_codegen_syntex/sqlite"] +unstable_postgres = ["unstable", "postgres", "diesel_codegen/postgres"] +unstable_sqlite = ["unstable", "sqlite", "diesel_codegen/sqlite"] [[test]] name = "integration_tests" diff --git a/diesel_tests/build.rs b/diesel_tests/build.rs index 56147572d68e..6bb26bcb9e5d 100644 --- a/diesel_tests/build.rs +++ b/diesel_tests/build.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "unstable"))] mod inner { extern crate syntex; - extern crate diesel_codegen; + extern crate diesel_codegen_syntex as diesel_codegen; extern crate dotenv_codegen; use std::env;