File tree 5 files changed +34
-2
lines changed
5 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
## [ Unreleased]
7
7
8
8
- #722 - boolean environment variables are evaluated as truthy or falsey.
9
+ - #721 - add support for running doctests on nightly if ` CROSS_UNSTABLE_ENABLE_DOCTESTS=true ` .
9
10
- #718 - remove deb subcommand.
10
11
- #714 - use host target directory when falling back to host cargo.
11
12
- #713 - convert relative target directories to absolute paths.
Original file line number Diff line number Diff line change @@ -207,6 +207,15 @@ passthrough = [
207
207
]
208
208
```
209
209
210
+ ### Unstable Features
211
+
212
+ Certain unstable features can enable additional functionality useful to
213
+ cross-compiling. Note that these are unstable, and may be removed at any
214
+ time (particularly if the feature is stabilized or removed), and will
215
+ only be used on a nightly channel.
216
+
217
+ - ` CROSS_UNSTABLE_ENABLE_DOCTESTS=true ` : also run doctests.
218
+
210
219
### Mounting volumes into the build environment
211
220
212
221
In addition to passing environment variables, you can also specify environment
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub struct Args {
14
14
pub target : Option < Target > ,
15
15
pub target_dir : Option < PathBuf > ,
16
16
pub docker_in_docker : bool ,
17
+ pub enable_doctests : bool ,
17
18
}
18
19
19
20
// Fix for issue #581. target_dir must be absolute.
@@ -85,6 +86,9 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
85
86
let docker_in_docker = env:: var ( "CROSS_DOCKER_IN_DOCKER" )
86
87
. map ( |s| bool_from_envvar ( & s) )
87
88
. unwrap_or_default ( ) ;
89
+ let enable_doctests = env:: var ( "CROSS_UNSTABLE_ENABLE_DOCTESTS" )
90
+ . map ( |s| bool:: from_str ( & s) . unwrap_or_default ( ) )
91
+ . unwrap_or_default ( ) ;
88
92
89
93
Ok ( Args {
90
94
all,
@@ -93,5 +97,6 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
93
97
target,
94
98
target_dir,
95
99
docker_in_docker,
100
+ enable_doctests,
96
101
} )
97
102
}
Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ fn run() -> Result<ExitStatus> {
279
279
280
280
let host_version_meta =
281
281
rustc_version:: version_meta ( ) . wrap_err ( "couldn't fetch the `rustc` version" ) ?;
282
+ let is_nightly = rustc:: is_nightly ( & args. channel , & host_version_meta) ;
282
283
if let Some ( root) = cargo:: root ( ) ? {
283
284
let host = host_version_meta. host ( ) ;
284
285
let toml = toml ( & root) ?;
@@ -358,7 +359,7 @@ fn run() -> Result<ExitStatus> {
358
359
. map ( |sc| sc. needs_interpreter ( ) )
359
360
. unwrap_or ( false ) ;
360
361
361
- let filtered_args = if args
362
+ let mut filtered_args = if args
362
363
. subcommand
363
364
. map_or ( false , |s| !s. needs_target_in_command ( ) )
364
365
{
@@ -384,6 +385,14 @@ fn run() -> Result<ExitStatus> {
384
385
args. all . clone ( )
385
386
} ;
386
387
388
+ let is_test = args
389
+ . subcommand
390
+ . map ( |sc| sc == Subcommand :: Test )
391
+ . unwrap_or ( false ) ;
392
+ if is_test && args. enable_doctests && is_nightly {
393
+ filtered_args. push ( "-Zdoctest-xcompile" . to_string ( ) ) ;
394
+ }
395
+
387
396
if target. needs_docker ( ) && args. subcommand . map ( |sc| sc. needs_docker ( ) ) . unwrap_or ( false )
388
397
{
389
398
if host_version_meta. needs_interpreter ( )
Original file line number Diff line number Diff line change 1
1
use std:: path:: PathBuf ;
2
2
use std:: process:: Command ;
3
3
4
- use rustc_version:: { Version , VersionMeta } ;
4
+ use rustc_version:: { Channel , Version , VersionMeta } ;
5
5
6
6
use crate :: errors:: * ;
7
7
use crate :: extensions:: CommandExt ;
@@ -33,6 +33,14 @@ impl VersionMetaExt for VersionMeta {
33
33
}
34
34
}
35
35
36
+ pub fn is_nightly ( channel : & Option < String > , host_version_meta : & VersionMeta ) -> bool {
37
+ if let Some ( channel) = channel {
38
+ channel. contains ( "nightly" )
39
+ } else {
40
+ host_version_meta. channel == Channel :: Nightly
41
+ }
42
+ }
43
+
36
44
pub fn target_list ( verbose : bool ) -> Result < TargetList > {
37
45
Command :: new ( "rustc" )
38
46
. args ( & [ "--print" , "target-list" ] )
You can’t perform that action at this time.
0 commit comments