File tree 3 files changed +23
-2
lines changed 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ pub struct ConfigOptsBuild {
60
60
#[ arg( long) ]
61
61
pub features : Option < String > ,
62
62
63
+ /// Whether to build an example.
64
+ #[ arg( long) ]
65
+ pub example : Option < String > ,
66
+
63
67
/// Whether to include hash values in the output file names [default: true]
64
68
#[ arg( long) ]
65
69
pub filehash : Option < bool > ,
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ pub struct RtcBuild {
48
48
pub staging_dist : PathBuf ,
49
49
/// The configuration of the features passed to cargo.
50
50
pub cargo_features : Features ,
51
+ /// Optional example to be passed to cargo.
52
+ pub cargo_example : Option < String > ,
51
53
/// Configuration for automatic application download.
52
54
pub tools : ConfigOptsTools ,
53
55
/// Build process hooks.
@@ -160,6 +162,7 @@ impl RtcBuild {
160
162
staging_dist,
161
163
final_dist,
162
164
cargo_features,
165
+ cargo_example : opts. example ,
163
166
tools,
164
167
hooks,
165
168
inject_autoloader,
@@ -197,6 +200,7 @@ impl RtcBuild {
197
200
final_dist,
198
201
staging_dist,
199
202
cargo_features : Features :: All ,
203
+ cargo_example : None ,
200
204
tools : ConfigOptsTools {
201
205
sass : None ,
202
206
wasm_bindgen : None ,
Original file line number Diff line number Diff line change @@ -374,6 +374,10 @@ impl RustApp {
374
374
args. push ( "--bin" ) ;
375
375
args. push ( bin) ;
376
376
}
377
+ if let Some ( example) = & self . cfg . cargo_example {
378
+ args. push ( "--example" ) ;
379
+ args. push ( example) ;
380
+ }
377
381
378
382
match & self . cargo_features {
379
383
Features :: All => args. push ( "--all-features" ) ,
@@ -767,13 +771,22 @@ impl RustApp {
767
771
return false ;
768
772
}
769
773
770
- // must be cdylib or bin
774
+ // must be cdylib, bin, or example
771
775
if !( art. target . kind . contains ( & "bin" . to_string ( ) )
772
- || art. target . kind . contains ( & "cdylib" . to_string ( ) ) )
776
+ || art. target . kind . contains ( & "cdylib" . to_string ( ) )
777
+ || art. target . kind . contains ( & "example" . to_string ( ) ) )
773
778
{
774
779
return false ;
775
780
}
776
781
782
+ // Are we building an example?
783
+ if let Some ( example) = & self . cfg . cargo_example {
784
+ // it must match
785
+ if example != & art. target . name {
786
+ return false ;
787
+ }
788
+ }
789
+
777
790
// if we have the --bin argument
778
791
if let Some ( bin) = & self . bin {
779
792
// it must match
You can’t perform that action at this time.
0 commit comments