Skip to content

Commit 12dc94e

Browse files
committed
move the debug file to the target/machine subdirectory
1 parent a13cc18 commit 12dc94e

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ without writing the associated boilerplate.
1414
* transitions can have multiple end states if needed (conditions depending on message content, etc)
1515
* accessors can be generated for state members
1616
* wrapper methods and accessors are generated on the parent enum
17-
* the generated code is also written in the `target/` directory for further inspection
18-
* a dot file is written in the `target/` directory for graph generation
17+
* the generated code is also written in the `target/machine` directory for further inspection
18+
* a dot file is written in the `target/machine` directory for graph generation
1919

2020
## Usage
2121

@@ -252,9 +252,9 @@ impl Traffic {
252252
}
253253
```
254254

255-
The complete generated code can be found in `target/traffic.rs`.
255+
The complete generated code can be found in `target/machine/traffic.rs`.
256256

257-
The machine crate will also generate the `target/traffic.dot` file
257+
The machine crate will also generate the `target/machine/traffic.dot` file
258258
for graphviz usage:
259259

260260
```dot
@@ -267,7 +267,7 @@ Green -> Orange [ label = "PassCar" ];
267267
}
268268
```
269269

270-
`dot -Tpng target/traffic.dot > traffic.png` will generate the following image:
270+
`dot -Tpng target/machine/traffic.dot > traffic.png` will generate the following image:
271271

272272
![traffic light transitions graph](https://raw.githubusercontent.com/rust-bakery/machine/master/assets/traffic.png)
273273

src/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
//! * transitions can have multiple end states if needed (conditions depending on message content, etc)
1111
//! * accessors can be generated for state members
1212
//! * wrapper methods and accessors are generated on the parent enum
13-
//! * the generated code is also written in the `target/` directory for further inspection
14-
//! * a dot file is written in the `target/` directory for graph generation
13+
//! * the generated code is also written in the `target/machine` directory for further inspection
14+
//! * a dot file is written in the `target/machine` directory for graph generation
1515
//!
1616
//! ## Usage
1717
//!
@@ -248,9 +248,9 @@
248248
//! }
249249
//! ```
250250
//!
251-
//! The complete generated code can be found in `target/traffic.rs`.
251+
//! The complete generated code can be found in `target/machine/traffic.rs`.
252252
//!
253-
//! The machine crate will also generate the `target/traffic.dot` file
253+
//! The machine crate will also generate the `target/machine/traffic.dot` file
254254
//! for graphviz usage:
255255
//!
256256
//! ```dot
@@ -263,7 +263,7 @@
263263
//! }
264264
//! ```
265265
//!
266-
//! `dot -Tpng target/traffic.dot > traffic.png` will generate the following image:
266+
//! `dot -Tpng target/machine/traffic.dot > traffic.png` will generate the following image:
267267
//!
268268
//! ![traffic light transitions graph](https://raw.githubusercontent.com/rust-bakery/machine/master/assets/traffic.png)
269269
//!
@@ -409,7 +409,7 @@ extern crate syn;
409409
extern crate quote;
410410

411411
use std::collections::HashMap;
412-
use std::fs::{File, OpenOptions};
412+
use std::fs::{File, OpenOptions, create_dir};
413413
use std::io::{Seek, Write};
414414

415415
use case::CaseExt;
@@ -443,7 +443,8 @@ pub fn machine(input: proc_macro::TokenStream) -> syn::export::TokenStream {
443443

444444
trace!("generated: {}", gen);
445445

446-
let file_name = format!("target/{}.rs", name.to_string().to_lowercase());
446+
let file_name = format!("target/machine/{}.rs", name.to_string().to_lowercase());
447+
let _ = create_dir("target/machine");
447448
File::create(&file_name)
448449
.and_then(|mut file| {
449450
file.seek(std::io::SeekFrom::End(0))?;
@@ -645,9 +646,10 @@ impl Parse for Transition {
645646
impl Transitions {
646647
pub fn render(&self) {
647648
let file_name = format!(
648-
"target/{}.dot",
649+
"target/machine/{}.dot",
649650
self.machine_name.to_string().to_lowercase()
650651
);
652+
let _ = create_dir("target/machine");
651653
let mut file = File::create(&file_name).expect("error opening dot file");
652654

653655
file.write_all(format!("digraph {} {{\n", self.machine_name.to_string()).as_bytes())
@@ -775,7 +777,8 @@ pub fn transitions(input: proc_macro::TokenStream) -> syn::export::TokenStream {
775777

776778
//println!("generated: {:?}", gen);
777779
trace!("generated transitions: {}", stream);
778-
let file_name = format!("target/{}.rs", machine_name.to_string().to_lowercase());
780+
let _ = create_dir("target/machine");
781+
let file_name = format!("target/machine/{}.rs", machine_name.to_string().to_lowercase());
779782
OpenOptions::new()
780783
.create(true)
781784
.write(true)
@@ -986,7 +989,8 @@ pub fn methods(input: proc_macro::TokenStream) -> syn::export::TokenStream {
986989

987990
stream.extend(proc_macro::TokenStream::from(toks));
988991

989-
let file_name = format!("target/{}.rs", machine_name.to_string().to_lowercase());
992+
let file_name = format!("target/machine/{}.rs", machine_name.to_string().to_lowercase());
993+
let _ = create_dir("target/machine");
990994
OpenOptions::new()
991995
.create(true)
992996
.write(true)

0 commit comments

Comments
 (0)