Skip to content

Commit 36b8801

Browse files
committed
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.
1 parent b33f8b6 commit 36b8801

30 files changed

+113
-258
lines changed

.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
paths = ["diesel"]
1+
paths = ["diesel", "diesel_codegen_syntex"]

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ script:
2222
fi &&
2323
(cd diesel_cli && travis-cargo test -- --no-default-features --features "$BACKEND") &&
2424
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then
25-
(cd diesel_codegen && travis-cargo test -- --no-default-features --features "nightly $BACKEND")
25+
(cd diesel_codegen_syntex && travis-cargo test -- --no-default-features --features "$BACKEND")
2626
else
27-
(cd diesel_codegen && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND")
27+
(cd diesel_codegen_syntex && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND")
2828
fi &&
2929
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then
30-
(cd diesel_tests && travis-cargo test -- --no-default-features --features "unstable $BACKEND")
30+
(cd diesel_tests && travis-cargo test -- --no-default-features --features "unstable_$BACKEND")
3131
else
32-
(cd diesel_tests && travis-cargo test -- --no-default-features --features "with-syntex $BACKEND")
32+
(cd diesel_tests && travis-cargo test -- --no-default-features --features "stable_$BACKEND")
3333
fi &&
3434
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then
3535
(cd diesel_compile_tests && travis-cargo test)

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
3131
* Diesel now targets `nightly-2016-07-07`. Future releases will update to a
3232
newer nightly version on the date that Rust releases.
3333

34+
* `diesel_codegen` has been split into two crates. `diesel_codegen` and
35+
`diesel_codegen_syntex`. See [this commit](FIXME COMMIT LINK HERE) for
36+
migration information.
37+
3438
* Most structs that implement `Queryable` will now also need
3539
`#[derive(Identifiable)]`.
3640

bin/test

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
set -e
33

44
if [ "$1" == "integration" ] && [ "$2" == "sqlite" ]; then
5-
(cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable sqlite" --no-default-features)
5+
(cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable_sqlite" --no-default-features)
66
elif [ "$1" == "integration" ]; then
7-
(cd diesel_tests && cargo test --features "unstable postgres" --no-default-features)
7+
(cd diesel_tests && cargo test --features "unstable_postgres" --no-default-features)
88
elif [ "$1" == "compile" ]; then
99
(cd diesel_compile_tests && cargo test)
1010
else
1111
(cd diesel && cargo test --features "unstable chrono sqlite")
1212
(cd diesel_cli && cargo test --features "postgres" --no-default-features)
1313
(cd diesel_cli && cargo test --features "sqlite" --no-default-features)
14-
(cd diesel_codegen && cargo test --no-default-features --features "nightly postgres")
15-
(cd diesel_tests && cargo test --features "unstable postgres" --no-default-features)
16-
(cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable sqlite" --no-default-features)
14+
(cd diesel_codegen_syntex && cargo test --no-default-features --features "postgres")
15+
(cd diesel_tests && cargo test --features "unstable_postgres" --no-default-features)
16+
(cd diesel_tests && DATABASE_URL=/tmp/test.db cargo test --features "unstable_sqlite" --no-default-features)
1717
(cd diesel_compile_tests && cargo test)
1818
fi;

diesel_codegen/Cargo.toml

+4-18
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,18 @@ name = "diesel_codegen"
33
version = "0.6.1"
44
authors = ["Sean Griffin <sean@seantheprogrammer.com>"]
55
license = "MIT OR Apache-2.0"
6-
build = "build.rs"
76
description = "Annotations to remove boilerplate from Diesel"
87
documentation = "https://github.com/diesel-rs/diesel/blob/master/diesel_codegen"
98
homepage = "http://diesel.rs"
109
repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_codegen"
1110
keywords = ["orm", "database", "postgres", "sql", "codegen"]
1211

13-
[build-dependencies]
14-
syntex = { version = ">= 0.37.0, < 0.39.0", optional = true }
15-
syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true }
16-
1712
[dependencies]
18-
syntex = { version = ">= 0.37.0, < 0.39.0", optional = true }
19-
syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true }
20-
diesel = { git = "https://github.com/diesel-rs/diesel.git", default-features = false }
21-
22-
[dev-dependencies]
23-
tempdir = "0.3.4"
13+
diesel_codegen_syntex = { path = "../diesel_codegen_syntex", default-features = false }
2414

2515
[features]
26-
default = ["with-syntex", "postgres"]
27-
nightly = []
28-
with-syntex = ["syntex", "syntex_syntax"]
29-
postgres = ["diesel/postgres"]
30-
sqlite = ["diesel/sqlite"]
16+
postgres = ["diesel_codegen_syntex/postgres"]
17+
sqlite = ["diesel_codegen_syntex/sqlite"]
3118

3219
[lib]
33-
name = "diesel_codegen"
34-
crate-type = ["rlib", "dylib"]
20+
plugin = true

diesel_codegen/README.md

-173
This file was deleted.

diesel_codegen/src/lib.in.rs

-10
This file was deleted.

diesel_codegen/src/lib.rs

+4-40
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
1-
#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin_registrar, quote))]
2-
#![deny(warnings)]
1+
#![feature(rustc_private, plugin_registrar)]
32

4-
#[macro_use] extern crate diesel;
5-
6-
#[cfg(feature = "with-syntex")]
7-
extern crate syntex;
8-
9-
#[cfg(feature = "with-syntex")]
10-
extern crate syntex_syntax as syntax;
11-
12-
#[cfg(not(feature = "with-syntex"))]
3+
extern crate diesel_codegen_syntex;
134
extern crate syntax;
14-
15-
#[cfg(not(feature = "with-syntex"))]
165
extern crate rustc_plugin;
176

18-
#[cfg(feature = "with-syntex")]
19-
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
20-
21-
#[cfg(not(feature = "with-syntex"))]
22-
include!("lib.in.rs");
23-
24-
mod util;
25-
26-
#[cfg(feature = "with-syntex")]
27-
pub fn register(reg: &mut syntex::Registry) {
28-
reg.add_attr("feature(custom_derive)");
29-
reg.add_attr("feature(custom_attribute)");
30-
31-
reg.add_decorator("derive_Queryable", queryable::expand_derive_queryable);
32-
reg.add_decorator("derive_Identifiable", identifiable::expand_derive_identifiable);
33-
reg.add_decorator("insertable_into", insertable::expand_insert);
34-
reg.add_decorator("changeset_for", update::expand_changeset_for);
35-
reg.add_decorator("has_many", associations::expand_has_many);
36-
reg.add_decorator("belongs_to", associations::expand_belongs_to);
37-
reg.add_macro("embed_migrations", migrations::expand_embed_migrations);
38-
reg.add_macro("infer_table_from_schema", schema_inference::expand_load_table);
39-
reg.add_macro("infer_schema", schema_inference::expand_infer_schema);
40-
41-
reg.add_post_expansion_pass(util::strip_attributes);
42-
}
7+
use diesel_codegen_syntex::*;
438

44-
#[cfg_attr(not(feature = "with-syntex"), plugin_registrar)]
45-
#[cfg(not(feature = "with-syntex"))]
9+
#[plugin_registrar]
4610
pub fn register(reg: &mut rustc_plugin::Registry) {
4711
use syntax::parse::token::intern;
4812
use syntax::ext::base::MultiDecorator;

diesel_codegen_syntex/Cargo.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "diesel_codegen_syntex"
3+
version = "0.6.1"
4+
authors = ["Sean Griffin <sean@seantheprogrammer.com>"]
5+
license = "MIT OR Apache-2.0"
6+
build = "build.rs"
7+
description = "Allows use of `diesel_codegen` with `syntex`"
8+
documentation = "https://github.com/diesel-rs/diesel/blob/master/diesel_codegen"
9+
homepage = "http://diesel.rs"
10+
repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_codegen"
11+
keywords = ["orm", "database", "postgres", "sql", "codegen"]
12+
13+
[build-dependencies]
14+
syntex = { version = ">= 0.37.0, < 0.39.0", optional = true }
15+
syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true }
16+
17+
[dependencies]
18+
syntex = { version = ">= 0.37.0, < 0.39.0", optional = true }
19+
syntex_syntax = { version = ">= 0.37.0, < 0.39.0", optional = true }
20+
diesel = { git = "https://github.com/diesel-rs/diesel.git", default-features = false }
21+
22+
[dev-dependencies]
23+
tempdir = "0.3.4"
24+
25+
[features]
26+
default = ["with-syntex"]
27+
with-syntex = ["syntex", "syntex_syntax"]
28+
postgres = ["diesel/postgres"]
29+
sqlite = ["diesel/sqlite"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

diesel_codegen_syntex/src/lib.in.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub mod associations;
2+
mod attr;
3+
pub mod identifiable;
4+
pub mod insertable;
5+
pub mod migrations;
6+
mod model;
7+
pub mod queryable;
8+
pub mod schema_inference;
9+
pub mod update;

0 commit comments

Comments
 (0)